diff options
Diffstat (limited to 'vendor/rails-2.1.0/railties/lib/tasks')
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/annotations.rake | 23 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/databases.rake | 387 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/documentation.rake | 80 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/framework.rake | 114 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/gems.rake | 64 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/log.rake | 9 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/misc.rake | 57 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/rails.rb | 8 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/routes.rake | 17 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/statistics.rake | 18 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/testing.rake | 118 | ||||
-rw-r--r-- | vendor/rails-2.1.0/railties/lib/tasks/tmp.rake | 37 |
12 files changed, 932 insertions, 0 deletions
diff --git a/vendor/rails-2.1.0/railties/lib/tasks/annotations.rake b/vendor/rails-2.1.0/railties/lib/tasks/annotations.rake new file mode 100644 index 000000000..ea6046670 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/annotations.rake @@ -0,0 +1,23 @@ +require 'source_annotation_extractor' + +desc "Enumerate all annotations" +task :notes do + SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true +end + +namespace :notes do + desc "Enumerate all OPTIMIZE annotations" + task :optimize do + SourceAnnotationExtractor.enumerate "OPTIMIZE" + end + + desc "Enumerate all FIXME annotations" + task :fixme do + SourceAnnotationExtractor.enumerate "FIXME" + end + + desc "Enumerate all TODO annotations" + task :todo do + SourceAnnotationExtractor.enumerate "TODO" + end +end
\ No newline at end of file diff --git a/vendor/rails-2.1.0/railties/lib/tasks/databases.rake b/vendor/rails-2.1.0/railties/lib/tasks/databases.rake new file mode 100644 index 000000000..8077d0a40 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/databases.rake @@ -0,0 +1,387 @@ +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 + ActiveRecord::Base.establish_connection(config) + ActiveRecord::Base.connection + 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 + when 'sqlite' + `sqlite "#{config['database']}"` + when 'sqlite3' + `sqlite3 "#{config['database']}"` + 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' + task :redo => [ 'db:rollback', 'db:migrate' ] + + 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 + 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" + task :load => :environment do + require 'active_record/fixtures' + ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym) + (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'test', 'fixtures', '*.{yml,csv}'))).each do |fixture_file| + Fixtures.create_fixtures('test/fixtures', File.basename(fixture_file, '.*')) + end + end + + desc "Search for a fixture given a LABEL or ID." + 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 + + Dir["#{RAILS_ROOT}/test/fixtures/**/*.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'] || "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'] || "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("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} > db/#{RAILS_ENV}_structure.sql" + else + raise "Task not supported by '#{abcs["test"]["adapter"]}'" + end + + if ActiveRecord::Base.connection.supports_migrations? + File.open("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 environment's database schema" + task :clone => %w(db:schema:dump 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 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("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 db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}` + when "sqlite", "sqlite3" + dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] + `#{abcs["test"]["adapter"]} #{dbfile} < 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("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 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"]) + 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 'Prepare the test database and load the schema' + task :prepare => %w(environment db:abort_if_pending_migrations) do + if defined?(ActiveRecord) && !ActiveRecord::Base.configurations.blank? + Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[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 diff --git a/vendor/rails-2.1.0/railties/lib/tasks/documentation.rake b/vendor/rails-2.1.0/railties/lib/tasks/documentation.rake new file mode 100644 index 000000000..331b2450a --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/documentation.rake @@ -0,0 +1,80 @@ +namespace :doc do + desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb" + Rake::RDocTask.new("app") { |rdoc| + rdoc.rdoc_dir = 'doc/app' + rdoc.template = ENV['template'] if ENV['template'] + rdoc.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 + + namespace :plugins do + # Define doc tasks for each plugin + plugins.each do |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 << '-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 diff --git a/vendor/rails-2.1.0/railties/lib/tasks/framework.rake b/vendor/rails-2.1.0/railties/lib/tasks/framework.rake new file mode 100644 index 000000000..71aea0986 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/framework.rake @@ -0,0 +1,114 @@ +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' + Gem.manage_gems + + 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" + url = "http://dev.rubyonrails.org/archives/#{target}" + + chdir 'vendor' do + 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 + 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 diff --git a/vendor/rails-2.1.0/railties/lib/tasks/gems.rake b/vendor/rails-2.1.0/railties/lib/tasks/gems.rake new file mode 100644 index 000000000..0321e60e0 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/gems.rake @@ -0,0 +1,64 @@ +desc "List the gems that this rails application depends on" +task :gems => 'gems:base' do + Rails.configuration.gems.each do |gem| + code = gem.loaded? ? (gem.frozen? ? "F" : "I") : " " + puts "[#{code}] #{gem.name} #{gem.requirement.to_s}" + end + puts + puts "I = Installed" + puts "F = Frozen" +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_ROOT, 'vendor', 'gems', '*')].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(File.join(RAILS_ROOT, 'vendor', 'gems')) 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| + dependency.add_load_paths # double check that we have not already unpacked + next if dependency.frozen? + dependency.unpack_to(File.join(RAILS_ROOT, 'vendor', 'gems')) + end + end + end + end +end
\ No newline at end of file diff --git a/vendor/rails-2.1.0/railties/lib/tasks/log.rake b/vendor/rails-2.1.0/railties/lib/tasks/log.rake new file mode 100644 index 000000000..6e1334692 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/log.rake @@ -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 diff --git a/vendor/rails-2.1.0/railties/lib/tasks/misc.rake b/vendor/rails-2.1.0/railties/lib/tasks/misc.rake new file mode 100644 index 000000000..61042595f --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/misc.rake @@ -0,0 +1,57 @@ +task :default => :test +task :environment do + require(File.join(RAILS_ROOT, 'config', 'environment')) +end + +require 'rails_generator/secret_key_generator' +desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions. Pass a unique identifier to the generator using ID="some unique identifier" for greater security.' +task :secret do + puts Rails::SecretKeyGenerator.new(ENV['ID']).generate_secret +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 + 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
\ No newline at end of file diff --git a/vendor/rails-2.1.0/railties/lib/tasks/rails.rb b/vendor/rails-2.1.0/railties/lib/tasks/rails.rb new file mode 100644 index 000000000..bfcf5bc49 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/rails.rb @@ -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}/lib/tasks/**/*.rake"].sort.each { |ext| load ext } +Dir["#{RAILS_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext } diff --git a/vendor/rails-2.1.0/railties/lib/tasks/routes.rake b/vendor/rails-2.1.0/railties/lib/tasks/routes.rake new file mode 100644 index 000000000..39b713916 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/routes.rake @@ -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
\ No newline at end of file diff --git a/vendor/rails-2.1.0/railties/lib/tasks/statistics.rake b/vendor/rails-2.1.0/railties/lib/tasks/statistics.rake new file mode 100644 index 000000000..dbd077319 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/statistics.rake @@ -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 diff --git a/vendor/rails-2.1.0/railties/lib/tasks/testing.rake b/vendor/rails-2.1.0/railties/lib/tasks/testing.rake new file mode 100644 index 000000000..cc2376cbb --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/testing.rake @@ -0,0 +1,118 @@ +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 + changed_since_checkin = silence_stderr { `svn status` }.map { |path| path.chomp[7 .. -1] } + + 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)" + + 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(: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 diff --git a/vendor/rails-2.1.0/railties/lib/tasks/tmp.rake b/vendor/rails-2.1.0/railties/lib/tasks/tmp.rake new file mode 100644 index 000000000..b191039d6 --- /dev/null +++ b/vendor/rails-2.1.0/railties/lib/tasks/tmp.rake @@ -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
\ No newline at end of file |