diff options
author | José Valim <jose.valim@gmail.com> | 2009-11-11 08:16:25 -0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-11-11 08:16:25 -0200 |
commit | 01ae99c681d31803f3a29f8305c9a041aa456660 (patch) | |
tree | 7fdb9e32b743aeb254854371349cecfd2499defa /railties/lib | |
parent | d002826e54415a340e55fdbf363d005faebf8fc5 (diff) | |
parent | fca32eb6c5b41e4f19a25b7b246c4a8a3d763667 (diff) | |
download | rails-01ae99c681d31803f3a29f8305c9a041aa456660.tar.gz rails-01ae99c681d31803f3a29f8305c9a041aa456660.tar.bz2 rails-01ae99c681d31803f3a29f8305c9a041aa456660.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 57 | ||||
-rw-r--r-- | railties/lib/rails/commands/destroy.rb | 3 | ||||
-rwxr-xr-x | railties/lib/rails/commands/generate.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 14 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 58 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 61 | ||||
-rw-r--r-- | railties/lib/rails/generators/active_record.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/generators/base.rb | 78 | ||||
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/app_generator.rb | 13 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/Gemfile | 17 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/about (renamed from railties/lib/rails/generators/rails/app/templates/script/about.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/console (renamed from railties/lib/rails/generators/rails/app/templates/script/console.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/dbconsole (renamed from railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/destroy | 2 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/destroy.tt | 3 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/generate (renamed from railties/lib/rails/generators/rails/app/templates/script/generate.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker (renamed from railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/performance/profiler (renamed from railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/plugin (renamed from railties/lib/rails/generators/rails/app/templates/script/plugin.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/runner (renamed from railties/lib/rails/generators/rails/app/templates/script/runner.tt) | 1 | ||||
-rwxr-xr-x | railties/lib/rails/generators/rails/app/templates/script/server (renamed from railties/lib/rails/generators/rails/app/templates/script/server.tt) | 1 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/resource_helpers.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/initializable.rb | 139 | ||||
-rw-r--r-- | railties/lib/rails/plugin.rb | 99 | ||||
-rw-r--r-- | railties/lib/rails/ruby_version_check.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/CHANGELOG.rdoc (renamed from railties/lib/rails/vendor/thor-0.11.8/CHANGELOG.rdoc) | 7 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/LICENSE (renamed from railties/lib/rails/vendor/thor-0.11.8/LICENSE) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/README.rdoc (renamed from railties/lib/rails/vendor/thor-0.11.8/README.rdoc) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/Thorfile (renamed from railties/lib/rails/vendor/thor-0.11.8/Thorfile) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/create_file.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/create_file.rb) | 1 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/directory.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/directory.rb) | 14 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/empty_directory.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/empty_directory.rb) | 1 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/file_manipulation.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/file_manipulation.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/inject_into_file.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/inject_into_file.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/base.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/base.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/core_ext/hash_with_indifferent_access.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/core_ext/hash_with_indifferent_access.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/core_ext/ordered_hash.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/core_ext/ordered_hash.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/error.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/error.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/group.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/group.rb) | 2 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/invocation.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/invocation.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/argument.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/argument.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/arguments.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/arguments.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/option.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/option.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/options.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/options.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/rake_compat.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/rake_compat.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/runner.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/runner.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell/basic.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell/basic.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell/color.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell/color.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/task.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/task.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/util.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/util.rb) | 0 | ||||
-rw-r--r-- | railties/lib/rails/vendor/thor-0.12.0/lib/thor/version.rb (renamed from railties/lib/rails/vendor/thor-0.11.8/lib/thor/version.rb) | 0 |
58 files changed, 367 insertions, 243 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 26a55a73e1..b43dcb0041 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -1,6 +1,6 @@ module Rails class Application - extend Initializable + include Initializable class << self # Stub out App initialize @@ -8,6 +8,10 @@ module Rails new end + def new + @instance ||= super + end + def config @config ||= Configuration.new end @@ -27,23 +31,36 @@ module Rails config.root end - def routes - ActionController::Routing::Routes + def call(env) + new.call(env) end + end - def middleware - config.middleware - end + def initialize + run_initializers + end - def call(env) - @app ||= middleware.build(routes) - @app.call(env) - end + def config + self.class.config + end - def new - run_initializers - self - end + alias configuration config + + def plugin_loader + self.class.plugin_loader + end + + def middleware + config.middleware + end + + def routes + ActionController::Routing::Routes + end + + def call(env) + @app ||= middleware.build(routes) + @app.call(env) end initializer :initialize_rails do @@ -242,6 +259,7 @@ module Rails # If assigned value cannot be matched to a TimeZone, an exception will be raised. initializer :initialize_time_zone do if config.time_zone + require 'active_support/core_ext/time/zones' zone_default = Time.__send__(:get_zone, config.time_zone) unless zone_default @@ -411,17 +429,6 @@ module Rails end end - # Configure generators if they were already loaded - # === - # TODO: Does this need to be an initializer here? - initializer :initialize_generators do - if defined?(Rails::Generators) - Rails::Generators.no_color! unless config.generators.colorize_logging - Rails::Generators.aliases.deep_merge! config.generators.aliases - Rails::Generators.options.deep_merge! config.generators.options - end - end - # For each framework, search for instrument file with Notifications hooks. # initializer :load_notifications_hooks do diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 1270fdd033..f85c17bb94 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,4 +1,5 @@ -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) +require 'rails/generators' +Rails::Generators.configure! if ARGV.size == 0 Rails::Generators.help diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index d91dcf9788..c5e3ae3529 100755 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,4 +1,5 @@ -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) +require 'rails/generators' +Rails::Generators.configure! if ARGV.size == 0 Rails::Generators.help diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 0a545f23de..2b847ba711 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -278,12 +278,16 @@ module Rails end def method_missing(method, *args) - method = method.to_s.sub(/=$/, '').to_sym - namespace = args.first.is_a?(Symbol) ? args.shift : nil - configuration = args.first.is_a?(Hash) ? args.shift : nil + method = method.to_s.sub(/=$/, '').to_sym - @options[:rails][method] = namespace if namespace - namespace ||= method + if method == :rails + namespace, configuration = :rails, args.shift + elsif args.first.is_a?(Hash) + namespace, configuration = method, args.shift + else + namespace, configuration = args.shift, args.shift + @options[:rails][method] = namespace + end if configuration aliases = configuration.delete(:aliases) diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 49f32aa0db..19412c259e 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -9,7 +9,7 @@ require 'active_support/core_ext/module/attribute_accessors' require 'active_support/core_ext/string/inflections' # TODO: Do not always push on vendored thor -$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.11.8/lib") +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.12.0/lib") require 'rails/generators/base' require 'rails/generators/named_base' @@ -72,6 +72,12 @@ module Rails } } + def self.configure!(config = Rails.application.config.generators) #:nodoc: + no_color! unless config.colorize_logging + aliases.deep_merge! config.aliases + options.deep_merge! config.options + end + def self.aliases #:nodoc: @aliases ||= DEFAULT_ALIASES.dup end @@ -152,7 +158,18 @@ module Rails end load_paths # Cache load paths. Needed to avoid __FILE__ pointing to wrong paths. - # Receives a namespace and tries different combinations to find a generator. + # Rails finds namespaces exactly as thor, with three conveniences: + # + # 1) If your generator name ends with generator, as WebratGenerator, it sets + # its namespace to "webrat", so it can be invoked as "webrat" and not + # "webrat_generator"; + # + # 2) If your generator has a generators namespace, as Rails::Generators::WebratGenerator, + # the namespace is set to "rails:generators:webrat", but Rails allows it + # to be invoked simply as "rails:webrat". The "generators" is added + # automatically when doing the lookup; + # + # 3) Rails looks in load paths and loads the generator just before it's going to be used. # # ==== Examples # @@ -162,30 +179,29 @@ module Rails # # "rails:generators:webrat", "webrat:generators:integration", "webrat" # - # If the namespace has ":" included we consider that a absolute namespace - # was given and the lookup above does not happen. Just the name is searched. + # On the other hand, if "rails:webrat" is given, it will search for: # - # Finally, it deals with one kind of shortcut: + # "rails:generators:webrat", "rails:webrat" # - # find_by_namespace "test_unit:model" - # - # It will search for generators at: - # - # "test_unit:generators:model", "test_unit:model" + # Notice that the "generators" namespace is handled automatically by Rails, + # so you don't need to type it when you want to invoke a generator in specific. # def self.find_by_namespace(name, base=nil, context=nil) #:nodoc: - name, attempts = name.to_s, [] + name, attempts = name.to_s, [ ] case name.count(':') when 1 base, name = name.split(':') return find_by_namespace(name, base) when 0 - attempts << "#{base}:generators:#{name}" if base - attempts << "#{name}:generators:#{context}" if context + attempts += generator_names(base, name) if base + attempts += generator_names(name, context) if context end attempts << name + attempts += generator_names(name, name) unless name.include?(?:) + attempts.uniq! + unloaded = attempts - namespaces lookup(unloaded) @@ -231,7 +247,10 @@ module Rails until tail.empty? others += Dir[File.join(path, *tail)].collect do |file| - file.split('/')[-tail.size, 2].join(':').sub(/_generator\.rb$/, '') + name = file.split('/')[-tail.size, 2] + name.last.sub!(/_generator\.rb$/, '') + name.uniq! + name.join(':') end tail.shift end @@ -246,7 +265,7 @@ module Rails # Return all defined namespaces. # def self.namespaces #:nodoc: - Thor::Base.subclasses.map{ |klass| klass.namespace } + Thor::Base.subclasses.map { |klass| klass.namespace } end # Keep builtin generators in an Array[Array[group, name]]. @@ -257,6 +276,12 @@ module Rails end end + # By default, Rails strips the generator namespace to make invocations + # easier. This method generaters the both possibilities names. + def self.generator_names(first, second) + [ "#{first}:generators:#{second}", "#{first}:#{second}" ] + end + # Try callbacks for the given base. # def self.invoke_fallbacks_for(name, base) @@ -285,6 +310,9 @@ module Rails Dir[File.join(path, '**', attempts)].each do |file| begin require file + rescue NameError => e + raise unless e.message =~ /Rails::Generator/ + warn "[WARNING] Could not load generator at #{file.inspect} because it's a Rails 2.x generator, which is not supported anymore" rescue Exception => e warn "[WARNING] Could not load generator at #{file.inspect}. Error: #{e.message}" end diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 9254f8d918..8677bf283b 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -1,4 +1,5 @@ require 'open-uri' +require 'active_support/deprecation' module Rails module Generators @@ -45,19 +46,56 @@ module Rails # # gem "rspec", :env => :test # gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/" + # gem "rails", "3.0", :git => "git://github.com/rails/rails" # - def gem(name, options={}) - log :gem, name - env = options.delete(:env) + def gem(*args) + options = args.extract_options! + name, version = args - gems_code = "config.gem '#{name}'" + # Deal with deprecated options + { :env => :only, :lib => :require_as }.each do |old, new| + next unless options[old] + options[new] = options.delete(old) + ActiveSupport::Deprecation.warn "#{old.inspect} option in gem is deprecated, use #{new.inspect} instead" + end + + # Deal with deprecated source + if source = options.delete(:source) + ActiveSupport::Deprecation.warn ":source option in gem is deprecated, use add_source method instead" + add_source(source) + end + + # Set the message to be shown in logs. Uses the git repo if one is given, + # otherwise use name (version). + parts, message = [ name.inspect ], name + if version ||= options.delete(:version) + parts << version + message << " (#{version})" + end + message = options[:git] if options[:git] + + log :gemfile, message + + options.each do |option, value| + parts << ":#{option} => #{value.inspect}" + end - if options.any? - opts = options.inject([]) {|result, h| result << [":#{h[0]} => #{h[1].inspect.gsub('"',"'")}"] }.sort.join(", ") - gems_code << ", #{opts}" + in_root do + append_file "Gemfile", "gem #{parts.join(", ")}", :verbose => false end + end + + # Add the given source to Gemfile + # + # ==== Example + # + # source "http://gems.github.com/" + def add_source(source, options={}) + log :source, source - environment gems_code, :env => env + in_root do + prepend_file "Gemfile", "source #{source.inspect}", :verbose => false + end end # Adds a line inside the Initializer block for config/environment.rb. @@ -79,6 +117,7 @@ module Rails end end end + alias :application :environment # Run a command in git. # @@ -222,9 +261,8 @@ module Rails # # freeze! # - def freeze!(args = {}) - log :vendor, "rails" - in_root { run("#{extify(:rake)} rails:freeze:edge", :verbose => false) } + def freeze!(args={}) + ActiveSupport::Deprecation.warn "freeze! is deprecated since your rails app now comes bundled with Rails by default, please check your Gemfile" end # Make an entry in Rails routing file conifg/routes.rb @@ -251,6 +289,7 @@ module Rails if args.size == 1 say args.first.to_s else + args << (self.behavior == :invoke ? :green : :red) say_status *args end end diff --git a/railties/lib/rails/generators/active_record.rb b/railties/lib/rails/generators/active_record.rb index babad33db3..c62f75c384 100644 --- a/railties/lib/rails/generators/active_record.rb +++ b/railties/lib/rails/generators/active_record.rb @@ -1,6 +1,7 @@ require 'rails/generators/named_base' require 'rails/generators/migration' require 'rails/generators/active_model' +require 'active_record' module ActiveRecord module Generators diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 7af99797ea..226ae63963 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -12,11 +12,24 @@ module Rails add_runtime_options! + # Always move to rails source root. + # + def initialize(*args) #:nodoc: + if !invoked?(args) && defined?(Rails.root) && Rails.root + self.destination_root = Rails.root + FileUtils.cd(destination_root) + end + super + end + # Automatically sets the source root based on the class name. # def self.source_root - @_rails_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), - base_name, generator_name, 'templates')) + @_rails_source_root ||= begin + if base_name && generator_name + File.expand_path(File.join(File.dirname(__FILE__), base_name, generator_name, 'templates')) + end + end end # Tries to get the description from a USAGE file one folder above the source @@ -201,9 +214,12 @@ module Rails # def self.inherited(base) #:nodoc: super - base.source_root # Cache source root - if Rails.root && base.name !~ /Base$/ + # Cache source root, we need to do this, since __FILE__ is a relative value + # and can point to wrong directions when inside an specified directory. + base.source_root + + if base.name && base.name !~ /Base$/ && base.base_name && base.generator_name && defined?(Rails.root) && Rails.root path = File.expand_path(File.join(Rails.root, 'lib', 'templates')) if base.name.include?('::') base.source_paths << File.join(path, base.base_name, base.generator_name) @@ -247,6 +263,13 @@ module Rails end end + # Check if this generator was invoked from another one by inspecting + # parameters. + # + def invoked?(args) + args.last.is_a?(Hash) && args.last.key?(:invocations) + end + # Use Rails default banner. # def self.banner @@ -256,17 +279,24 @@ module Rails # Sets the base_name taking into account the current class namespace. # def self.base_name - @base_name ||= self.name.split('::').first.underscore + @base_name ||= begin + if base = name.to_s.split('::').first + base.underscore + end + end end # Removes the namespaces and get the generator name. For example, # Rails::Generators::MetalGenerator will return "metal" as generator name. # def self.generator_name - @generator_name ||= begin - klass_name = self.name.split('::').last - klass_name.sub!(/Generator$/, '') - klass_name.underscore + if name + @generator_name ||= begin + if klass_name = name.to_s.split('::').last + klass_name.sub!(/Generator$/, '') + klass_name.underscore + end + end end end @@ -274,35 +304,27 @@ module Rails # Rails::Generators.options. # def self.default_value_for_option(name, options) - config = Rails::Generators.options - generator, base = generator_name.to_sym, base_name.to_sym - - if config[generator] && config[generator].key?(name) - config[generator][name] - elsif config[base] && config[base].key?(name) - config[base][name] - elsif config[:rails].key?(name) - config[:rails][name] - else - options[:default] - end + default_for_option(Rails::Generators.options, name, options, options[:default]) end # Return default aliases for the option name given doing a lookup in # Rails::Generators.aliases. # def self.default_aliases_for_option(name, options) - config = Rails::Generators.aliases - generator, base = generator_name.to_sym, base_name.to_sym + default_for_option(Rails::Generators.aliases, name, options, options[:aliases]) + end - if config[generator] && config[generator].key?(name) - config[generator][name] - elsif config[base] && config[base].key?(name) - config[base][name] + # Return default for the option name given doing a lookup in config. + # + def self.default_for_option(config, name, options, default) + if generator_name and c = config[generator_name.to_sym] and c.key?(name) + c[name] + elsif base_name and c = config[base_name.to_sym] and c.key?(name) + c[name] elsif config[:rails].key?(name) config[:rails][name] else - options[:aliases] + default end end diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index 0e5976f915..1d4f52286e 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -11,7 +11,10 @@ module Rails alias :file_name :singular_name - def initialize(*args) #:nodoc: + def initialize(args, *options) #:nodoc: + # Unfreeze name in case it's given as a frozen string + args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? + super assign_names!(self.name) parse_attributes! if respond_to?(:attributes) diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 93d9ac553d..2bcea4bc8f 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -12,9 +12,6 @@ module Rails::Generators class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3", :desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})" - class_option :freeze, :type => :boolean, :aliases => "-F", :default => false, - :desc => "Freeze Rails in vendor/rails from the gems" - class_option :template, :type => :string, :aliases => "-m", :desc => "Path to an application template (can be a filesystem path or URL)." @@ -126,8 +123,10 @@ module Rails::Generators end def create_script_files - directory "script" - chmod "script", 0755, :verbose => false + directory "script" do |file| + prepend_file file, "#{shebang}\n", :verbose => false + chmod file, 0755, :verbose => false + end end def create_test_files @@ -155,10 +154,6 @@ module Rails::Generators raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}" end - def freeze? - freeze! if options[:freeze] - end - protected attr_accessor :rails_template diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 3966c0f70d..8e851a64e7 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -1,20 +1,17 @@ -# Gemfile is where you list all of your application's dependencies -# -<%= "# " if options.freeze? %>gem "rails", "<%= Rails::VERSION::STRING %>" -# -# Bundling edge rails: -<%= "# " unless options.freeze? %>gem "rails", "<%= Rails::VERSION::STRING %>", :git => "git://github.com/rails/rails.git" +# Edit this Gemfile to bundle your application's dependencies. -# Specify gemcutter as a gem source -# source "http://gemcutter.org" +gem "rails", "<%= Rails::VERSION::STRING %>" -# Specify gems that this application depends on and have them installed with rake gems:install +## Bundle edge rails: +# gem "rails", :git => "git://github.com/rails/rails.git" + +## Bundle the gems you use: # gem "bj" # gem "hpricot", "0.6" # gem "sqlite3-ruby", :require_as => "sqlite3" # gem "aws-s3", :require_as => "aws/s3" -# Specify gems that should only be required in certain environments +## Bundle gems used only in certain environments: # gem "rspec", :only => :test # only :test do # gem "webrat" diff --git a/railties/lib/rails/generators/rails/app/templates/script/about.tt b/railties/lib/rails/generators/rails/app/templates/script/about index 7639d4040f..93fd007649 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/about.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/about @@ -1,4 +1,3 @@ -<%= shebang %> require File.expand_path('../../config/environment', __FILE__) $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'rails/commands/about' diff --git a/railties/lib/rails/generators/rails/app/templates/script/console.tt b/railties/lib/rails/generators/rails/app/templates/script/console index 1cd2eb8b53..20aa799d2f 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/console.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/console @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../config/application', __FILE__) require 'rails/commands/console' diff --git a/railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt b/railties/lib/rails/generators/rails/app/templates/script/dbconsole index 94beb13715..e6a1c59394 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/dbconsole.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/dbconsole @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../config/application', __FILE__) require 'rails/commands/dbconsole' diff --git a/railties/lib/rails/generators/rails/app/templates/script/destroy b/railties/lib/rails/generators/rails/app/templates/script/destroy new file mode 100755 index 0000000000..adfa8e8426 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/script/destroy @@ -0,0 +1,2 @@ +require File.expand_path('../../config/environment', __FILE__) +require 'rails/commands/destroy' diff --git a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt b/railties/lib/rails/generators/rails/app/templates/script/destroy.tt deleted file mode 100755 index c97090cdee..0000000000 --- a/railties/lib/rails/generators/rails/app/templates/script/destroy.tt +++ /dev/null @@ -1,3 +0,0 @@ -<%= shebang %> -require File.expand_path('../../config/application', __FILE__) -require 'rails/commands/destroy' diff --git a/railties/lib/rails/generators/rails/app/templates/script/generate.tt b/railties/lib/rails/generators/rails/app/templates/script/generate index 26f029c6a6..6fb8ad0395 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/generate.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/generate @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../config/environment', __FILE__) require 'rails/commands/generate' diff --git a/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt b/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker index 9ebc4c92fc..9647d8f10a 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/performance/benchmarker @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../../config/environment', __FILE__) require 'rails/commands/performance/benchmarker' diff --git a/railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt b/railties/lib/rails/generators/rails/app/templates/script/performance/profiler index 5f4c763f9d..a5822042d2 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/performance/profiler.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/performance/profiler @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../../config/environment', __FILE__) require 'rails/commands/performance/profiler' diff --git a/railties/lib/rails/generators/rails/app/templates/script/plugin.tt b/railties/lib/rails/generators/rails/app/templates/script/plugin index 4a335ee33c..1f1af6c880 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/plugin.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/plugin @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../config/application', __FILE__) require 'rails/commands/plugin' diff --git a/railties/lib/rails/generators/rails/app/templates/script/runner.tt b/railties/lib/rails/generators/rails/app/templates/script/runner index 34ad7c18eb..7a70828e90 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/runner.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/runner @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../config/environment', __FILE__) require 'rails/commands/runner' diff --git a/railties/lib/rails/generators/rails/app/templates/script/server.tt b/railties/lib/rails/generators/rails/app/templates/script/server index 932e72ea58..a7aaee2953 100755 --- a/railties/lib/rails/generators/rails/app/templates/script/server.tt +++ b/railties/lib/rails/generators/rails/app/templates/script/server @@ -1,3 +1,2 @@ -<%= shebang %> require File.expand_path('../../config/application', __FILE__) require 'rails/commands/server' diff --git a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb index 4b60558b43..a3dc38d9e4 100644 --- a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +++ b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb @@ -1,5 +1,5 @@ require 'test_helper' -require 'performance_test_help' +require 'rails/performance_test_help' # Profiling results for each test method are written to tmp/performance. class BrowsingTest < ActionController::PerformanceTest diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 0385581083..99954e2292 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -6,6 +6,8 @@ module Rails # ActiveModel. # module ResourceHelpers + mattr_accessor :skip_warn + def self.included(base) #:nodoc: base.send :attr_reader, :controller_name, :controller_class_name, :controller_file_name, :controller_class_path, :controller_file_path @@ -19,7 +21,11 @@ module Rails super if name == name.pluralize && !options[:force_plural] - say "Plural version of the model detected, using singularized version. Override with --force-plural." + unless ResourceHelpers.skip_warn + say "Plural version of the model detected, using singularized version. Override with --force-plural." + ResourceHelpers.skip_warn = true + end + name.replace name.singularize assign_names!(self.name) end diff --git a/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb b/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb index 27c91b0fca..362e3dc09f 100644 --- a/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb +++ b/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb @@ -1,5 +1,5 @@ require 'test_helper' -require 'performance_test_help' +require 'rails/performance_test_help' class <%= class_name %>Test < ActionController::PerformanceTest # Replace this with your real tests. diff --git a/railties/lib/rails/initializable.rb b/railties/lib/rails/initializable.rb index c491d5e012..d78eab9a75 100644 --- a/railties/lib/rails/initializable.rb +++ b/railties/lib/rails/initializable.rb @@ -1,93 +1,116 @@ module Rails module Initializable - def self.included(klass) - klass.instance_eval do - extend Rails::Initializable - extend Rails::Initializable::ClassMethodsWhenIncluded - include Rails::Initializable::InstanceMethodsWhenIncluded - end + def self.included(base) + base.extend ClassMethods end - def self.extended(klass) - klass.extend Initializer - end + class Initializer + attr_reader :name, :before, :after, :global, :block - class Collection < Array - def initialize(klasses) - klasses.each do |klass| - (klass.added_initializers || []).each do |initializer| - index = if initializer.before - index_for(initializer.before) - elsif initializer.after - index_for(initializer.after) + 1 - else - length - end - - insert(index, initializer) - end - end + def initialize(name, context, options, &block) + @name, @context, @options, @block = name, context, options, block end - def index_for(name) - inst = find {|i| i.name == name } - inst && index(inst) + def before + @options[:before] end - end + def after + @options[:after] + end - attr_reader :added_initializers + def global + @options[:global] + end - # When you include Rails::Initializable, this method will be on instances - # of the class included into. When you extend it, it will be on the - # class or module itself. - # - # The #initializers method is set up to return the right list of - # initializers for the context in question. - def run_initializers - return if @_initialized + alias global? global - initializers.each {|initializer| instance_eval(&initializer.block) } + def run(*args) + @context.instance_exec(*args, &block) + end - @_initialized = true + def bind(context) + return self if @context + Initializer.new(@name, context, @options, &block) + end end - module Initializer - Initializer = Struct.new(:name, :before, :after, :block, :global) - - def all_initializers - klasses = ancestors.select {|klass| klass.is_a?(Initializable) }.reverse - initializers = Collection.new(klasses) + class Collection < Array + def initialize(initializers = []) + super() + initializers.each do |initializer| + if initializer.before + index = index_for(initializer.before) + elsif initializer.after + index = index_for(initializer.after) + 1 + else + index = length + end + insert(index || -1, initializer) + end end - alias initializers all_initializers + def +(other) + Collection.new(to_a + other.to_a) + end - def initializer(name, options = {}, &block) - @added_initializers ||= [] - @added_initializers << - Initializer.new(name, options[:before], options[:after], block, options[:global]) + def index_for(name) + initializer = find { |i| i.name == name } + initializer && index(initializer) end end - module ClassMethodsWhenIncluded - def initializers - all_initializers.select {|i| i.global == true } + def run_initializers(*args) + return if @ran + initializers.each do |initializer| + initializer.run(*args) end + @ran = true + end + def initializers + @initializers ||= begin + initializers = self.class.initializers_for(:instance) + Collection.new(initializers.map { |i| i.bind(self) }) + end end - module InstanceMethodsWhenIncluded + module ClassMethods def initializers - self.class.all_initializers.reject {|i| i.global == true } + @initializers ||= [] + end + + def initializers_for(scope = :global) + initializers = Collection.new + ancestors.reverse_each do |klass| + next unless klass.respond_to?(:initializers) + initializers = initializers + klass.initializers.select { |i| + (scope == :global) == !!i.global? + } + end + initializers + end + + def initializer(name, opts = {}, &blk) + @initializers ||= [] + @initializers << Initializer.new(name, nil, opts, &blk) + end + + def run_initializers(*args) + return if @ran + initializers_for(:global).each do |initializer| + instance_exec(*args, &initializer.block) + end + @ran = true end end end - extend Initializable + include Initializable # Check for valid Ruby version (1.8.2 or 1.8.4 or higher). This is done in an # external file, so we can use it from the `rails` program as well without duplication. - initializer :check_ruby_version do + initializer :check_ruby_version, :global => true do require 'rails/ruby_version_check' end @@ -97,7 +120,7 @@ module Rails # on ActionController::Base. # # For Ruby 1.9, UTF-8 is the default internal and external encoding. - initializer :initialize_encoding do + initializer :initialize_encoding, :global => true do if RUBY_VERSION < '1.9' $KCODE='u' else diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 1c0af6411a..090ec6e4cb 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -18,6 +18,7 @@ module Rails # plugin.about["url"] # => "http://interblah.net" class Plugin include Comparable + include Initializable attr_reader :directory, :name @@ -99,67 +100,69 @@ module Rails def locale_files Dir[ File.join(locale_path, '*.{rb,yml}') ] end - - private - def load_about_information - about_yml_path = File.join(@directory, "about.yml") - parsed_yml = File.exist?(about_yml_path) ? YAML.load(File.read(about_yml_path)) : {} - parsed_yml || {} - rescue Exception - {} - end + private + def load_about_information + about_yml_path = File.join(@directory, "about.yml") + parsed_yml = File.exist?(about_yml_path) ? YAML.load(File.read(about_yml_path)) : {} + parsed_yml || {} + rescue Exception + {} + end - def report_nonexistant_or_empty_plugin! - raise LoadError, "Can not find the plugin named: #{name}" - end + def report_nonexistant_or_empty_plugin! + raise LoadError, "Can not find the plugin named: #{name}" + end - - def app_paths - [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path, metal_path ] - end - - def lib_path - File.join(directory, 'lib') - end + def app_paths + [ File.join(directory, 'app', 'models'), File.join(directory, 'app', 'helpers'), controller_path, metal_path ] + end - def classic_init_path - File.join(directory, 'init.rb') - end + def lib_path + File.join(directory, 'lib') + end - def gem_init_path - File.join(directory, 'rails', 'init.rb') - end + def classic_init_path + File.join(directory, 'init.rb') + end - def init_path - File.file?(gem_init_path) ? gem_init_path : classic_init_path - end + def gem_init_path + File.join(directory, 'rails', 'init.rb') + end + def init_path + File.file?(gem_init_path) ? gem_init_path : classic_init_path + end - def has_app_directory? - File.directory?(File.join(directory, 'app')) - end + def has_app_directory? + File.directory?(File.join(directory, 'app')) + end - def has_lib_directory? - File.directory?(lib_path) - end + def has_lib_directory? + File.directory?(lib_path) + end - def has_init_file? - File.file?(init_path) - end + def has_init_file? + File.file?(init_path) + end + def evaluate_init_rb(initializer) + if has_init_file? + require 'active_support/core_ext/kernel/reporting' + silence_warnings do + # Allow plugins to reference the current configuration object + config = initializer.configuration - def evaluate_init_rb(initializer) - if has_init_file? - require 'active_support/core_ext/kernel/reporting' - silence_warnings do - # Allow plugins to reference the current configuration object - config = initializer.configuration - - eval(IO.read(init_path), binding, init_path) - end + eval(IO.read(init_path), binding, init_path) end - end + end + end + + class Vendored < Plugin + initializer :init_rb do |application| + evaluate_init_rb(application) + end + end end # This Plugin subclass represents a Gem plugin. Although RubyGems has already diff --git a/railties/lib/rails/ruby_version_check.rb b/railties/lib/rails/ruby_version_check.rb index 68d3acc876..62d7804bf3 100644 --- a/railties/lib/rails/ruby_version_check.rb +++ b/railties/lib/rails/ruby_version_check.rb @@ -1,13 +1,6 @@ -min_release = "1.8.2 (2004-12-25)" +min_release = "1.8.7" ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})" -if ruby_release =~ /1\.8\.3/ - abort <<-end_message - - Rails does not work with Ruby version 1.8.3. - Please upgrade to version 1.8.4 or downgrade to 1.8.2. - - end_message -elsif ruby_release < min_release +if ruby_release < min_release abort <<-end_message Rails requires Ruby version #{min_release} or later. diff --git a/railties/lib/rails/vendor/thor-0.11.8/CHANGELOG.rdoc b/railties/lib/rails/vendor/thor-0.12.0/CHANGELOG.rdoc index dba25b7205..adedfeca9d 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/CHANGELOG.rdoc +++ b/railties/lib/rails/vendor/thor-0.12.0/CHANGELOG.rdoc @@ -2,7 +2,12 @@ * Improve spec coverage for Thor::Runner -== 0.11.x, released 2009-07-01 +== 0.12, released 2009-11-06 + +* [#7] Do not force white color on status +* [#8] Yield a block with the filename on directory + +== 0.11, released 2009-07-01 * Added a rake compatibility layer. It allows you to use spec and rdoc tasks on Thor classes. diff --git a/railties/lib/rails/vendor/thor-0.11.8/LICENSE b/railties/lib/rails/vendor/thor-0.12.0/LICENSE index 98722da459..98722da459 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/LICENSE +++ b/railties/lib/rails/vendor/thor-0.12.0/LICENSE diff --git a/railties/lib/rails/vendor/thor-0.11.8/README.rdoc b/railties/lib/rails/vendor/thor-0.12.0/README.rdoc index f1106f02b6..f1106f02b6 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/README.rdoc +++ b/railties/lib/rails/vendor/thor-0.12.0/README.rdoc diff --git a/railties/lib/rails/vendor/thor-0.11.8/Thorfile b/railties/lib/rails/vendor/thor-0.12.0/Thorfile index f71a1e57e2..f71a1e57e2 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/Thorfile +++ b/railties/lib/rails/vendor/thor-0.12.0/Thorfile diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor.rb index 68944f140d..68944f140d 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions.rb index d561ccb2aa..d561ccb2aa 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/create_file.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/create_file.rb index 8f6badee27..a3d9296823 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/create_file.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/create_file.rb @@ -60,6 +60,7 @@ class Thor FileUtils.mkdir_p(File.dirname(destination)) File.open(destination, 'w'){ |f| f.write render } end + given_destination end protected diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/directory.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/directory.rb index 063ac57406..467e63732a 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/directory.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/directory.rb @@ -40,15 +40,16 @@ class Thor # directory "doc" # directory "doc", "docs", :recursive => false # - def directory(source, destination=nil, config={}) - action Directory.new(self, source, destination || source, config) + def directory(source, destination=nil, config={}, &block) + action Directory.new(self, source, destination || source, config, &block) end class Directory < EmptyDirectory #:nodoc: attr_reader :source - def initialize(base, source, destination=nil, config={}) + def initialize(base, source, destination=nil, config={}, &block) @source = File.expand_path(base.find_in_source_paths(source.to_s)) + @block = block super(base, destination, { :recursive => true }.merge(config)) end @@ -70,6 +71,7 @@ class Thor Dir[lookup].each do |file_source| next if File.directory?(file_source) file_destination = File.join(given_destination, file_source.gsub(source, '.')) + file_destination.gsub!('/./', '/') case file_source when /\.empty_directory$/ @@ -77,9 +79,11 @@ class Thor next if dirname == given_destination base.empty_directory(dirname, config) when /\.tt$/ - base.template(file_source, file_destination[0..-4], config) + destination = base.template(file_source, file_destination[0..-4], config) + @block.call(destination) if @block else - base.copy_file(file_source, file_destination, config) + destination = base.copy_file(file_source, file_destination, config) + @block.call(destination) if @block end end end diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/empty_directory.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/empty_directory.rb index 03c1fe4af1..484cb820f8 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/empty_directory.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/empty_directory.rb @@ -55,6 +55,7 @@ class Thor def revoke! say_status :remove, :red ::FileUtils.rm_rf(destination) if !pretend? && exists? + given_destination end protected diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/file_manipulation.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/file_manipulation.rb index d77d90d448..d77d90d448 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/file_manipulation.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/file_manipulation.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/inject_into_file.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/inject_into_file.rb index 0636ec6591..0636ec6591 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/actions/inject_into_file.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/actions/inject_into_file.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/base.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/base.rb index 700d794123..700d794123 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/base.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/base.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/core_ext/hash_with_indifferent_access.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/core_ext/hash_with_indifferent_access.rb index 78bc5cf4bf..78bc5cf4bf 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/core_ext/hash_with_indifferent_access.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/core_ext/hash_with_indifferent_access.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/core_ext/ordered_hash.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/core_ext/ordered_hash.rb index 27fea5bb35..27fea5bb35 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/core_ext/ordered_hash.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/core_ext/ordered_hash.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/error.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/error.rb index f9b31a35d1..f9b31a35d1 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/error.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/error.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/group.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/group.rb index 1e59df2313..0964a9667a 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/group.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/group.rb @@ -74,7 +74,7 @@ class Thor::Group # def invoke(*names, &block) options = names.last.is_a?(Hash) ? names.pop : {} - verbose = options.fetch(:verbose, :white) + verbose = options.fetch(:verbose, true) names.each do |name| invocations[name] = false diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/invocation.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/invocation.rb index 32e6a72454..32e6a72454 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/invocation.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/invocation.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser.rb index 57a3f6e1a5..57a3f6e1a5 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/argument.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/argument.rb index aa8ace4719..aa8ace4719 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/argument.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/argument.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/arguments.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/arguments.rb index fb5d965e06..fb5d965e06 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/arguments.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/arguments.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/option.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/option.rb index 9e40ec73fa..9e40ec73fa 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/option.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/option.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/options.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/options.rb index 75092308b5..75092308b5 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/parser/options.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/parser/options.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/rake_compat.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/rake_compat.rb index 0d0757fdda..0d0757fdda 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/rake_compat.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/rake_compat.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/runner.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/runner.rb index 9dc70ea069..9dc70ea069 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/runner.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/runner.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell.rb index 1dc8f0e5b4..1dc8f0e5b4 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell/basic.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell/basic.rb index ea9665380b..ea9665380b 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell/basic.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell/basic.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell/color.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell/color.rb index 24704f7885..24704f7885 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/shell/color.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/shell/color.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/task.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/task.rb index 91c7564d3f..91c7564d3f 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/task.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/task.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/util.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/util.rb index ebae0a3193..ebae0a3193 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/util.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/util.rb diff --git a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/version.rb b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/version.rb index 885230fac4..885230fac4 100644 --- a/railties/lib/rails/vendor/thor-0.11.8/lib/thor/version.rb +++ b/railties/lib/rails/vendor/thor-0.12.0/lib/thor/version.rb |