Revision 912:5e80956cc792 lib/tasks
| lib/tasks/email.rake | ||
|---|---|---|
| 100 | 100 |
Examples: |
| 101 | 101 |
# No project specified. Emails MUST contain the 'Project' keyword: |
| 102 | 102 |
|
| 103 |
rake redmine:email:receive_iamp RAILS_ENV="production" \\
|
|
| 103 |
rake redmine:email:receive_imap RAILS_ENV="production" \\
|
|
| 104 | 104 |
host=imap.foo.bar username=redmine@example.net password=xxx |
| 105 | 105 |
|
| 106 | 106 |
|
| 107 | 107 |
# Fixed project and default tracker specified, but emails can override |
| 108 | 108 |
# both tracker and priority attributes: |
| 109 | 109 |
|
| 110 |
rake redmine:email:receive_iamp RAILS_ENV="production" \\
|
|
| 110 |
rake redmine:email:receive_imap RAILS_ENV="production" \\
|
|
| 111 | 111 |
host=imap.foo.bar username=redmine@example.net password=xxx ssl=1 \\ |
| 112 | 112 |
project=foo \\ |
| 113 | 113 |
tracker=bug \\ |
| ... | ... | |
| 167 | 167 |
end |
| 168 | 168 |
|
| 169 | 169 |
desc "Send a test email to the user with the provided login name" |
| 170 |
task :test, :login, :needs => :environment do |task, args|
|
|
| 170 |
task :test, [:login] => :environment do |task, args|
|
|
| 171 | 171 |
include Redmine::I18n |
| 172 | 172 |
abort l(:notice_email_error, "Please include the user login to test with. Example: rake redmine:email:test[login]") if args[:login].blank? |
| 173 | 173 |
|
| lib/tasks/extract_fixtures.rake | ||
|---|---|---|
| 1 |
desc 'Create YAML test fixtures from data in an existing database. |
|
| 2 |
Defaults to development database. Set RAILS_ENV to override.' |
|
| 3 |
|
|
| 4 |
task :extract_fixtures => :environment do |
|
| 5 |
sql = "SELECT * FROM %s" |
|
| 6 |
skip_tables = ["schema_info"] |
|
| 7 |
ActiveRecord::Base.establish_connection |
|
| 8 |
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| |
|
| 9 |
i = "000" |
|
| 10 |
File.open("#{RAILS_ROOT}/#{table_name}.yml", 'w' ) do |file|
|
|
| 11 |
data = ActiveRecord::Base.connection.select_all(sql % table_name) |
|
| 12 |
file.write data.inject({}) { |hash, record|
|
|
| 13 |
# cast extracted values |
|
| 14 |
ActiveRecord::Base.connection.columns(table_name).each { |col|
|
|
| 15 |
record[col.name] = col.type_cast(record[col.name]) if record[col.name] |
|
| 16 |
} |
|
| 17 |
hash["#{table_name}_#{i.succ!}"] = record
|
|
| 18 |
hash |
|
| 19 |
}.to_yaml |
|
| 20 |
end |
|
| 21 |
end |
|
| 22 |
end |
|
| 1 |
desc 'Create YAML test fixtures from data in an existing database. |
|
| 2 |
Defaults to development database. Set RAILS_ENV to override.' |
|
| 3 |
|
|
| 4 |
task :extract_fixtures => :environment do |
|
| 5 |
sql = "SELECT * FROM %s" |
|
| 6 |
skip_tables = ["schema_info"] |
|
| 7 |
ActiveRecord::Base.establish_connection |
|
| 8 |
(ActiveRecord::Base.connection.tables - skip_tables).each do |table_name| |
|
| 9 |
i = "000" |
|
| 10 |
File.open("#{Rails.root}/#{table_name}.yml", 'w' ) do |file|
|
|
| 11 |
data = ActiveRecord::Base.connection.select_all(sql % table_name) |
|
| 12 |
file.write data.inject({}) { |hash, record|
|
|
| 13 |
# cast extracted values |
|
| 14 |
ActiveRecord::Base.connection.columns(table_name).each { |col|
|
|
| 15 |
record[col.name] = col.type_cast(record[col.name]) if record[col.name] |
|
| 16 |
} |
|
| 17 |
hash["#{table_name}_#{i.succ!}"] = record
|
|
| 18 |
hash |
|
| 19 |
}.to_yaml |
|
| 20 |
end |
|
| 21 |
end |
|
| 22 |
end |
|
| lib/tasks/fetch_changesets.rake | ||
|---|---|---|
| 1 |
# redMine - project management software
|
|
| 2 |
# Copyright (C) 2006-2008 Jean-Philippe Lang
|
|
| 1 |
# Redmine - project management software
|
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| 6 | 6 |
# as published by the Free Software Foundation; either version 2 |
| 7 | 7 |
# of the License, or (at your option) any later version. |
| 8 |
#
|
|
| 8 |
# |
|
| 9 | 9 |
# This program is distributed in the hope that it will be useful, |
| 10 | 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | 12 |
# GNU General Public License for more details. |
| 13 |
#
|
|
| 13 |
# |
|
| 14 | 14 |
# You should have received a copy of the GNU General Public License |
| 15 | 15 |
# along with this program; if not, write to the Free Software |
| 16 | 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| lib/tasks/initializers.rake | ||
|---|---|---|
| 1 | 1 |
desc 'Generates a configuration file for cookie store sessions.' |
| 2 | 2 |
|
| 3 | 3 |
file 'config/initializers/session_store.rb' do |
| 4 |
path = File.join(RAILS_ROOT, 'config', 'initializers', 'session_store.rb')
|
|
| 4 |
path = File.join(Rails.root, 'config', 'initializers', 'session_store.rb')
|
|
| 5 | 5 |
secret = ActiveSupport::SecureRandom.hex(40) |
| 6 | 6 |
File.open(path, 'w') do |f| |
| 7 | 7 |
f.write <<"EOF" |
| ... | ... | |
| 10 | 10 |
# If you have a load-balancing Redmine cluster, you will need to use the |
| 11 | 11 |
# same version of this file on each machine. And be sure to restart your |
| 12 | 12 |
# server when you modify this file. |
| 13 |
|
|
| 13 |
|
|
| 14 | 14 |
# Your secret key for verifying cookie session data integrity. If you |
| 15 | 15 |
# change this key, all old sessions will become invalid! Make sure the |
| 16 | 16 |
# secret is at least 30 characters and all random, no regular words or |
| lib/tasks/load_default_data.rake | ||
|---|---|---|
| 4 | 4 |
task :load_default_data => :environment do |
| 5 | 5 |
include Redmine::I18n |
| 6 | 6 |
set_language_if_valid('en')
|
| 7 |
|
|
| 7 |
|
|
| 8 | 8 |
envlang = ENV['REDMINE_LANG'] |
| 9 | 9 |
if !envlang || !set_language_if_valid(envlang) |
| 10 | 10 |
puts |
| ... | ... | |
| 21 | 21 |
STDOUT.flush |
| 22 | 22 |
puts "====================================" |
| 23 | 23 |
end |
| 24 |
|
|
| 24 |
|
|
| 25 | 25 |
begin |
| 26 | 26 |
Redmine::DefaultData::Loader.load(current_language) |
| 27 | 27 |
puts "Default configuration data loaded." |
| lib/tasks/locales.rake | ||
|---|---|---|
| 59 | 59 |
desc <<-END_DESC |
| 60 | 60 |
Removes a translation string from all locale file (only works for top-level childless non-multiline keys, probably doesn\'t work on windows). |
| 61 | 61 |
|
| 62 |
This task does not work on Ruby 1.8.6. |
|
| 63 |
You need to use Ruby 1.8.7 or later. |
|
| 64 |
|
|
| 62 | 65 |
Options: |
| 63 | 66 |
key=key_1,key_2 Comma-separated list of keys to delete |
| 64 | 67 |
skip=en,de Comma-separated list of locale files to ignore (filename without extension) |
| ... | ... | |
| 113 | 116 |
end |
| 114 | 117 |
end |
| 115 | 118 |
end |
| 119 |
|
|
| 120 |
desc 'Check parsing yaml by psych library on Ruby 1.9.' |
|
| 121 |
|
|
| 122 |
# On Fedora 12 and 13, if libyaml-devel is available, |
|
| 123 |
# in case of installing by rvm, |
|
| 124 |
# Ruby 1.9 default yaml library is psych. |
|
| 125 |
|
|
| 126 |
task :check_parsing_by_psych do |
|
| 127 |
begin |
|
| 128 |
require 'psych' |
|
| 129 |
parser = Psych::Parser.new |
|
| 130 |
dir = ENV['DIR'] || './config/locales' |
|
| 131 |
files = Dir.glob(File.join(dir,'*.yml')) |
|
| 132 |
files.each do |filename| |
|
| 133 |
next if File.directory? filename |
|
| 134 |
puts "parsing #{filename}..."
|
|
| 135 |
begin |
|
| 136 |
parser.parse File.open(filename) |
|
| 137 |
rescue Exception => e1 |
|
| 138 |
puts(e1.message) |
|
| 139 |
puts("")
|
|
| 140 |
end |
|
| 141 |
end |
|
| 142 |
rescue Exception => e |
|
| 143 |
puts(e.message) |
|
| 144 |
end |
|
| 145 |
end |
|
| 116 | 146 |
end |
| lib/tasks/migrate_from_trac.rake | ||
|---|---|---|
| 1 |
# redMine - project management software
|
|
| 2 |
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
|
| 1 |
# Redmine - project management software
|
|
| 2 |
# Copyright (C) 2006-2011 Jean-Philippe Lang
|
|
| 3 | 3 |
# |
| 4 | 4 |
# This program is free software; you can redistribute it and/or |
| 5 | 5 |
# modify it under the terms of the GNU General Public License |
| ... | ... | |
| 758 | 758 |
prompt('Trac database encoding', :default => 'UTF-8') {|encoding| TracMigrate.encoding encoding}
|
| 759 | 759 |
prompt('Target project identifier') {|identifier| TracMigrate.target_project_identifier identifier}
|
| 760 | 760 |
puts |
| 761 |
|
|
| 761 |
|
|
| 762 | 762 |
# Turn off email notifications |
| 763 | 763 |
Setting.notified_events = [] |
| 764 |
|
|
| 764 |
|
|
| 765 | 765 |
TracMigrate.migrate |
| 766 | 766 |
end |
| 767 | 767 |
end |
| lib/tasks/testing.rake | ||
|---|---|---|
| 5 | 5 |
task :coverage do |
| 6 | 6 |
rm_f "coverage" |
| 7 | 7 |
rm_f "coverage.data" |
| 8 |
rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html" |
|
| 8 |
rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html --exclude gems/"
|
|
| 9 | 9 |
files = Dir.glob("test/**/*_test.rb").join(" ")
|
| 10 | 10 |
system("#{rcov} #{files}")
|
| 11 | 11 |
system("open coverage/index.html") if PLATFORM['darwin']
|
| ... | ... | |
| 30 | 30 |
task :create_dir do |
| 31 | 31 |
FileUtils.mkdir_p Rails.root + '/tmp/test' |
| 32 | 32 |
end |
| 33 |
|
|
| 33 |
|
|
| 34 | 34 |
supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem] |
| 35 |
|
|
| 35 |
|
|
| 36 | 36 |
desc "Creates a test subversion repository" |
| 37 | 37 |
task :subversion => :create_dir do |
| 38 | 38 |
repo_path = "tmp/test/subversion_repository" |
| 39 | 39 |
system "svnadmin create #{repo_path}"
|
| 40 | 40 |
system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}"
|
| 41 | 41 |
end |
| 42 |
|
|
| 42 |
|
|
| 43 | 43 |
desc "Creates a test mercurial repository" |
| 44 | 44 |
task :mercurial => :create_dir do |
| 45 | 45 |
repo_path = "tmp/test/mercurial_repository" |
| ... | ... | |
| 47 | 47 |
system "hg init #{repo_path}"
|
| 48 | 48 |
system "hg -R #{repo_path} pull #{bundle_path}"
|
| 49 | 49 |
end |
| 50 |
|
|
| 50 |
|
|
| 51 | 51 |
(supported_scms - [:subversion, :mercurial]).each do |scm| |
| 52 | 52 |
desc "Creates a test #{scm} repository"
|
| 53 | 53 |
task scm => :create_dir do |
| 54 |
# system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
|
|
| 55 |
system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz"
|
|
| 54 |
# system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test"
|
|
| 55 |
system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz"
|
|
| 56 | 56 |
end |
| 57 | 57 |
end |
| 58 |
|
|
| 58 |
|
|
| 59 | 59 |
desc "Creates all test repositories" |
| 60 | 60 |
task :all => supported_scms |
| 61 | 61 |
end |
| 62 |
|
|
| 62 |
|
|
| 63 | 63 |
desc "Updates installed test repositories" |
| 64 | 64 |
task :update do |
| 65 | 65 |
require 'fileutils' |
| ... | ... | |
| 68 | 68 |
scm = $1 |
| 69 | 69 |
next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first
|
| 70 | 70 |
next if File.stat(dir).ctime > File.stat(fixture).mtime |
| 71 |
|
|
| 71 |
|
|
| 72 | 72 |
FileUtils.rm_rf dir |
| 73 | 73 |
Rake::Task["test:scm:setup:#{scm}"].execute
|
| 74 | 74 |
end |
| 75 | 75 |
end |
| 76 |
|
|
| 76 |
|
|
| 77 | 77 |
Rake::TestTask.new(:units => "db:test:prepare") do |t| |
| 78 | 78 |
t.libs << "test" |
| 79 | 79 |
t.verbose = true |
| 80 | 80 |
t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb'] |
| 81 | 81 |
end |
| 82 | 82 |
Rake::Task['test:scm:units'].comment = "Run the scm unit tests" |
| 83 |
|
|
| 83 |
|
|
| 84 | 84 |
Rake::TestTask.new(:functionals => "db:test:prepare") do |t| |
| 85 | 85 |
t.libs << "test" |
| 86 | 86 |
t.verbose = true |
Also available in: Unified diff