aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-08-30 16:16:53 +0200
committerJosé Valim <jose.valim@gmail.com>2009-08-30 16:16:53 +0200
commit72c6ea1022e9819eda667f209660a5cf143b72d3 (patch)
treebf3b8a7b1ae9fb921117f2a47e39bef5aea22387 /railties/lib
parentd8e7ff12a82f4cde563d6d8777e644811929bf50 (diff)
downloadrails-72c6ea1022e9819eda667f209660a5cf143b72d3.tar.gz
rails-72c6ea1022e9819eda667f209660a5cf143b72d3.tar.bz2
rails-72c6ea1022e9819eda667f209660a5cf143b72d3.zip
Update vendored thor.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/generators.rb2
-rw-r--r--railties/lib/vendor/thor-0.11.6/CHANGELOG.rdoc (renamed from railties/lib/vendor/thor-0.11.5/CHANGELOG.rdoc)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/LICENSE (renamed from railties/lib/vendor/thor-0.11.5/LICENSE)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/README.rdoc (renamed from railties/lib/vendor/thor-0.11.5/README.rdoc)0
-rwxr-xr-xrailties/lib/vendor/thor-0.11.6/bin/rake2thor (renamed from railties/lib/vendor/thor-0.11.5/bin/rake2thor)0
-rwxr-xr-xrailties/lib/vendor/thor-0.11.6/bin/thor (renamed from railties/lib/vendor/thor-0.11.5/bin/thor)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/actions.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/actions.rb)31
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/actions/create_file.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/actions/create_file.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/actions/directory.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/actions/directory.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/actions/empty_directory.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/actions/empty_directory.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/actions/file_manipulation.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/actions/file_manipulation.rb)58
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/actions/inject_into_file.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/actions/inject_into_file.rb)63
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/base.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/base.rb)7
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/core_ext/hash_with_indifferent_access.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/hash_with_indifferent_access.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/core_ext/ordered_hash.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/ordered_hash.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/error.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/error.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/group.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/group.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/invocation.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/invocation.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/parser.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/parser.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/parser/argument.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/parser/argument.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/parser/arguments.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/parser/arguments.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/parser/option.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/parser/option.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/parser/options.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/parser/options.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/rake_compat.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/runner.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/runner.rb)4
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/shell.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/shell.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/shell/basic.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/shell/basic.rb)5
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/shell/color.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/shell/color.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/task.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/task.rb)20
-rw-r--r--railties/lib/vendor/thor-0.11.6/lib/thor/util.rb (renamed from railties/lib/vendor/thor-0.11.5/lib/thor/util.rb)17
31 files changed, 138 insertions, 73 deletions
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb
index a2f462ae81..5c03787aee 100644
--- a/railties/lib/generators.rb
+++ b/railties/lib/generators.rb
@@ -11,7 +11,7 @@ end
$:.unshift(File.dirname(__FILE__))
-require 'vendor/thor-0.11.5/lib/thor'
+require 'vendor/thor-0.11.6/lib/thor'
require 'generators/base'
require 'generators/named_base'
diff --git a/railties/lib/vendor/thor-0.11.5/CHANGELOG.rdoc b/railties/lib/vendor/thor-0.11.6/CHANGELOG.rdoc
index dba25b7205..dba25b7205 100644
--- a/railties/lib/vendor/thor-0.11.5/CHANGELOG.rdoc
+++ b/railties/lib/vendor/thor-0.11.6/CHANGELOG.rdoc
diff --git a/railties/lib/vendor/thor-0.11.5/LICENSE b/railties/lib/vendor/thor-0.11.6/LICENSE
index 98722da459..98722da459 100644
--- a/railties/lib/vendor/thor-0.11.5/LICENSE
+++ b/railties/lib/vendor/thor-0.11.6/LICENSE
diff --git a/railties/lib/vendor/thor-0.11.5/README.rdoc b/railties/lib/vendor/thor-0.11.6/README.rdoc
index f1106f02b6..f1106f02b6 100644
--- a/railties/lib/vendor/thor-0.11.5/README.rdoc
+++ b/railties/lib/vendor/thor-0.11.6/README.rdoc
diff --git a/railties/lib/vendor/thor-0.11.5/bin/rake2thor b/railties/lib/vendor/thor-0.11.6/bin/rake2thor
index 50c7410d80..50c7410d80 100755
--- a/railties/lib/vendor/thor-0.11.5/bin/rake2thor
+++ b/railties/lib/vendor/thor-0.11.6/bin/rake2thor
diff --git a/railties/lib/vendor/thor-0.11.5/bin/thor b/railties/lib/vendor/thor-0.11.6/bin/thor
index eaf849fb4a..eaf849fb4a 100755
--- a/railties/lib/vendor/thor-0.11.5/bin/thor
+++ b/railties/lib/vendor/thor-0.11.6/bin/thor
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor.rb b/railties/lib/vendor/thor-0.11.6/lib/thor.rb
index 8dfcfd4c5b..3b45c4e9b7 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor.rb
@@ -135,7 +135,7 @@ class Thor
args, opts = given_args, {}
end
- task ||= Task.dynamic(meth)
+ task ||= Thor::Task::Dynamic.new(meth)
trailing = args[Range.new(arguments.size, -1)]
new(args, opts, config).invoke(task, trailing || [])
end
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/actions.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/actions.rb
index 1d09dc38ae..d561ccb2aa 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/actions.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/actions.rb
@@ -8,23 +8,8 @@ class Thor
module Actions
attr_accessor :behavior
- # On inclusion, add some options to base.
- #
def self.included(base) #:nodoc:
base.extend ClassMethods
- return unless base.respond_to?(:class_option)
-
- base.class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
- :desc => "Run but do not make any changes"
-
- base.class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
- :desc => "Overwrite files that already exist"
-
- base.class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
- :desc => "Skip files that already exist"
-
- base.class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
- :desc => "Supress status output"
end
module ClassMethods
@@ -49,6 +34,22 @@ class Thor
paths += from_superclass(:source_paths, [])
paths
end
+
+ # Add runtime options that help actions execution.
+ #
+ def add_runtime_options!
+ class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
+ :desc => "Run but do not make any changes"
+
+ class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
+ :desc => "Overwrite files that already exist"
+
+ class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
+ :desc => "Skip files that already exist"
+
+ class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
+ :desc => "Supress status output"
+ end
end
# Extends initializer to add more configuration options.
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/create_file.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/create_file.rb
index 8f6badee27..8f6badee27 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/create_file.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/create_file.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/directory.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/directory.rb
index be5eb822ac..be5eb822ac 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/directory.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/directory.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/empty_directory.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/empty_directory.rb
index 03c1fe4af1..03c1fe4af1 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/empty_directory.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/empty_directory.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/file_manipulation.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/file_manipulation.rb
index 74c157ba8c..d77d90d448 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/file_manipulation.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/file_manipulation.rb
@@ -100,7 +100,7 @@ class Thor
FileUtils.chmod_R(mode, path) unless options[:pretend]
end
- # Prepend text to a file.
+ # Prepend text to a file. Since it depends on inject_into_file, it's reversible.
#
# ==== Parameters
# path<String>:: path of the file to be changed
@@ -111,19 +111,17 @@ class Thor
#
# prepend_file 'config/environments/test.rb', 'config.gem "rspec"'
#
- def prepend_file(path, data=nil, config={}, &block)
- return unless behavior == :invoke
- path = File.expand_path(path, destination_root)
- say_status :prepend, relative_to_original_destination_root(path), config.fetch(:verbose, true)
-
- unless options[:pretend]
- content = data || block.call
- content << File.read(path)
- File.open(path, 'wb') { |file| file.write(content) }
- end
+ # prepend_file 'config/environments/test.rb' do
+ # 'config.gem "rspec"'
+ # end
+ #
+ def prepend_file(path, *args, &block)
+ config = args.last.is_a?(Hash) ? args.pop : {}
+ config.merge!(:after => /\A/)
+ inject_into_file(path, *(args << config), &block)
end
- # Append text to a file.
+ # Append text to a file. Since it depends on inject_into_file, it's reversible.
#
# ==== Parameters
# path<String>:: path of the file to be changed
@@ -134,11 +132,37 @@ class Thor
#
# append_file 'config/environments/test.rb', 'config.gem "rspec"'
#
- def append_file(path, data=nil, config={}, &block)
- return unless behavior == :invoke
- path = File.expand_path(path, destination_root)
- say_status :append, relative_to_original_destination_root(path), config.fetch(:verbose, true)
- File.open(path, 'ab') { |file| file.write(data || block.call) } unless options[:pretend]
+ # append_file 'config/environments/test.rb' do
+ # 'config.gem "rspec"'
+ # end
+ #
+ def append_file(path, *args, &block)
+ config = args.last.is_a?(Hash) ? args.pop : {}
+ config.merge!(:before => /\z/)
+ inject_into_file(path, *(args << config), &block)
+ end
+
+ # Injects text right after the class definition. Since it depends on
+ # inject_into_file, it's reversible.
+ #
+ # ==== Parameters
+ # path<String>:: path of the file to be changed
+ # klass<String|Class>:: the class to be manipulated
+ # data<String>:: the data to append to the class, can be also given as a block.
+ # config<Hash>:: give :verbose => false to not log the status.
+ #
+ # ==== Examples
+ #
+ # inject_into_class "app/controllers/application_controller.rb", " filter_parameter :password\n"
+ #
+ # inject_into_class "app/controllers/application_controller.rb", ApplicationController do
+ # " filter_parameter :password\n"
+ # end
+ #
+ def inject_into_class(path, klass, *args, &block)
+ config = args.last.is_a?(Hash) ? args.pop : {}
+ config.merge!(:after => /class #{klass}\n|class #{klass} .*\n/)
+ inject_into_file(path, *(args << config), &block)
end
# Run a regular expression replacement on a file.
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/inject_into_file.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/inject_into_file.rb
index 66dd1f5fc1..0636ec6591 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/actions/inject_into_file.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/actions/inject_into_file.rb
@@ -3,10 +3,8 @@ require 'thor/actions/empty_directory'
class Thor
module Actions
- # Injects the given content into a file. Different from append_file,
- # prepend_file and gsub_file, this method is reversible. By this reason,
- # the flag can only be strings. gsub_file is your friend if you need to
- # deal with more complex cases.
+ # Injects the given content into a file. Different from gsub_file, this
+ # method is reversible.
#
# ==== Parameters
# destination<String>:: Relative path to the destination root
@@ -16,11 +14,11 @@ class Thor
#
# ==== Examples
#
- # inject_into_file "config/environment.rb", "config.gem thor", :after => "Rails::Initializer.run do |config|\n"
+ # inject_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
#
# inject_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do
# gems = ask "Which gems would you like to add?"
- # gems.split(" ").map{ |gem| " config.gem #{gem}" }.join("\n")
+ # gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
def inject_into_file(destination, *args, &block)
@@ -29,40 +27,65 @@ class Thor
else
data, config = args.shift, args.shift
end
-
- log_status = args.empty? || args.pop
action InjectIntoFile.new(self, destination, data, config)
end
class InjectIntoFile < EmptyDirectory #:nodoc:
- attr_reader :flag, :replacement
+ attr_reader :replacement, :flag, :behavior
def initialize(base, destination, data, config)
super(base, destination, { :verbose => true }.merge(config))
- data = data.call if data.is_a?(Proc)
-
- @replacement = if @config.key?(:after)
- @flag = @config.delete(:after)
- @flag + data
+ @behavior, @flag = if @config.key?(:after)
+ [:after, @config.delete(:after)]
else
- @flag = @config.delete(:before)
- data + @flag
+ [:before, @config.delete(:before)]
end
+
+ @replacement = data.is_a?(Proc) ? data.call : data
+ @flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)
end
def invoke!
- say_status :inject, config[:verbose]
- replace!(flag, replacement)
+ say_status :invoke
+
+ content = if @behavior == :after
+ '\0' + replacement
+ else
+ replacement + '\0'
+ end
+
+ replace!(/#{flag}/, content)
end
def revoke!
- say_status :deinject, config[:verbose]
- replace!(replacement, flag)
+ say_status :revoke
+
+ regexp = if @behavior == :after
+ content = '\1\2'
+ /(#{flag})(.*)(#{Regexp.escape(replacement)})/m
+ else
+ content = '\2\3'
+ /(#{Regexp.escape(replacement)})(.*)(#{flag})/m
+ end
+
+ replace!(regexp, content)
end
protected
+ def say_status(behavior)
+ status = if flag == /\A/
+ behavior == :invoke ? :prepend : :unprepend
+ elsif flag == /\z/
+ behavior == :invoke ? :append : :unappend
+ else
+ behavior == :invoke ? :inject : :deinject
+ end
+
+ super(status, config[:verbose])
+ end
+
# Adds the content to the file.
#
def replace!(regexp, string)
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/base.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/base.rb
index 0fa87f8162..700d794123 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/base.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/base.rb
@@ -355,6 +355,7 @@ class Thor
else
config[:shell].error e.message
end
+ exit(1) if exit_on_failure?
end
protected
@@ -491,6 +492,12 @@ class Thor
end
end
+ # A flag that makes the process exit with status 1 if any error happens.
+ #
+ def exit_on_failure?
+ false
+ end
+
# SIGNATURE: Sets the baseclass. This is where the superclass lookup
# finishes.
def baseclass #:nodoc:
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/hash_with_indifferent_access.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/core_ext/hash_with_indifferent_access.rb
index 78bc5cf4bf..78bc5cf4bf 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/core_ext/hash_with_indifferent_access.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/ordered_hash.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/core_ext/ordered_hash.rb
index 27fea5bb35..27fea5bb35 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/ordered_hash.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/core_ext/ordered_hash.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/error.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/error.rb
index f9b31a35d1..f9b31a35d1 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/error.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/error.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/group.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/group.rb
index 1e59df2313..1e59df2313 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/group.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/group.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/invocation.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/invocation.rb
index c0388dd863..32e6a72454 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/invocation.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/invocation.rb
@@ -153,7 +153,7 @@ class Thor
raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base
task ||= klass.default_task if klass <= Thor
- task = klass.all_tasks[task.to_s] || Task.dynamic(task) if task && !task.is_a?(Thor::Task)
+ task = klass.all_tasks[task.to_s] || Thor::Task::Dynamic.new(task) if task && !task.is_a?(Thor::Task)
task
end
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/parser.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/parser.rb
index 57a3f6e1a5..57a3f6e1a5 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/parser.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/parser.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/argument.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/argument.rb
index aa8ace4719..aa8ace4719 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/argument.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/argument.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/arguments.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/arguments.rb
index fb5d965e06..fb5d965e06 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/arguments.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/arguments.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/option.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/option.rb
index 9e40ec73fa..9e40ec73fa 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/option.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/option.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/options.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/options.rb
index 75092308b5..75092308b5 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/parser/options.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/parser/options.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/rake_compat.rb
index 3ab6bb21f5..3ab6bb21f5 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/rake_compat.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/runner.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/runner.rb
index 3639ac0aa9..43da09b336 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/runner.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/runner.rb
@@ -175,6 +175,10 @@ class Thor::Runner < Thor #:nodoc:
File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
end
+ def self.exit_on_failure?
+ true
+ end
+
# Load the thorfiles. If relevant_to is supplied, looks for specific files
# in the thor_root instead of loading them all.
#
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/shell.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/shell.rb
index 0d3f4d5951..0d3f4d5951 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/shell.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/shell.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/shell/basic.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/shell/basic.rb
index 3c02e47c33..ea9665380b 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/shell/basic.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/shell/basic.rb
@@ -34,12 +34,11 @@ class Thor
# ==== Example
# say("I know you knew that.")
#
- def say(message="", color=nil, force_new_line=false)
+ def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/))
message = message.to_s
- new_line = force_new_line || !(message[-1, 1] == " " || message[-1, 1] == "\t")
message = set_color(message, color) if color
- if new_line
+ if force_new_line
$stdout.puts(message)
else
$stdout.print(message)
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/shell/color.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/shell/color.rb
index 24704f7885..24704f7885 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/shell/color.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/shell/color.rb
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/task.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/task.rb
index 23d35b883c..91c7564d3f 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/task.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/task.rb
@@ -1,11 +1,19 @@
class Thor
class Task < Struct.new(:name, :description, :usage, :options)
- # Creates a dynamic task. Dynamic tasks are created on demand to allow method
- # missing calls (since a method missing does not have a task object for it).
+ # A dynamic task that handles method missing scenarios.
#
- def self.dynamic(name)
- new(name, "A dynamically-generated task", name.to_s)
+ class Dynamic < Task
+ def initialize(name)
+ super(name.to_s, "A dynamically-generated task", name.to_s)
+ end
+
+ def run(instance, args=[])
+ unless (instance.methods & [name.to_s, name.to_sym]).empty?
+ raise Error, "could not find Thor class or task '#{name}'"
+ end
+ super
+ end
end
def initialize(name, description, usage, options=nil)
@@ -37,8 +45,6 @@ class Thor
# injected in the usage.
#
def formatted_usage(klass=nil, namespace=false, show_options=true)
- formatted = ''
-
formatted = if namespace.is_a?(String)
"#{namespace}:"
elsif klass && namespace
@@ -77,7 +83,7 @@ class Thor
#
def public_method?(instance) #:nodoc:
collection = instance.private_methods + instance.protected_methods
- !(collection).include?(name.to_s) && !(collection).include?(name.to_sym) # For Ruby 1.9
+ (collection & [name.to_s, name.to_sym]).empty?
end
# Clean everything that comes from the Thor gempath and remove the caller.
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/util.rb b/railties/lib/vendor/thor-0.11.6/lib/thor/util.rb
index 4938dc4aca..fd820d7462 100644
--- a/railties/lib/vendor/thor-0.11.5/lib/thor/util.rb
+++ b/railties/lib/vendor/thor-0.11.6/lib/thor/util.rb
@@ -22,7 +22,7 @@ class Thor
# namespace<String>:: The namespace to search for.
#
def self.find_by_namespace(namespace)
- namespace = 'default' if namespace.empty?
+ namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
Thor::Base.subclasses.find do |klass|
klass.namespace == namespace
@@ -137,17 +137,18 @@ class Thor
# inherit from Thor or Thor::Group.
#
def self.namespace_to_thor_class_and_task(namespace, raise_if_nil=true)
- klass, task_name = Thor::Util.find_by_namespace(namespace), nil
+ if namespace.include?(?:)
+ pieces = namespace.split(":")
+ task = pieces.pop
+ klass = Thor::Util.find_by_namespace(pieces.join(":"))
+ end
- if klass.nil? && namespace.include?(?:)
- namespace = namespace.split(":")
- task_name = namespace.pop
- klass = Thor::Util.find_by_namespace(namespace.join(":"))
+ unless klass
+ klass, task = Thor::Util.find_by_namespace(namespace), nil
end
raise Error, "could not find Thor class or task '#{namespace}'" if raise_if_nil && klass.nil?
-
- return klass, task_name
+ return klass, task
end
# Receives a path and load the thor file in the path. The file is evaluated