mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-06 04:40:18 +01:00
freeze rails 2.2
This commit is contained in:
parent
fe5f962dcf
commit
59d5d4c8b6
1468 changed files with 213171 additions and 0 deletions
20
vendor/rails/railties/lib/tasks/annotations.rake
vendored
Normal file
20
vendor/rails/railties/lib/tasks/annotations.rake
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require 'source_annotation_extractor'
|
||||
|
||||
desc "Enumerate all annotations"
|
||||
task :notes do
|
||||
SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true
|
||||
end
|
||||
|
||||
namespace :notes do
|
||||
["OPTIMIZE", "FIXME", "TODO"].each do |annotation|
|
||||
desc "Enumerate all #{annotation} annotations"
|
||||
task annotation.downcase.intern do
|
||||
SourceAnnotationExtractor.enumerate annotation
|
||||
end
|
||||
end
|
||||
|
||||
desc "Enumerate a custom annotation, specify with ANNOTATION=WTFHAX"
|
||||
task :custom do
|
||||
SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
|
||||
end
|
||||
end
|
||||
416
vendor/rails/railties/lib/tasks/databases.rake
vendored
Normal file
416
vendor/rails/railties/lib/tasks/databases.rake
vendored
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
namespace :db do
|
||||
namespace :create do
|
||||
desc 'Create all the local databases defined in config/database.yml'
|
||||
task :all => :environment do
|
||||
ActiveRecord::Base.configurations.each_value do |config|
|
||||
# Skip entries that don't have a database key, such as the first entry here:
|
||||
#
|
||||
# defaults: &defaults
|
||||
# adapter: mysql
|
||||
# username: root
|
||||
# password:
|
||||
# host: localhost
|
||||
#
|
||||
# development:
|
||||
# database: blog_development
|
||||
# <<: *defaults
|
||||
next unless config['database']
|
||||
# Only connect to local databases
|
||||
local_database?(config) { create_database(config) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Create the database defined in config/database.yml for the current RAILS_ENV'
|
||||
task :create => :environment do
|
||||
create_database(ActiveRecord::Base.configurations[RAILS_ENV])
|
||||
end
|
||||
|
||||
def create_database(config)
|
||||
begin
|
||||
if config['adapter'] =~ /sqlite/
|
||||
if File.exist?(config['database'])
|
||||
$stderr.puts "#{config['database']} already exists"
|
||||
else
|
||||
begin
|
||||
# Create the SQLite database
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
ActiveRecord::Base.connection
|
||||
rescue
|
||||
$stderr.puts $!, *($!.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
end
|
||||
end
|
||||
return # Skip the else clause of begin/rescue
|
||||
else
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
ActiveRecord::Base.connection
|
||||
end
|
||||
rescue
|
||||
case config['adapter']
|
||||
when 'mysql'
|
||||
@charset = ENV['CHARSET'] || 'utf8'
|
||||
@collation = ENV['COLLATION'] || 'utf8_general_ci'
|
||||
begin
|
||||
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
||||
ActiveRecord::Base.connection.create_database(config['database'], :charset => (config['charset'] || @charset), :collation => (config['collation'] || @collation))
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
rescue
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)"
|
||||
end
|
||||
when 'postgresql'
|
||||
@encoding = config[:encoding] || ENV['CHARSET'] || 'utf8'
|
||||
begin
|
||||
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
||||
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
rescue
|
||||
$stderr.puts $!, *($!.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
end
|
||||
end
|
||||
else
|
||||
$stderr.puts "#{config['database']} already exists"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :drop do
|
||||
desc 'Drops all the local databases defined in config/database.yml'
|
||||
task :all => :environment do
|
||||
ActiveRecord::Base.configurations.each_value do |config|
|
||||
# Skip entries that don't have a database key
|
||||
next unless config['database']
|
||||
# Only connect to local databases
|
||||
local_database?(config) { drop_database(config) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Drops the database for the current RAILS_ENV'
|
||||
task :drop => :environment do
|
||||
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
|
||||
begin
|
||||
drop_database(config)
|
||||
rescue Exception => e
|
||||
puts "Couldn't drop #{config['database']} : #{e.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def local_database?(config, &block)
|
||||
if %w( 127.0.0.1 localhost ).include?(config['host']) || config['host'].blank?
|
||||
yield
|
||||
else
|
||||
puts "This task only modifies local databases. #{config['database']} is on a remote host."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
||||
task :migrate => :environment do
|
||||
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
||||
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
||||
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
||||
end
|
||||
|
||||
namespace :migrate do
|
||||
desc 'Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.'
|
||||
task :redo => :environment do
|
||||
if ENV["VERSION"]
|
||||
Rake::Task["db:migrate:down"].invoke
|
||||
Rake::Task["db:migrate:up"].invoke
|
||||
else
|
||||
Rake::Task["db:rollback"].invoke
|
||||
Rake::Task["db:migrate"].invoke
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Resets your database using your migrations for the current environment'
|
||||
task :reset => ["db:drop", "db:create", "db:migrate"]
|
||||
|
||||
desc 'Runs the "up" for a given migration VERSION.'
|
||||
task :up => :environment do
|
||||
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
||||
raise "VERSION is required" unless version
|
||||
ActiveRecord::Migrator.run(:up, "db/migrate/", version)
|
||||
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
||||
end
|
||||
|
||||
desc 'Runs the "down" for a given migration VERSION.'
|
||||
task :down => :environment do
|
||||
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
||||
raise "VERSION is required" unless version
|
||||
ActiveRecord::Migrator.run(:down, "db/migrate/", version)
|
||||
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
|
||||
task :rollback => :environment do
|
||||
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
||||
ActiveRecord::Migrator.rollback('db/migrate/', step)
|
||||
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
||||
end
|
||||
|
||||
desc 'Drops and recreates the database from db/schema.rb for the current environment.'
|
||||
task :reset => ['db:drop', 'db:create', 'db:schema:load']
|
||||
|
||||
desc "Retrieves the charset for the current environment's database"
|
||||
task :charset => :environment do
|
||||
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
|
||||
case config['adapter']
|
||||
when 'mysql'
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
puts ActiveRecord::Base.connection.charset
|
||||
when 'postgresql'
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
puts ActiveRecord::Base.connection.encoding
|
||||
else
|
||||
puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
|
||||
end
|
||||
end
|
||||
|
||||
desc "Retrieves the collation for the current environment's database"
|
||||
task :collation => :environment do
|
||||
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
|
||||
case config['adapter']
|
||||
when 'mysql'
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
puts ActiveRecord::Base.connection.collation
|
||||
else
|
||||
puts 'sorry, your database adapter is not supported yet, feel free to submit a patch'
|
||||
end
|
||||
end
|
||||
|
||||
desc "Retrieves the current schema version number"
|
||||
task :version => :environment do
|
||||
puts "Current version: #{ActiveRecord::Migrator.current_version}"
|
||||
end
|
||||
|
||||
desc "Raises an error if there are pending migrations"
|
||||
task :abort_if_pending_migrations => :environment do
|
||||
if defined? ActiveRecord
|
||||
pending_migrations = ActiveRecord::Migrator.new(:up, 'db/migrate').pending_migrations
|
||||
|
||||
if pending_migrations.any?
|
||||
puts "You have #{pending_migrations.size} pending migrations:"
|
||||
pending_migrations.each do |pending_migration|
|
||||
puts ' %4d %s' % [pending_migration.version, pending_migration.name]
|
||||
end
|
||||
abort %{Run "rake db:migrate" to update your database then try again.}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :fixtures do
|
||||
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
|
||||
task :load => :environment do
|
||||
require 'active_record/fixtures'
|
||||
ActiveRecord::Base.establish_connection(Rails.env)
|
||||
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
|
||||
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
||||
|
||||
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
||||
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
||||
end
|
||||
end
|
||||
|
||||
desc "Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures."
|
||||
task :identify => :environment do
|
||||
require "active_record/fixtures"
|
||||
|
||||
label, id = ENV["LABEL"], ENV["ID"]
|
||||
raise "LABEL or ID required" if label.blank? && id.blank?
|
||||
|
||||
puts %Q(The fixture ID for "#{label}" is #{Fixtures.identify(label)}.) if label
|
||||
|
||||
base_dir = ENV['FIXTURES_PATH'] ? File.join(Rails.root, ENV['FIXTURES_PATH']) : File.join(Rails.root, 'test', 'fixtures')
|
||||
Dir["#{base_dir}/**/*.yml"].each do |file|
|
||||
if data = YAML::load(ERB.new(IO.read(file)).result)
|
||||
data.keys.each do |key|
|
||||
key_id = Fixtures.identify(key)
|
||||
|
||||
if key == label || key_id == id.to_i
|
||||
puts "#{file}: #{key} (#{key_id})"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :schema do
|
||||
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
|
||||
task :dump => :environment do
|
||||
require 'active_record/schema_dumper'
|
||||
File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file|
|
||||
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
||||
end
|
||||
end
|
||||
|
||||
desc "Load a schema.rb file into the database"
|
||||
task :load => :environment do
|
||||
file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
|
||||
load(file)
|
||||
end
|
||||
end
|
||||
|
||||
namespace :structure do
|
||||
desc "Dump the database structure to a SQL file"
|
||||
task :dump => :environment do
|
||||
abcs = ActiveRecord::Base.configurations
|
||||
case abcs[RAILS_ENV]["adapter"]
|
||||
when "mysql", "oci", "oracle"
|
||||
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
|
||||
File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
||||
when "postgresql"
|
||||
ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
|
||||
ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
|
||||
ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"]
|
||||
search_path = abcs[RAILS_ENV]["schema_search_path"]
|
||||
search_path = "--schema=#{search_path}" if search_path
|
||||
`pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}`
|
||||
raise "Error dumping database" if $?.exitstatus == 1
|
||||
when "sqlite", "sqlite3"
|
||||
dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"]
|
||||
`#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql`
|
||||
when "sqlserver"
|
||||
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
|
||||
`scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
|
||||
when "firebird"
|
||||
set_firebird_env(abcs[RAILS_ENV])
|
||||
db_string = firebird_db_string(abcs[RAILS_ENV])
|
||||
sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql"
|
||||
else
|
||||
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
|
||||
end
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :test do
|
||||
desc "Recreate the test database from the current schema.rb"
|
||||
task :load => 'db:test:purge' do
|
||||
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
|
||||
ActiveRecord::Schema.verbose = false
|
||||
Rake::Task["db:schema:load"].invoke
|
||||
end
|
||||
|
||||
desc "Recreate the test database from the current environment's database schema"
|
||||
task :clone => %w(db:schema:dump db:test:load)
|
||||
|
||||
desc "Recreate the test databases from the development structure"
|
||||
task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
|
||||
abcs = ActiveRecord::Base.configurations
|
||||
case abcs["test"]["adapter"]
|
||||
when "mysql"
|
||||
ActiveRecord::Base.establish_connection(:test)
|
||||
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
|
||||
IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
|
||||
ActiveRecord::Base.connection.execute(table)
|
||||
end
|
||||
when "postgresql"
|
||||
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
||||
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
||||
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
|
||||
`psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
|
||||
when "sqlite", "sqlite3"
|
||||
dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
|
||||
`#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql`
|
||||
when "sqlserver"
|
||||
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
||||
when "oci", "oracle"
|
||||
ActiveRecord::Base.establish_connection(:test)
|
||||
IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
|
||||
ActiveRecord::Base.connection.execute(ddl)
|
||||
end
|
||||
when "firebird"
|
||||
set_firebird_env(abcs["test"])
|
||||
db_string = firebird_db_string(abcs["test"])
|
||||
sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}"
|
||||
else
|
||||
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Empty the test database"
|
||||
task :purge => :environment do
|
||||
abcs = ActiveRecord::Base.configurations
|
||||
case abcs["test"]["adapter"]
|
||||
when "mysql"
|
||||
ActiveRecord::Base.establish_connection(:test)
|
||||
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"], abcs["test"])
|
||||
when "postgresql"
|
||||
ActiveRecord::Base.clear_active_connections!
|
||||
drop_database(abcs['test'])
|
||||
create_database(abcs['test'])
|
||||
when "sqlite","sqlite3"
|
||||
dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
|
||||
File.delete(dbfile) if File.exist?(dbfile)
|
||||
when "sqlserver"
|
||||
dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
|
||||
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
|
||||
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
|
||||
when "oci", "oracle"
|
||||
ActiveRecord::Base.establish_connection(:test)
|
||||
ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl|
|
||||
ActiveRecord::Base.connection.execute(ddl)
|
||||
end
|
||||
when "firebird"
|
||||
ActiveRecord::Base.establish_connection(:test)
|
||||
ActiveRecord::Base.connection.recreate_database!
|
||||
else
|
||||
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Check for pending migrations and load the test schema'
|
||||
task :prepare => 'db:abort_if_pending_migrations' do
|
||||
if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank?
|
||||
Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:load" }[ActiveRecord::Base.schema_format]].invoke
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :sessions do
|
||||
desc "Creates a sessions migration for use with CGI::Session::ActiveRecordStore"
|
||||
task :create => :environment do
|
||||
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
|
||||
require 'rails_generator'
|
||||
require 'rails_generator/scripts/generate'
|
||||
Rails::Generator::Scripts::Generate.new.run(["session_migration", ENV["MIGRATION"] || "CreateSessions"])
|
||||
end
|
||||
|
||||
desc "Clear the sessions table"
|
||||
task :clear => :environment do
|
||||
ActiveRecord::Base.connection.execute "DELETE FROM #{session_table_name}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def drop_database(config)
|
||||
case config['adapter']
|
||||
when 'mysql'
|
||||
ActiveRecord::Base.connection.drop_database config['database']
|
||||
when /^sqlite/
|
||||
FileUtils.rm(File.join(RAILS_ROOT, config['database']))
|
||||
when 'postgresql'
|
||||
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
||||
ActiveRecord::Base.connection.drop_database config['database']
|
||||
end
|
||||
end
|
||||
|
||||
def session_table_name
|
||||
ActiveRecord::Base.pluralize_table_names ? :sessions : :session
|
||||
end
|
||||
|
||||
def set_firebird_env(config)
|
||||
ENV["ISC_USER"] = config["username"].to_s if config["username"]
|
||||
ENV["ISC_PASSWORD"] = config["password"].to_s if config["password"]
|
||||
end
|
||||
|
||||
def firebird_db_string(config)
|
||||
FireRuby::Database.db_string_for(config.symbolize_keys)
|
||||
end
|
||||
95
vendor/rails/railties/lib/tasks/documentation.rake
vendored
Normal file
95
vendor/rails/railties/lib/tasks/documentation.rake
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
namespace :doc do
|
||||
desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\""
|
||||
Rake::RDocTask.new("app") { |rdoc|
|
||||
rdoc.rdoc_dir = 'doc/app'
|
||||
rdoc.template = ENV['template'] if ENV['template']
|
||||
rdoc.title = ENV['title'] || "Rails Application Documentation"
|
||||
rdoc.options << '--line-numbers' << '--inline-source'
|
||||
rdoc.options << '--charset' << 'utf-8'
|
||||
rdoc.rdoc_files.include('doc/README_FOR_APP')
|
||||
rdoc.rdoc_files.include('app/**/*.rb')
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
}
|
||||
|
||||
desc "Generate documentation for the Rails framework"
|
||||
Rake::RDocTask.new("rails") { |rdoc|
|
||||
rdoc.rdoc_dir = 'doc/api'
|
||||
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
||||
rdoc.title = "Rails Framework Documentation"
|
||||
rdoc.options << '--line-numbers' << '--inline-source'
|
||||
rdoc.rdoc_files.include('README')
|
||||
rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG')
|
||||
rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE')
|
||||
rdoc.rdoc_files.include('vendor/rails/railties/README')
|
||||
rdoc.rdoc_files.include('vendor/rails/railties/lib/{*.rb,commands/*.rb,rails_generator/*.rb}')
|
||||
rdoc.rdoc_files.include('vendor/rails/activerecord/README')
|
||||
rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG')
|
||||
rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb')
|
||||
rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*')
|
||||
rdoc.rdoc_files.include('vendor/rails/activeresource/README')
|
||||
rdoc.rdoc_files.include('vendor/rails/activeresource/CHANGELOG')
|
||||
rdoc.rdoc_files.include('vendor/rails/activeresource/lib/active_resource.rb')
|
||||
rdoc.rdoc_files.include('vendor/rails/activeresource/lib/active_resource/*')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionpack/README')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionmailer/README')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG')
|
||||
rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb')
|
||||
rdoc.rdoc_files.include('vendor/rails/activesupport/README')
|
||||
rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG')
|
||||
rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
|
||||
}
|
||||
|
||||
plugins = FileList['vendor/plugins/**'].collect { |plugin| File.basename(plugin) }
|
||||
|
||||
desc "Generate documentation for all installed plugins"
|
||||
task :plugins => plugins.collect { |plugin| "doc:plugins:#{plugin}" }
|
||||
|
||||
desc "Remove plugin documentation"
|
||||
task :clobber_plugins do
|
||||
rm_rf 'doc/plugins' rescue nil
|
||||
end
|
||||
|
||||
desc "Generate Rails guides"
|
||||
task :guides do
|
||||
source = File.join(RAILTIES_PATH, "doc/guides")
|
||||
destination = File.join(RAILS_ROOT, "doc/guides")
|
||||
FileUtils.rm_r(destination) if File.directory?(destination)
|
||||
FileUtils.mkdir(destination)
|
||||
|
||||
FileUtils.cp_r File.join(source, 'html/.'), File.join(destination)
|
||||
# Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
|
||||
FileUtils.cp_r File.join(source, 'source/images'), File.join(destination)
|
||||
FileUtils.cp_r File.join(source, 'source/stylesheets'), File.join(destination, 'stylesheets')
|
||||
end
|
||||
|
||||
namespace :plugins do
|
||||
# Define doc tasks for each plugin
|
||||
plugins.each do |plugin|
|
||||
desc "Generate documentation for the #{plugin} plugin"
|
||||
task(plugin => :environment) do
|
||||
plugin_base = "vendor/plugins/#{plugin}"
|
||||
options = []
|
||||
files = Rake::FileList.new
|
||||
options << "-o doc/plugins/#{plugin}"
|
||||
options << "--title '#{plugin.titlecase} Plugin Documentation'"
|
||||
options << '--line-numbers' << '--inline-source'
|
||||
options << '--charset' << 'utf-8'
|
||||
options << '-T html'
|
||||
|
||||
files.include("#{plugin_base}/lib/**/*.rb")
|
||||
if File.exist?("#{plugin_base}/README")
|
||||
files.include("#{plugin_base}/README")
|
||||
options << "--main '#{plugin_base}/README'"
|
||||
end
|
||||
files.include("#{plugin_base}/CHANGELOG") if File.exist?("#{plugin_base}/CHANGELOG")
|
||||
|
||||
options << files.to_s
|
||||
|
||||
sh %(rdoc #{options * ' '})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
118
vendor/rails/railties/lib/tasks/framework.rake
vendored
Normal file
118
vendor/rails/railties/lib/tasks/framework.rake
vendored
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
namespace :rails do
|
||||
namespace :freeze do
|
||||
desc "Lock this application to the current gems (by unpacking them into vendor/rails)"
|
||||
task :gems do
|
||||
deps = %w(actionpack activerecord actionmailer activesupport activeresource)
|
||||
require 'rubygems'
|
||||
require 'rubygems/gem_runner'
|
||||
|
||||
rails = (version = ENV['VERSION']) ?
|
||||
Gem.cache.find_name('rails', "= #{version}").first :
|
||||
Gem.cache.find_name('rails').sort_by { |g| g.version }.last
|
||||
|
||||
version ||= rails.version
|
||||
|
||||
unless rails
|
||||
puts "No rails gem #{version} is installed. Do 'gem list rails' to see what you have available."
|
||||
exit
|
||||
end
|
||||
|
||||
puts "Freezing to the gems for Rails #{rails.version}"
|
||||
rm_rf "vendor/rails"
|
||||
mkdir_p "vendor/rails"
|
||||
|
||||
begin
|
||||
chdir("vendor/rails") do
|
||||
rails.dependencies.select { |g| deps.include? g.name }.each do |g|
|
||||
Gem::GemRunner.new.run(["unpack", g.name, "--version", g.version_requirements.to_s])
|
||||
mv(Dir.glob("#{g.name}*").first, g.name)
|
||||
end
|
||||
|
||||
Gem::GemRunner.new.run(["unpack", "rails", "--version", "=#{version}"])
|
||||
FileUtils.mv(Dir.glob("rails*").first, "railties")
|
||||
end
|
||||
rescue Exception
|
||||
rm_rf "vendor/rails"
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0'
|
||||
task :edge do
|
||||
require 'open-uri'
|
||||
version = ENV["RELEASE"] || "edge"
|
||||
target = "rails_#{version}.zip"
|
||||
commits = "http://github.com/api/v1/yaml/rails/rails/commits/master"
|
||||
url = "http://dev.rubyonrails.org/archives/#{target}"
|
||||
|
||||
chdir 'vendor' do
|
||||
latest_revision = YAML.load(open(commits))["commits"].first["id"]
|
||||
|
||||
puts "Downloading Rails from #{url}"
|
||||
File.open('rails.zip', 'wb') do |dst|
|
||||
open url do |src|
|
||||
while chunk = src.read(4096)
|
||||
dst << chunk
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts 'Unpacking Rails'
|
||||
rm_rf 'rails'
|
||||
`unzip rails.zip`
|
||||
%w(rails.zip rails/Rakefile rails/cleanlogs.sh rails/pushgems.rb rails/release.rb).each do |goner|
|
||||
rm_f goner
|
||||
end
|
||||
|
||||
touch "rails/REVISION_#{latest_revision}"
|
||||
end
|
||||
|
||||
puts 'Updating current scripts, javascripts, and configuration settings'
|
||||
Rake::Task['rails:update'].invoke
|
||||
end
|
||||
end
|
||||
|
||||
desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems"
|
||||
task :unfreeze do
|
||||
rm_rf "vendor/rails"
|
||||
end
|
||||
|
||||
desc "Update both configs, scripts and public/javascripts from Rails"
|
||||
task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
|
||||
|
||||
namespace :update do
|
||||
desc "Add new scripts to the application script/ directory"
|
||||
task :scripts do
|
||||
local_base = "script"
|
||||
edge_base = "#{File.dirname(__FILE__)}/../../bin"
|
||||
|
||||
local = Dir["#{local_base}/**/*"].reject { |path| File.directory?(path) }
|
||||
edge = Dir["#{edge_base}/**/*"].reject { |path| File.directory?(path) }
|
||||
|
||||
edge.each do |script|
|
||||
base_name = script[(edge_base.length+1)..-1]
|
||||
next if base_name == "rails"
|
||||
next if local.detect { |path| base_name == path[(local_base.length+1)..-1] }
|
||||
if !File.directory?("#{local_base}/#{File.dirname(base_name)}")
|
||||
mkdir_p "#{local_base}/#{File.dirname(base_name)}"
|
||||
end
|
||||
install script, "#{local_base}/#{base_name}", :mode => 0755
|
||||
end
|
||||
end
|
||||
|
||||
desc "Update your javascripts from your current rails install"
|
||||
task :javascripts do
|
||||
require 'railties_path'
|
||||
project_dir = RAILS_ROOT + '/public/javascripts/'
|
||||
scripts = Dir[RAILTIES_PATH + '/html/javascripts/*.js']
|
||||
scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exist?(project_dir + 'application.js')
|
||||
FileUtils.cp(scripts, project_dir)
|
||||
end
|
||||
|
||||
desc "Update config/boot.rb from your current rails install"
|
||||
task :configs do
|
||||
require 'railties_path'
|
||||
FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
|
||||
end
|
||||
end
|
||||
end
|
||||
80
vendor/rails/railties/lib/tasks/gems.rake
vendored
Normal file
80
vendor/rails/railties/lib/tasks/gems.rake
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
desc "List the gems that this rails application depends on"
|
||||
task :gems => 'gems:base' do
|
||||
Rails.configuration.gems.each do |gem|
|
||||
print_gem_status(gem)
|
||||
end
|
||||
puts
|
||||
puts "I = Installed"
|
||||
puts "F = Frozen"
|
||||
puts "R = Framework (loaded before rails starts)"
|
||||
end
|
||||
|
||||
def print_gem_status(gem, indent=1)
|
||||
code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " "
|
||||
puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
|
||||
gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded?
|
||||
end
|
||||
|
||||
namespace :gems do
|
||||
task :base do
|
||||
$rails_gem_installer = true
|
||||
Rake::Task[:environment].invoke
|
||||
end
|
||||
|
||||
desc "Build any native extensions for unpacked gems"
|
||||
task :build do
|
||||
$rails_gem_installer = true
|
||||
require 'rails/gem_builder'
|
||||
Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |gem_dir|
|
||||
spec_file = File.join(gem_dir, '.specification')
|
||||
next unless File.exists?(spec_file)
|
||||
specification = YAML::load_file(spec_file)
|
||||
next unless ENV['GEM'].blank? || ENV['GEM'] == specification.name
|
||||
Rails::GemBuilder.new(specification, gem_dir).build_extensions
|
||||
puts "Built gem: '#{gem_dir}'"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Installs all required gems for this application."
|
||||
task :install => :base do
|
||||
require 'rubygems'
|
||||
require 'rubygems/gem_runner'
|
||||
Rails.configuration.gems.each { |gem| gem.install unless gem.loaded? }
|
||||
end
|
||||
|
||||
desc "Unpacks the specified gem into vendor/gems."
|
||||
task :unpack => :base do
|
||||
require 'rubygems'
|
||||
require 'rubygems/gem_runner'
|
||||
Rails.configuration.gems.each do |gem|
|
||||
next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
||||
gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
|
||||
end
|
||||
end
|
||||
|
||||
namespace :unpack do
|
||||
desc "Unpacks the specified gems and its dependencies into vendor/gems"
|
||||
task :dependencies => :unpack do
|
||||
require 'rubygems'
|
||||
require 'rubygems/gem_runner'
|
||||
Rails.configuration.gems.each do |gem|
|
||||
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
|
||||
gem.dependencies.each do |dependency|
|
||||
next if dependency.frozen?
|
||||
dependency.unpack_to(Rails::GemDependency.unpacked_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Regenerate gem specifications in correct format."
|
||||
task :refresh_specs => :base do
|
||||
require 'rubygems'
|
||||
require 'rubygems/gem_runner'
|
||||
Rails::VendorGemSourceIndex.silence_spec_warnings = true
|
||||
Rails.configuration.gems.each do |gem|
|
||||
next unless gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
||||
gem.refresh_spec(Rails::GemDependency.unpacked_path) if gem.loaded?
|
||||
end
|
||||
end
|
||||
end
|
||||
9
vendor/rails/railties/lib/tasks/log.rake
vendored
Normal file
9
vendor/rails/railties/lib/tasks/log.rake
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
namespace :log do
|
||||
desc "Truncates all *.log files in log/ to zero bytes"
|
||||
task :clear do
|
||||
FileList["log/*.log"].each do |log_file|
|
||||
f = File.open(log_file, "w")
|
||||
f.close
|
||||
end
|
||||
end
|
||||
end
|
||||
56
vendor/rails/railties/lib/tasks/misc.rake
vendored
Normal file
56
vendor/rails/railties/lib/tasks/misc.rake
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
task :default => :test
|
||||
task :environment do
|
||||
require(File.join(RAILS_ROOT, 'config', 'environment'))
|
||||
end
|
||||
|
||||
desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.'
|
||||
task :secret do
|
||||
puts ActiveSupport::SecureRandom.hex(64)
|
||||
end
|
||||
|
||||
require 'active_support'
|
||||
namespace :time do
|
||||
namespace :zones do
|
||||
desc 'Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
|
||||
task :all do
|
||||
build_time_zone_list(:all)
|
||||
end
|
||||
|
||||
desc 'Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6'
|
||||
task :us do
|
||||
build_time_zone_list(:us_zones)
|
||||
end
|
||||
|
||||
desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time'
|
||||
task :local do
|
||||
jan_offset = Time.now.beginning_of_year.utc_offset
|
||||
jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset
|
||||
offset = jan_offset < jul_offset ? jan_offset : jul_offset
|
||||
build_time_zone_list(:all, offset)
|
||||
end
|
||||
|
||||
# to find UTC -06:00 zones, OFFSET can be set to either -6, -6:00 or 21600
|
||||
def build_time_zone_list(method, offset = ENV['OFFSET'])
|
||||
if offset
|
||||
offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/)
|
||||
sign = $1 == '-' ? -1 : 1
|
||||
hours, minutes = $2.to_f, $3.to_f
|
||||
((hours * 3600) + (minutes.to_f * 60)) * sign
|
||||
elsif offset.to_f.abs <= 13
|
||||
offset.to_f * 3600
|
||||
else
|
||||
offset.to_f
|
||||
end
|
||||
end
|
||||
previous_offset = nil
|
||||
ActiveSupport::TimeZone.__send__(method).each do |zone|
|
||||
if offset.nil? || offset == zone.utc_offset
|
||||
puts "\n* UTC #{zone.formatted_offset} *" unless zone.utc_offset == previous_offset
|
||||
puts zone.name
|
||||
previous_offset = zone.utc_offset
|
||||
end
|
||||
end
|
||||
puts "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
8
vendor/rails/railties/lib/tasks/rails.rb
vendored
Normal file
8
vendor/rails/railties/lib/tasks/rails.rb
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
$VERBOSE = nil
|
||||
|
||||
# Load Rails rakefile extensions
|
||||
Dir["#{File.dirname(__FILE__)}/*.rake"].each { |ext| load ext }
|
||||
|
||||
# Load any custom rakefile extensions
|
||||
Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext }
|
||||
Dir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
|
||||
17
vendor/rails/railties/lib/tasks/routes.rake
vendored
Normal file
17
vendor/rails/railties/lib/tasks/routes.rake
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
desc 'Print out all defined routes in match order, with names.'
|
||||
task :routes => :environment do
|
||||
routes = ActionController::Routing::Routes.routes.collect do |route|
|
||||
name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
|
||||
verb = route.conditions[:method].to_s.upcase
|
||||
segs = route.segments.inject("") { |str,s| str << s.to_s }
|
||||
segs.chop! if segs.length > 1
|
||||
reqs = route.requirements.empty? ? "" : route.requirements.inspect
|
||||
{:name => name, :verb => verb, :segs => segs, :reqs => reqs}
|
||||
end
|
||||
name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max
|
||||
verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max
|
||||
segs_width = routes.collect {|r| r[:segs]}.collect {|s| s.length}.max
|
||||
routes.each do |r|
|
||||
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:segs].ljust(segs_width)} #{r[:reqs]}"
|
||||
end
|
||||
end
|
||||
18
vendor/rails/railties/lib/tasks/statistics.rake
vendored
Normal file
18
vendor/rails/railties/lib/tasks/statistics.rake
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
STATS_DIRECTORIES = [
|
||||
%w(Controllers app/controllers),
|
||||
%w(Helpers app/helpers),
|
||||
%w(Models app/models),
|
||||
%w(Libraries lib/),
|
||||
%w(APIs app/apis),
|
||||
%w(Components components),
|
||||
%w(Integration\ tests test/integration),
|
||||
%w(Functional\ tests test/functional),
|
||||
%w(Unit\ tests test/unit)
|
||||
|
||||
].collect { |name, dir| [ name, "#{RAILS_ROOT}/#{dir}" ] }.select { |name, dir| File.directory?(dir) }
|
||||
|
||||
desc "Report code statistics (KLOCs, etc) from the application"
|
||||
task :stats do
|
||||
require 'code_statistics'
|
||||
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
||||
end
|
||||
139
vendor/rails/railties/lib/tasks/testing.rake
vendored
Normal file
139
vendor/rails/railties/lib/tasks/testing.rake
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
TEST_CHANGES_SINCE = Time.now - 600
|
||||
|
||||
# Look up tests for recently modified sources.
|
||||
def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
|
||||
FileList[source_pattern].map do |path|
|
||||
if File.mtime(path) > touched_since
|
||||
tests = []
|
||||
source_dir = File.dirname(path).split("/")
|
||||
source_file = File.basename(path, '.rb')
|
||||
|
||||
# Support subdirs in app/models and app/controllers
|
||||
modified_test_path = source_dir.length > 2 ? "#{test_path}/" << source_dir[1..source_dir.length].join('/') : test_path
|
||||
|
||||
# For modified files in app/ run the tests for it. ex. /test/functional/account_controller.rb
|
||||
test = "#{modified_test_path}/#{source_file}_test.rb"
|
||||
tests.push test if File.exist?(test)
|
||||
|
||||
# For modified files in app, run tests in subdirs too. ex. /test/functional/account/*_test.rb
|
||||
test = "#{modified_test_path}/#{File.basename(path, '.rb').sub("_controller","")}"
|
||||
FileList["#{test}/*_test.rb"].each { |f| tests.push f } if File.exist?(test)
|
||||
|
||||
return tests
|
||||
|
||||
end
|
||||
end.flatten.compact
|
||||
end
|
||||
|
||||
|
||||
# Recreated here from ActiveSupport because :uncommitted needs it before Rails is available
|
||||
module Kernel
|
||||
def silence_stderr
|
||||
old_stderr = STDERR.dup
|
||||
STDERR.reopen(RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'NUL:' : '/dev/null')
|
||||
STDERR.sync = true
|
||||
yield
|
||||
ensure
|
||||
STDERR.reopen(old_stderr)
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Run all unit, functional and integration tests'
|
||||
task :test do
|
||||
errors = %w(test:units test:functionals test:integration).collect do |task|
|
||||
begin
|
||||
Rake::Task[task].invoke
|
||||
nil
|
||||
rescue => e
|
||||
task
|
||||
end
|
||||
end.compact
|
||||
abort "Errors running #{errors.to_sentence}!" if errors.any?
|
||||
end
|
||||
|
||||
namespace :test do
|
||||
Rake::TestTask.new(:recent => "db:test:prepare") do |t|
|
||||
since = TEST_CHANGES_SINCE
|
||||
touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
|
||||
recent_tests('app/models/**/*.rb', 'test/unit', since) +
|
||||
recent_tests('app/controllers/**/*.rb', 'test/functional', since)
|
||||
|
||||
t.libs << 'test'
|
||||
t.verbose = true
|
||||
t.test_files = touched.uniq
|
||||
end
|
||||
Rake::Task['test:recent'].comment = "Test recent changes"
|
||||
|
||||
Rake::TestTask.new(:uncommitted => "db:test:prepare") do |t|
|
||||
def t.file_list
|
||||
if File.directory?(".svn")
|
||||
changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] }
|
||||
elsif File.directory?(".git")
|
||||
changed_since_checkin = silence_stderr { `git ls-files --modified --others` }.map { |path| path.chomp }
|
||||
else
|
||||
abort "Not a Subversion or Git checkout."
|
||||
end
|
||||
|
||||
models = changed_since_checkin.select { |path| path =~ /app[\\\/]models[\\\/].*\.rb$/ }
|
||||
controllers = changed_since_checkin.select { |path| path =~ /app[\\\/]controllers[\\\/].*\.rb$/ }
|
||||
|
||||
unit_tests = models.map { |model| "test/unit/#{File.basename(model, '.rb')}_test.rb" }
|
||||
functional_tests = controllers.map { |controller| "test/functional/#{File.basename(controller, '.rb')}_test.rb" }
|
||||
|
||||
unit_tests.uniq + functional_tests.uniq
|
||||
end
|
||||
|
||||
t.libs << 'test'
|
||||
t.verbose = true
|
||||
end
|
||||
Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)"
|
||||
|
||||
Rake::TestTask.new(:units => "db:test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/unit/**/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
Rake::Task['test:units'].comment = "Run the unit tests in test/unit"
|
||||
|
||||
Rake::TestTask.new(:functionals => "db:test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/functional/**/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
Rake::Task['test:functionals'].comment = "Run the functional tests in test/functional"
|
||||
|
||||
Rake::TestTask.new(:integration => "db:test:prepare") do |t|
|
||||
t.libs << "test"
|
||||
t.pattern = 'test/integration/**/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
Rake::Task['test:integration'].comment = "Run the integration tests in test/integration"
|
||||
|
||||
Rake::TestTask.new(:benchmark => 'db:test:prepare') do |t|
|
||||
t.libs << 'test'
|
||||
t.pattern = 'test/performance/**/*_test.rb'
|
||||
t.verbose = true
|
||||
t.options = '-- --benchmark'
|
||||
end
|
||||
Rake::Task['test:benchmark'].comment = 'Benchmark the performance tests'
|
||||
|
||||
Rake::TestTask.new(:profile => 'db:test:prepare') do |t|
|
||||
t.libs << 'test'
|
||||
t.pattern = 'test/performance/**/*_test.rb'
|
||||
t.verbose = true
|
||||
end
|
||||
Rake::Task['test:profile'].comment = 'Profile the performance tests'
|
||||
|
||||
Rake::TestTask.new(:plugins => :environment) do |t|
|
||||
t.libs << "test"
|
||||
|
||||
if ENV['PLUGIN']
|
||||
t.pattern = "vendor/plugins/#{ENV['PLUGIN']}/test/**/*_test.rb"
|
||||
else
|
||||
t.pattern = 'vendor/plugins/*/**/test/**/*_test.rb'
|
||||
end
|
||||
|
||||
t.verbose = true
|
||||
end
|
||||
Rake::Task['test:plugins'].comment = "Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)"
|
||||
end
|
||||
37
vendor/rails/railties/lib/tasks/tmp.rake
vendored
Normal file
37
vendor/rails/railties/lib/tasks/tmp.rake
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
namespace :tmp do
|
||||
desc "Clear session, cache, and socket files from tmp/"
|
||||
task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"]
|
||||
|
||||
desc "Creates tmp directories for sessions, cache, and sockets"
|
||||
task :create do
|
||||
FileUtils.mkdir_p(%w( tmp/sessions tmp/cache tmp/sockets tmp/pids ))
|
||||
end
|
||||
|
||||
namespace :sessions do
|
||||
desc "Clears all files in tmp/sessions"
|
||||
task :clear do
|
||||
FileUtils.rm(Dir['tmp/sessions/[^.]*'])
|
||||
end
|
||||
end
|
||||
|
||||
namespace :cache do
|
||||
desc "Clears all files and directories in tmp/cache"
|
||||
task :clear do
|
||||
FileUtils.rm_rf(Dir['tmp/cache/[^.]*'])
|
||||
end
|
||||
end
|
||||
|
||||
namespace :sockets do
|
||||
desc "Clears all files in tmp/sockets"
|
||||
task :clear do
|
||||
FileUtils.rm(Dir['tmp/sockets/[^.]*'])
|
||||
end
|
||||
end
|
||||
|
||||
namespace :pids do
|
||||
desc "Clears all files in tmp/pids"
|
||||
task :clear do
|
||||
FileUtils.rm(Dir['tmp/pids/[^.]*'])
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue