diff options
Diffstat (limited to 'railties/lib/tasks')
-rw-r--r-- | railties/lib/tasks/databases.rake | 13 | ||||
-rw-r--r-- | railties/lib/tasks/gems.rake | 23 | ||||
-rw-r--r-- | railties/lib/tasks/misc.rake | 6 |
3 files changed, 34 insertions, 8 deletions
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 9588fabb2d..cdab5d8bb0 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -156,8 +156,8 @@ namespace :db do 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 'Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.' + task :reset => [ 'db:drop', 'db:setup' ] desc "Retrieves the charset for the current environment's database" task :charset => :environment do @@ -206,6 +206,15 @@ namespace :db do end end + desc 'Create the database, load the schema, and initialize with the seed data' + task :setup => [ 'db:create', 'db:schema:load', 'db:seed' ] + + desc 'Load the seed data from db/seeds.rb' + task :seed => :environment do + seed_file = File.join(Rails.root, 'db', 'seeds.rb') + load(seed_file) if File.exist?(seed_file) + 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 diff --git a/railties/lib/tasks/gems.rake b/railties/lib/tasks/gems.rake index ed07bf2016..e496e1a04f 100644 --- a/railties/lib/tasks/gems.rake +++ b/railties/lib/tasks/gems.rake @@ -20,18 +20,25 @@ namespace :gems do desc "Build any native extensions for unpacked gems" task :build do $gems_build_rake_task = true - Rake::Task['gems:unpack'].invoke - current_gems.each &:build + frozen_gems.each {|gem| gem.build } + end + + namespace :build do + desc "Force the build of all gems" + task :force do + $gems_build_rake_task = true + frozen_gems.each { |gem| gem.build(:force => true) } + end end desc "Installs all required gems." task :install => :base do - current_gems.each &:install + current_gems.each {|gem| gem.install } end desc "Unpacks all required gems into vendor/gems." task :unpack => :install do - current_gems.each &:unpack + current_gems.each {|gem| gem.unpack } end namespace :unpack do @@ -43,7 +50,7 @@ namespace :gems do desc "Regenerate gem specifications in correct format." task :refresh_specs => :base do - current_gems.each &:refresh + current_gems.each {|gem| gem.refresh } end end @@ -53,6 +60,12 @@ def current_gems gems end +def frozen_gems + Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*-*')].map do |gem_dir| + Rails::GemDependency.from_directory_name(gem_dir) + end +end + def print_gem_status(gem, indent=1) code = case when gem.framework_gem? then 'R' diff --git a/railties/lib/tasks/misc.rake b/railties/lib/tasks/misc.rake index 9e6f96db5b..fb2fc31dc1 100644 --- a/railties/lib/tasks/misc.rake +++ b/railties/lib/tasks/misc.rake @@ -12,10 +12,10 @@ end desc 'Generate a crytographically secure secret key. This is typically used to generate a secret for cookie sessions.' task :secret do + require 'active_support/secure_random' 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' @@ -30,6 +30,8 @@ namespace :time do desc 'Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time' task :local do + require 'active_support' + require 'active_support/time' 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 @@ -38,6 +40,8 @@ namespace :time do # 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']) + require 'active_support' + require 'active_support/time' if offset offset = if offset.to_s.match(/(\+|-)?(\d+):(\d+)/) sign = $1 == '-' ? -1 : 1 |