diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 27 | ||||
-rw-r--r-- | railties/lib/rails/commands/application.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/USAGE | 6 | ||||
-rw-r--r-- | railties/lib/rails/initializable.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/test_help.rb | 2 |
8 files changed, 36 insertions, 20 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 2e412147d3..cbb2d23238 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -91,7 +91,7 @@ module Rails @routes_reloader ||= RoutesReloader.new end - def initialize!(group=nil) + def initialize!(group=:default) raise "Application has been already initialized." if @initialized run_initializers(group, self) @initialized = true diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index c363e53c10..448521d2f0 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -37,19 +37,20 @@ module Rails @cache_store = [ :file_store, "#{root}/tmp/cache/" ] @assets = ActiveSupport::OrderedOptions.new - @assets.enabled = false - @assets.paths = [] - @assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) }, - /(?:\/|\\|\A)application\.(css|js)$/ ] - @assets.prefix = "/assets" - @assets.version = '' - @assets.debug = false - @assets.compile = true - @assets.digest = false - @assets.manifest = nil - @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ] - @assets.js_compressor = nil - @assets.css_compressor = nil + @assets.enabled = false + @assets.paths = [] + @assets.precompile = [ Proc.new{ |path| !File.extname(path).in?(['.js', '.css']) }, + /(?:\/|\\|\A)application\.(css|js)$/ ] + @assets.prefix = "/assets" + @assets.version = '' + @assets.debug = false + @assets.compile = true + @assets.digest = false + @assets.manifest = nil + @assets.cache_store = [ :file_store, "#{root}/tmp/cache/assets/" ] + @assets.js_compressor = nil + @assets.css_compressor = nil + @assets.initialize_on_precompile = true end def compiled_asset_path diff --git a/railties/lib/rails/commands/application.rb b/railties/lib/rails/commands/application.rb index 1cf23a8b92..60d1aed73a 100644 --- a/railties/lib/rails/commands/application.rb +++ b/railties/lib/rails/commands/application.rb @@ -9,6 +9,14 @@ if ARGV.first != "new" ARGV[0] = "--help" else ARGV.shift + railsrc = File.join(File.expand_path("~"), ".railsrc") + if File.exist?(railsrc) + extra_args_string = File.open(railsrc).read + extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten + puts "Using #{extra_args.join(" ")} from #{railsrc}" + ARGV << extra_args + ARGV.flatten! + end end require 'rubygems' if ARGV.include?("--dev") diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 0e1e719596..2d25273050 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -542,7 +542,7 @@ module Rails require environment if environment end - initializer :append_assets_path, :group => :assets do |app| + initializer :append_assets_path, :group => :all do |app| app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 575f4bb106..b26839644e 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -90,7 +90,7 @@ module Rails append_file "Gemfile", "\ngroup #{name} do\n", :force => true @in_group = true - instance_eval &block + instance_eval(&block) @in_group = false append_file "Gemfile", "end\n", :force => true @@ -252,7 +252,7 @@ module Rails # def rake(command, options={}) log :rake, command - env = options[:env] || 'development' + env = options[:env] || ENV["RAILS_ENV"] || 'development' sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : '' in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", :verbose => false) } end diff --git a/railties/lib/rails/generators/rails/app/USAGE b/railties/lib/rails/generators/rails/app/USAGE index 9e7a78d132..691095f33f 100644 --- a/railties/lib/rails/generators/rails/app/USAGE +++ b/railties/lib/rails/generators/rails/app/USAGE @@ -2,6 +2,12 @@ Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. + You can specify extra command-line arguments to be used every time + 'rails new' runs in the .railsrc configuration file in your home directory. + + Note that the arguments specified in the .railsrc file don't affect the + defaults values shown above in this help message. + Example: rails new ~/Code/Ruby/weblog diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb index 4c1da0a5a5..04d5b55c69 100644 --- a/railties/lib/rails/initializable.rb +++ b/railties/lib/rails/initializable.rb @@ -10,6 +10,7 @@ module Rails attr_reader :name, :block def initialize(name, context, options, &block) + options[:group] ||= :default @name, @context, @options, @block = name, context, options, block end @@ -48,10 +49,10 @@ module Rails end end - def run_initializers(group=nil, *args) + def run_initializers(group=:default, *args) return if instance_variable_defined?(:@ran) initializers.tsort.each do |initializer| - initializer.run(*args) if group.nil? || initializer.belongs_to?(group) + initializer.run(*args) if initializer.belongs_to?(group) end @ran = true end diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index 68f566274d..8d0d8cacac 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -24,7 +24,7 @@ if defined?(MiniTest) end end -if defined?(ActiveRecord) +if defined?(ActiveRecord::Base) require 'active_record/test_case' class ActiveSupport::TestCase |