aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--railties/lib/generators.rb2
-rw-r--r--railties/lib/vendor/thor-0.11.3/lib/thor/error.rb27
-rw-r--r--railties/lib/vendor/thor-0.11.3/lib/thor/tasks.rb4
-rw-r--r--railties/lib/vendor/thor-0.11.3/lib/thor/tasks/install.rb35
-rw-r--r--railties/lib/vendor/thor-0.11.3/lib/thor/tasks/package.rb31
-rw-r--r--railties/lib/vendor/thor-0.11.3/lib/thor/tasks/spec.rb70
-rw-r--r--railties/lib/vendor/thor-0.11.5/CHANGELOG.rdoc (renamed from railties/lib/vendor/thor-0.11.3/CHANGELOG.rdoc)6
-rw-r--r--railties/lib/vendor/thor-0.11.5/LICENSE (renamed from railties/lib/vendor/thor-0.11.3/LICENSE)0
-rw-r--r--railties/lib/vendor/thor-0.11.5/README.rdoc (renamed from railties/lib/vendor/thor-0.11.3/README.markdown)75
-rwxr-xr-xrailties/lib/vendor/thor-0.11.5/bin/rake2thor (renamed from railties/lib/vendor/thor-0.11.3/bin/rake2thor)0
-rwxr-xr-xrailties/lib/vendor/thor-0.11.5/bin/thor (renamed from railties/lib/vendor/thor-0.11.3/bin/thor)0
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor.rb)39
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/actions.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/actions.rb)30
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/actions/create_file.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/actions/create_file.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/actions/directory.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/actions/directory.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/actions/empty_directory.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/actions/empty_directory.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/actions/file_manipulation.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/actions/file_manipulation.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/actions/inject_into_file.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/actions/inject_into_file.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/base.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/base.rb)42
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/hash_with_indifferent_access.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/core_ext/hash_with_indifferent_access.rb)4
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/ordered_hash.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/core_ext/ordered_hash.rb)4
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/error.rb27
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/group.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/group.rb)6
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/invocation.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/invocation.rb)42
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/parser.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/parser.rb)0
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/parser/argument.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/parser/argument.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/parser/arguments.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/parser/arguments.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/parser/option.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/parser/option.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/parser/options.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/parser/options.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb67
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/runner.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/runner.rb)22
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/shell.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/shell.rb)2
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/shell/basic.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/shell/basic.rb)38
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/shell/color.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/shell/color.rb)16
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/task.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/task.rb)24
-rw-r--r--railties/lib/vendor/thor-0.11.5/lib/thor/util.rb (renamed from railties/lib/vendor/thor-0.11.3/lib/thor/util.rb)41
36 files changed, 312 insertions, 354 deletions
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb
index 64ec808ee4..ef837e1488 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.3/lib/thor'
+require 'vendor/thor-0.11.5/lib/thor'
require 'generators/base'
require 'generators/named_base'
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/error.rb b/railties/lib/vendor/thor-0.11.3/lib/thor/error.rb
deleted file mode 100644
index c846e9ce74..0000000000
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/error.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-class Thor
- # Thor::Error is raised when it's caused by the user invoking the task and
- # only errors that inherit from it are rescued.
- #
- # So, for example, if the developer declares a required argument after an
- # option, it should raise an ::ArgumentError and not ::Thor::ArgumentError,
- # because it was caused by the developer and not the "final user".
- #
- class Error < StandardError #:nodoc:
- end
-
- # Raised when a task was not found.
- #
- class UndefinedTaskError < Error #:nodoc:
- end
-
- # Raised when a task was found, but not invoked properly.
- #
- class InvocationError < Error #:nodoc:
- end
-
- class RequiredArgumentMissingError < InvocationError #:nodoc:
- end
-
- class MalformattedArgumentError < InvocationError #:nodoc:
- end
-end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks.rb b/railties/lib/vendor/thor-0.11.3/lib/thor/tasks.rb
deleted file mode 100644
index d1a7b1c673..0000000000
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# This only loads all tasks inside tasks.
-Dir[File.join(File.dirname(__FILE__), "tasks", "*.rb")].each do |task|
- require task
-end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/install.rb b/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/install.rb
deleted file mode 100644
index 6b20ff1634..0000000000
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/install.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-class Thor
- # Creates an install task.
- #
- # ==== Parameters
- # spec<Gem::Specification>
- #
- # ==== Options
- # :dir - The directory where the package is hold before installation. Defaults to ./pkg.
- #
- def self.install_task(spec, options={})
- package_task(spec, options)
- tasks['install'] = Thor::InstallTask.new(spec, options)
- end
-
- class InstallTask < Task
- attr_accessor :spec, :config
-
- def initialize(gemspec, config={})
- super(:install, "Install the gem", "install", {})
- @spec = gemspec
- @config = { :dir => File.join(Dir.pwd, "pkg") }.merge(config)
- end
-
- def run(instance, args=[])
- null, sudo, gem = RUBY_PLATFORM =~ /mswin|mingw/ ? ['NUL', '', 'gem.bat'] :
- ['/dev/null', 'sudo', 'gem']
-
- old_stderr, $stderr = $stderr.dup, File.open(null, "w")
- instance.invoke(:package)
- $stderr = old_stderr
-
- system %{#{sudo} #{Gem.ruby} -S #{gem} install #{config[:dir]}/#{spec.name}-#{spec.version} --no-rdoc --no-ri --no-update-sources}
- end
- end
-end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/package.rb b/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/package.rb
deleted file mode 100644
index 603d61b4ab..0000000000
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/package.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-require "fileutils"
-
-class Thor
- # Creates a package task.
- #
- # ==== Parameters
- # spec<Gem::Specification>
- #
- # ==== Options
- # :dir - The package directory. Defaults to ./pkg.
- #
- def self.package_task(spec, options={})
- tasks['package'] = Thor::PackageTask.new(spec, options)
- end
-
- class PackageTask < Task
- attr_accessor :spec, :config
-
- def initialize(gemspec, config={})
- super(:package, "Build a gem package", "package", {})
- @spec = gemspec
- @config = {:dir => File.join(Dir.pwd, "pkg")}.merge(config)
- end
-
- def run(instance, args=[])
- FileUtils.mkdir_p(config[:dir])
- Gem::Builder.new(spec).build
- FileUtils.mv(spec.file_name, File.join(config[:dir], spec.file_name))
- end
- end
-end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/spec.rb b/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/spec.rb
deleted file mode 100644
index c7d00968e8..0000000000
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/tasks/spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-require "fileutils"
-
-class Thor
- # Creates a spec task.
- #
- # ==== Parameters
- # files<Array> - Array of files to spec
- #
- # ==== Options
- # :name - The name of the task. It can be rcov or spec. Spec is the default.
- # :rcov - A hash with rcov specific options.
- # :rcov_dir - Where rcov reports should be printed.
- # :verbose - Sets the default value for verbose, although it can be specified
- # also through the command line.
- #
- # All other options are added to rspec.
- #
- def self.spec_task(files, options={})
- name = (options.delete(:name) || 'spec').to_s
- tasks[name] = Thor::SpecTask.new(name, files, options)
- end
-
- class SpecTask < Task
- attr_accessor :name, :files, :rcov_dir, :rcov_config, :spec_config
-
- def initialize(name, files, config={})
- options = { :verbose => Thor::Option.parse(:verbose, config.delete(:verbose) || false) }
- super(name, "#{name.capitalize} task", name, options)
-
- @name = name
- @files = files.map{ |f| %["#{f}"] }.join(" ")
- @rcov_dir = config.delete(:rdoc_dir) || File.join(Dir.pwd, 'coverage')
- @rcov_config = config.delete(:rcov) || {}
- @spec_config = { :format => 'specdoc', :color => true }.merge(config)
- end
-
- def run(instance, args=[])
- rcov_opts = Thor::Options.to_switches(rcov_config)
- spec_opts = Thor::Options.to_switches(spec_config)
-
- require 'rbconfig'
- cmd = RbConfig::CONFIG['ruby_install_name'] << " "
-
- if rcov?
- FileUtils.rm_rf(rcov_dir)
- cmd << "-S #{where('rcov')} -o #{rcov_dir} #{rcov_opts} "
- end
-
- cmd << [where('spec'), rcov? ? " -- " : nil, files, spec_opts].join(" ")
-
- puts cmd if instance.options.verbose?
- system(cmd)
- exit($?.exitstatus)
- end
-
- private
-
- def rcov?
- name == "rcov"
- end
-
- def where(file)
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
- file_with_path = File.join(path, file)
- next unless File.exist?(file_with_path) && File.executable?(file_with_path)
- return File.expand_path(file_with_path)
- end
- end
- end
-end
diff --git a/railties/lib/vendor/thor-0.11.3/CHANGELOG.rdoc b/railties/lib/vendor/thor-0.11.5/CHANGELOG.rdoc
index 544dde8c02..dba25b7205 100644
--- a/railties/lib/vendor/thor-0.11.3/CHANGELOG.rdoc
+++ b/railties/lib/vendor/thor-0.11.5/CHANGELOG.rdoc
@@ -1,9 +1,11 @@
== TODO
* Improve spec coverage for Thor::Runner
-* Improve help output to list shorthand switches, too
-== Current
+== 0.11.x, released 2009-07-01
+
+* Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
+ Thor classes.
* BACKWARDS INCOMPATIBLE: aliases are not generated automatically anymore
since it wrong behavior to the invocation system.
diff --git a/railties/lib/vendor/thor-0.11.3/LICENSE b/railties/lib/vendor/thor-0.11.5/LICENSE
index 98722da459..98722da459 100644
--- a/railties/lib/vendor/thor-0.11.3/LICENSE
+++ b/railties/lib/vendor/thor-0.11.5/LICENSE
diff --git a/railties/lib/vendor/thor-0.11.3/README.markdown b/railties/lib/vendor/thor-0.11.5/README.rdoc
index a1d7259775..f1106f02b6 100644
--- a/railties/lib/vendor/thor-0.11.3/README.markdown
+++ b/railties/lib/vendor/thor-0.11.5/README.rdoc
@@ -1,5 +1,4 @@
-thor
-====
+= thor
Map options to a class. Simply create a class with the appropriate annotations
and have options automatically map to functions and parameters.
@@ -34,26 +33,18 @@ That gets converted to:
App.new.install("myname")
# with {'force' => true} as options hash
-1. Inherit from Thor to turn a class into an option mapper
-2. Map additional non-valid identifiers to specific methods. In this case, convert -L to :list
-3. Describe the method immediately below. The first parameter is the usage information, and the second parameter is the description
-4. Provide any additional options that will be available the instance method options.
-
-Types for `method_options`
---------------------------
-
-<dl>
- <dt><code>:boolean</code></dt>
- <dd>is parsed as --option or --option=true</dd>
- <dt><code>:string</code></dt>
- <dd>is parsed as --option=VALUE</dd>
- <dt><code>:numeric</code></dt>
- <dd>is parsed as --option=N</dd>
- <dt><code>:array</code></dt>
- <dd>is parsed as --option=one two three</dd>
- <dt><code>:hash</code></dt>
- <dd>is parsed as --option=key:value key:value key:value</dd>
-</dl>
+1. Inherit from Thor to turn a class into an option mapper
+2. Map additional non-valid identifiers to specific methods. In this case, convert -L to :list
+3. Describe the method immediately below. The first parameter is the usage information, and the second parameter is the description
+4. Provide any additional options that will be available the instance method options.
+
+== Types for <tt>method_options</tt>
+
+* :boolean - is parsed as <tt>--option</tt> or <tt>--option=true</tt>
+* :string - is parsed as <tt>--option=VALUE</tt>
+* :numeric - is parsed as <tt>--option=N</tt>
+* :array - is parsed as <tt>--option=one two three</tt>
+* :hash - is parsed as <tt>--option=name:string age:integer</tt>
Besides, method_option allows a default value to be given, examples:
@@ -66,9 +57,9 @@ Besides, method_option allows a default value to be given, examples:
method_options :threshold => 3.0
#=> Creates a numeric option with default value 3.0
-You can also supply :option => :required to mark an option as required. The
+You can also supply <tt>:option => :required</tt> to mark an option as required. The
type is assumed to be string. If you want a required hash with default values
-as option, you can use `method_option` which uses a more declarative style:
+as option, you can use <tt>method_option</tt> which uses a more declarative style:
method_option :attributes, :type => :hash, :default => {}, :required => true
@@ -91,8 +82,7 @@ You can supply as many aliases as you want.
NOTE: Type :optional available in Thor 0.9.0 was deprecated. Use :string or :boolean instead.
-Namespaces
-----------
+== Namespaces
By default, your Thor tasks are invoked using Ruby namespace. In the example
above, tasks are invoked as:
@@ -124,8 +114,7 @@ And then your tasks hould be invoked as:
thor myapp:install name --force
-Invocations
------------
+== Invocations
Thor comes with a invocation-dependency system as well which allows a task to be
invoked only once. For example:
@@ -158,8 +147,7 @@ The output is "1 2 3", which means that the three task was invoked only once.
You can even invoke tasks from another class, so be sure to check the
documentation.
-Thor::Group
------------
+== Thor::Group
Thor has a special class called Thor::Group. The main difference to Thor class
is that it invokes all tasks at once. The example above could be rewritten in
@@ -185,10 +173,10 @@ When invoked:
thor counter
-It prints "1 2 3" as well. Notice you should described (desc) only the class
-and not each task anymore. Thor::Group is a great tool to create generators,
-since you can define several steps which are invoked in the order they are
-defined (Thor::Group is the tool use in generators in Rails 3.0).
+It prints "1 2 3" as well. Notice you should describe (using the method <tt>desc</tt>)
+only the class and not each task anymore. Thor::Group is a great tool to create
+generators, since you can define several steps which are invoked in the order they
+are defined (Thor::Group is the tool use in generators in Rails 3.0).
Besides, Thor::Group can parse arguments and options as Thor tasks:
@@ -218,17 +206,17 @@ The counter above expects one parameter and has the folling outputs:
thor counter 11
# Prints "11 12 13"
-You can also give options to Thor::Group, but instead of using `method_option` and
-`method_options`, you should use `class_option` and `class_options`. Both argument
-and class_options methods are available to Thor class as well.
+You can also give options to Thor::Group, but instead of using <tt>method_option</tt>
+and <tt>method_options</tt>, you should use <tt>class_option</tt> and <tt>class_options</tt>.
+Both argument and class_options methods are available to Thor class as well.
-Actions
--------
+== Actions
Thor comes with several actions which helps with script and generator tasks. You
-might be familiar with them since some came from Rails Templates. They are: `say`,
-`ask`, `yes?`, `no?`, `add_file`, `remove_file`, `copy_file`, `template`,
-`directory`, `inside`, `run`, `inject_into_file` and a couple more.
+might be familiar with them since some came from Rails Templates. They are:
+<tt>say</tt>, <tt>ask</tt>, <tt>yes?</tt>, <tt>no?</tt>, <tt>add_file</tt>,
+<tt>remove_file</tt>, <tt>copy_file</tt>, <tt>template</tt>, <tt>directory</tt>,
+<tt>inside</tt>, <tt>run</tt>, <tt>inject_into_file</tt> and a couple more.
To use them, you just need to include Thor::Actions in your Thor classes:
@@ -241,7 +229,6 @@ Some actions like copy file requires that a class method called source_root is
defined in your class. This is the directory where your templates should be
placed. Be sure to check the documentation.
-License
--------
+== License
See MIT LICENSE.
diff --git a/railties/lib/vendor/thor-0.11.3/bin/rake2thor b/railties/lib/vendor/thor-0.11.5/bin/rake2thor
index 50c7410d80..50c7410d80 100755
--- a/railties/lib/vendor/thor-0.11.3/bin/rake2thor
+++ b/railties/lib/vendor/thor-0.11.5/bin/rake2thor
diff --git a/railties/lib/vendor/thor-0.11.3/bin/thor b/railties/lib/vendor/thor-0.11.5/bin/thor
index eaf849fb4a..eaf849fb4a 100755
--- a/railties/lib/vendor/thor-0.11.3/bin/thor
+++ b/railties/lib/vendor/thor-0.11.5/bin/thor
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor.rb b/railties/lib/vendor/thor-0.11.5/lib/thor.rb
index f65455cdda..8dfcfd4c5b 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor.rb
@@ -101,8 +101,7 @@ class Thor
# :required - If the argument is required or not.
# :default - Default value for this argument. It cannot be required and have default values.
# :aliases - Aliases for this option.
- # :type - The type of the argument, can be :string, :hash, :array, :numeric, :boolean or :default.
- # Default accepts arguments as booleans (--switch) or as strings (--switch=VALUE).
+ # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
# :group - The group for this options. Use by class options to output options in different levels.
# :banner - String to show on usage notes.
#
@@ -160,39 +159,43 @@ class Thor
raise UndefinedTaskError, "task '#{meth}' could not be found in namespace '#{self.namespace}'" unless task
shell.say "Usage:"
- shell.say " #{banner(task, options[:namespace])}"
+ shell.say " #{banner(task, options[:namespace], false)}"
shell.say
- class_options_help(shell, "Class")
+ class_options_help(shell, "Class", :Method => task.options.map { |_, o| o })
shell.say task.description
else
list = (options[:short] ? tasks : all_tasks).map do |_, task|
- item = [ " " + banner(task, options[:namespace]) ]
- item << if task.short_description
- "\n # #{task.short_description}\n"
- else
- "\n"
- end
+ item = [ banner(task, options[:namespace]) ]
+ item << "# #{task.short_description}" if task.short_description
+ item << " "
end
+ options[:ident] ||= 2
if options[:short]
- shell.print_table(list)
+ shell.print_list(list, :ident => options[:ident])
else
shell.say "Tasks:"
- shell.print_table(list)
- class_options_help(shell, "Class")
+ shell.print_list(list, :ident => options[:ident])
end
+
+ Thor::Util.thor_classes_in(self).each do |subclass|
+ namespace = options[:namespace] == true || subclass.namespace.gsub(/^#{self.namespace}:/, '')
+ subclass.help(shell, options.merge(:short => true, :namespace => namespace))
+ end
+
+ class_options_help(shell, "Class") unless options[:short]
end
end
protected
# The banner for this class. You can customize it if you are invoking the
- # thor class by another means which is not the Thor::Runner. It receives
- # the task that is going to be invoked and if the namespace should be
- # displayed.
+ # thor class by another ways which is not the Thor::Runner. It receives
+ # the task that is going to be invoked and a boolean which indicates if
+ # the namespace should be displayed as arguments.
#
- def banner(task, namespace=true) #:nodoc:
- task.formatted_usage(self, namespace)
+ def banner(task, namespace=true, show_options=true)
+ task.formatted_usage(self, namespace, show_options)
end
def baseclass #:nodoc:
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/actions.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/actions.rb
index b8cfde1940..1d09dc38ae 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/actions.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/actions.rb
@@ -43,13 +43,11 @@ class Thor
# 3) Parents source paths
#
def source_paths_for_search
- @source_paths_for_search ||= begin
- paths = []
- paths += self.source_paths
- paths << self.source_root if self.respond_to?(:source_root)
- paths += from_superclass(:source_paths, [])
- paths
- end
+ paths = []
+ paths += self.source_paths
+ paths << self.source_root if self.respond_to?(:source_root)
+ paths += from_superclass(:source_paths, [])
+ paths
end
end
@@ -60,8 +58,7 @@ class Thor
# It also accepts :force, :skip and :pretend to set the behavior
# and the respective option.
#
- # destination_root<String>:: The root directory needed for some actions. It's also known
- # as destination root.
+ # destination_root<String>:: The root directory needed for some actions.
#
def initialize(args=[], options={}, config={})
self.behavior = case config[:behavior].to_s
@@ -80,7 +77,7 @@ class Thor
# Wraps an action object and call it accordingly to the thor class behavior.
#
- def action(instance)
+ def action(instance) #:nodoc:
if behavior == :revoke
instance.revoke!
else
@@ -110,18 +107,23 @@ class Thor
remove_dot ? (path[2..-1] || '') : path
end
+ # Holds source paths in instance so they can be manipulated.
+ #
+ def source_paths
+ @source_paths ||= self.class.source_paths_for_search
+ end
+
# Receives a file or directory and search for it in the source paths.
#
def find_in_source_paths(file)
relative_root = relative_to_original_destination_root(destination_root, false)
- paths = self.class.source_paths_for_search
- paths.each do |source|
+ source_paths.each do |source|
source_file = File.expand_path(file, File.join(source, relative_root))
return source_file if File.exists?(source_file)
end
- if paths.empty?
+ if source_paths.empty?
raise Error, "You don't have any source path defined for class #{self.class.name}. To fix this, " <<
"you can define a source_root in your class."
else
@@ -205,7 +207,7 @@ class Thor
end
say_status :run, desc, config.fetch(:verbose, true)
- `#{command}` unless options[:pretend]
+ system(command) unless options[:pretend]
end
# Executes a ruby script (taking into account WIN32 platform quirks).
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/create_file.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/create_file.rb
index 8f6badee27..8f6badee27 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/create_file.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/create_file.rb
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/directory.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/directory.rb
index e33639f4e5..be5eb822ac 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/directory.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/directory.rb
@@ -3,7 +3,7 @@ require 'thor/actions/empty_directory'
class Thor
module Actions
- # Copies interactively the files from source directory to root directory.
+ # Copies recursively the files from source directory to root directory.
# If any of the files finishes with .tt, it's considered to be a template
# and is placed in the destination without the extension .tt. If any
# empty directory is found, it's copied and all .empty_directory files are
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/empty_directory.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/empty_directory.rb
index 03c1fe4af1..03c1fe4af1 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/empty_directory.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/empty_directory.rb
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/file_manipulation.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/file_manipulation.rb
index 74c157ba8c..74c157ba8c 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/file_manipulation.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/file_manipulation.rb
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/inject_into_file.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/inject_into_file.rb
index 089bd894e4..66dd1f5fc1 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/actions/inject_into_file.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/actions/inject_into_file.rb
@@ -34,7 +34,7 @@ class Thor
action InjectIntoFile.new(self, destination, data, config)
end
- class InjectIntoFile < EmptyDirectory
+ class InjectIntoFile < EmptyDirectory #:nodoc:
attr_reader :flag, :replacement
def initialize(base, destination, data, config)
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/base.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/base.rb
index 0bdcc1f4d5..0fa87f8162 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/base.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/base.rb
@@ -8,7 +8,10 @@ require 'thor/task'
require 'thor/util'
class Thor
+ # Shortcuts for help.
HELP_MAPPINGS = %w(-h -? --help -D)
+
+ # Thor methods that should not be overwritten by the user.
THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
action add_file create_file in_root inside run run_ruby_script)
@@ -78,7 +81,6 @@ class Thor
# Whenever a class inherits from Thor or Thor::Group, we should track the
# class and the file on Thor::Base. This is the method responsable for it.
- # Also adds the source root to the source paths if the klass respond to it.
#
def register_klass_file(klass) #:nodoc:
file = caller[1].match(/(.*):\d+/)[1]
@@ -246,7 +248,8 @@ class Thor
# Returns the tasks for this Thor class.
#
# ==== Returns
- # OrderedHash:: An ordered hash with this class tasks.
+ # OrderedHash:: An ordered hash with tasks names as keys and Thor::Task
+ # objects as values.
#
def tasks
@tasks ||= Thor::CoreExt::OrderedHash.new
@@ -255,7 +258,8 @@ class Thor
# Returns the tasks for this Thor class and all subclasses.
#
# ==== Returns
- # OrderedHash
+ # OrderedHash:: An ordered hash with tasks names as keys and Thor::Task
+ # objects as values.
#
def all_tasks
@all_tasks ||= from_superclass(:all_tasks, Thor::CoreExt::OrderedHash.new)
@@ -334,7 +338,7 @@ class Thor
def namespace(name=nil)
case name
when nil
- @namespace ||= Thor::Util.constant_to_namespace(self, false)
+ @namespace ||= Thor::Util.namespace_from_thor_class(self, false)
else
@namespace = name.to_s
end
@@ -342,7 +346,7 @@ class Thor
# Default way to start generators from the command line.
#
- def start(given_args=ARGV, config={}) #:nodoc:
+ def start(given_args=ARGV, config={})
config[:shell] ||= Thor::Base.shell.new
yield
rescue Thor::Error => e
@@ -360,7 +364,7 @@ class Thor
# hooks to add extra options, one of them if the third argument called
# extra_group that should be a hash in the format :group => Array[Options].
#
- # The second is by returning a lamda used to print values. The lambda
+ # The second is by returning a lambda used to print values. The lambda
# requires two options: the group name and the array of options.
#
def class_options_help(shell, ungrouped_name=nil, extra_group=nil) #:nodoc:
@@ -377,24 +381,14 @@ class Thor
options.each do |option|
item = [ option.usage(padding) ]
-
- item << if option.description
- "# #{option.description}"
- else
- ""
- end
+ item.push(option.description ? "# #{option.description}" : "")
list << item
list << [ "", "# Default: #{option.default}" ] if option.show_default?
end
unless list.empty?
- if group_name
- shell.say "#{group_name} options:"
- else
- shell.say "Options:"
- end
-
+ shell.say(group_name ? "#{group_name} options:" : "Options:")
shell.print_table(list, :ident => 2)
shell.say ""
end
@@ -412,7 +406,7 @@ class Thor
# Raises an error if the word given is a Thor reserved word.
#
- def is_thor_reserved_word?(word, type)
+ def is_thor_reserved_word?(word, type) #:nodoc:
return false unless THOR_RESERVED_WORDS.include?(word.to_s)
raise "#{word.inspect} is a Thor reserved word and cannot be defined as #{type}"
end
@@ -423,7 +417,7 @@ class Thor
# name<Symbol>:: The name of the argument.
# options<Hash>:: Described in both class_option and method_option.
#
- def build_option(name, options, scope)
+ def build_option(name, options, scope) #:nodoc:
scope[name] = Thor::Option.new(name, options[:desc], options[:required],
options[:type], options[:default], options[:banner],
options[:group], options[:aliases])
@@ -437,7 +431,7 @@ class Thor
# ==== Parameters
# Hash[Symbol => Object]
#
- def build_options(options, scope)
+ def build_options(options, scope) #:nodoc:
options.each do |key, value|
scope[key] = Thor::Option.parse(key, value)
end
@@ -447,7 +441,7 @@ class Thor
# class, just return it, otherwise dup it and add the fresh copy to the
# current task hash.
#
- def find_and_refresh_task(name)
+ def find_and_refresh_task(name) #:nodoc:
task = if task = tasks[name.to_s]
task
elsif task = all_tasks[name.to_s]
@@ -465,7 +459,7 @@ class Thor
end
# Fire this callback whenever a method is added. Added methods are
- # tracked as tasks if the requirements set by valid_task? are valid.
+ # tracked as tasks by invoking the create_task method.
#
def method_added(meth)
meth = meth.to_s
@@ -486,7 +480,7 @@ class Thor
end
# Retrieves a value from superclass. If it reaches the baseclass,
- # returns nil.
+ # returns default.
#
def from_superclass(method, default=nil)
if self == baseclass || !superclass.respond_to?(method, true)
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/core_ext/hash_with_indifferent_access.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/hash_with_indifferent_access.rb
index 3213961fe4..78bc5cf4bf 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/hash_with_indifferent_access.rb
@@ -1,5 +1,5 @@
class Thor
- module CoreExt
+ module CoreExt #:nodoc:
# A hash with indifferent access and magic predicates.
#
@@ -9,7 +9,7 @@ class Thor
# hash['foo'] #=> 'bar'
# hash.foo? #=> true
#
- class HashWithIndifferentAccess < ::Hash
+ class HashWithIndifferentAccess < ::Hash #:nodoc:
def initialize(hash={})
super()
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/core_ext/ordered_hash.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/ordered_hash.rb
index 5e4ad5609f..27fea5bb35 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/core_ext/ordered_hash.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/core_ext/ordered_hash.rb
@@ -1,6 +1,4 @@
-require 'forwardable'
-
-class Thor #:nodoc:
+class Thor
module CoreExt #:nodoc:
if RUBY_VERSION >= '1.9'
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/error.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/error.rb
new file mode 100644
index 0000000000..f9b31a35d1
--- /dev/null
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/error.rb
@@ -0,0 +1,27 @@
+class Thor
+ # Thor::Error is raised when it's caused by wrong usage of thor classes. Those
+ # errors have their backtrace supressed and are nicely shown to the user.
+ #
+ # Errors that are caused by the developer, like declaring a method which
+ # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we
+ # ensure that developer errors are shown with full backtrace.
+ #
+ class Error < StandardError
+ end
+
+ # Raised when a task was not found.
+ #
+ class UndefinedTaskError < Error
+ end
+
+ # Raised when a task was found, but not invoked properly.
+ #
+ class InvocationError < Error
+ end
+
+ class RequiredArgumentMissingError < InvocationError
+ end
+
+ class MalformattedArgumentError < InvocationError
+ end
+end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/group.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/group.rb
index 1be1c35ba5..1e59df2313 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/group.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/group.rb
@@ -221,9 +221,9 @@ class Thor::Group
protected
# The banner for this class. You can customize it if you are invoking the
- # thor class by another means which is not the Thor::Runner.
+ # thor class by another ways which is not the Thor::Runner.
#
- def banner #:nodoc:
+ def banner
"#{self.namespace} #{self.arguments.map {|a| a.usage }.join(' ')}"
end
@@ -244,7 +244,7 @@ class Thor::Group
# Shortcut to invoke with padding and block handling. Use internally by
# invoke and invoke_from_option class methods.
#
- def _invoke_for_class_method(klass, task=nil, *args, &block)
+ def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
shell.padding += 1
result = if block_given?
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/invocation.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/invocation.rb
index 34e7a4b911..c0388dd863 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/invocation.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/invocation.rb
@@ -11,7 +11,7 @@ class Thor
def prepare_for_invocation(key, name) #:nodoc:
case name
when Symbol, String
- Thor::Util.namespace_to_thor_class(name.to_s, false)
+ Thor::Util.namespace_to_thor_class_and_task(name.to_s, false)
else
name
end
@@ -96,20 +96,8 @@ class Thor
task, args, opts, config = nil, task, args, opts if task.nil? || task.is_a?(Array)
args, opts, config = nil, args, opts if args.is_a?(Hash)
- object, task = _prepare_for_invocation(name, task)
- if object.is_a?(Class)
- klass = object
-
- stored_args, stored_opts, stored_config = @_initializer
- args ||= stored_args.dup
- opts ||= stored_opts.dup
-
- config ||= {}
- config = stored_config.merge(_shared_configuration).merge!(config)
- instance = klass.new(args, opts, config)
- else
- klass, instance = object.class, object
- end
+ object, task = _prepare_for_invocation(name, task)
+ klass, instance = _initialize_klass_with_initializer(object, args, opts, config)
method_args = []
current = @_invocations[klass]
@@ -134,7 +122,7 @@ class Thor
# Configuration values that are shared between invocations.
#
- def _shared_configuration
+ def _shared_configuration #:nodoc:
{ :invocations => @_invocations }
end
@@ -154,13 +142,13 @@ class Thor
# If the object was not set, use self and use the name as task.
object, task = self, name unless object
- return object, _validate_klass_and_task(object, task)
+ return object, _validate_task(object, task)
end
# Check if the object given is a Thor class object and get a task object
# for it.
#
- def _validate_klass_and_task(object, task) #:nodoc:
+ def _validate_task(object, task) #:nodoc:
klass = object.is_a?(Class) ? object : object.class
raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base
@@ -168,5 +156,23 @@ class Thor
task = klass.all_tasks[task.to_s] || Task.dynamic(task) if task && !task.is_a?(Thor::Task)
task
end
+
+ # Initialize klass using values stored in the @_initializer.
+ #
+ def _initialize_klass_with_initializer(object, args, opts, config) #:nodoc:
+ if object.is_a?(Class)
+ klass = object
+
+ stored_args, stored_opts, stored_config = @_initializer
+ args ||= stored_args.dup
+ opts ||= stored_opts.dup
+
+ config ||= {}
+ config = stored_config.merge(_shared_configuration).merge!(config)
+ [ klass, klass.new(args, opts, config) ]
+ else
+ [ object.class, object ]
+ end
+ end
end
end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/parser.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/parser.rb
index 57a3f6e1a5..57a3f6e1a5 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/parser.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/parser.rb
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/argument.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/argument.rb
index 2d7f4dbafb..aa8ace4719 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/argument.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/argument.rb
@@ -1,5 +1,5 @@
class Thor
- class Argument
+ class Argument #:nodoc:
VALID_TYPES = [ :numeric, :hash, :array, :string ]
attr_reader :name, :description, :required, :type, :default, :banner
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/arguments.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/arguments.rb
index 9a2262d6f7..fb5d965e06 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/arguments.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/arguments.rb
@@ -1,5 +1,5 @@
class Thor
- class Arguments
+ class Arguments #:nodoc:
NUMERIC = /(\d*\.\d+|\d+)/
# Receives an array of args and returns two arrays, one with arguments
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/option.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/option.rb
index 5c43f6b18f..9e40ec73fa 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/option.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/option.rb
@@ -1,5 +1,5 @@
class Thor
- class Option < Argument
+ class Option < Argument #:nodoc:
attr_reader :aliases, :group
VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/options.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/options.rb
index 01c86b7b27..75092308b5 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/parser/options.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/parser/options.rb
@@ -2,7 +2,7 @@ class Thor
# This is a modified version of Daniel Berger's Getopt::Long class, licensed
# under Ruby's license.
#
- class Options < Arguments
+ class Options < Arguments #:nodoc:
LONG_RE = /^(--\w+[-\w+]*)$/
SHORT_RE = /^(-[a-z])$/i
EQ_RE = /^(--\w+[-\w+]*|-[a-z])=(.*)$/i
diff --git a/railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb
new file mode 100644
index 0000000000..3ab6bb21f5
--- /dev/null
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/rake_compat.rb
@@ -0,0 +1,67 @@
+require 'rake'
+
+class Thor
+ # Adds a compatibility layer to your Thor classes which allows you to use
+ # rake package tasks. For example, to use rspec rake tasks, one can do:
+ #
+ # require 'thor/rake_compat'
+ #
+ # class Default < Thor
+ # include Thor::RakeCompat
+ #
+ # Spec::Rake::SpecTask.new(:spec) do |t|
+ # t.spec_opts = ['--options', "spec/spec.opts"]
+ # t.spec_files = FileList['spec/**/*_spec.rb']
+ # end
+ # end
+ #
+ module RakeCompat
+ def self.rake_classes
+ @rake_classes ||= []
+ end
+
+ def self.included(base)
+ # Hack. Make rakefile point to invoker, so rdoc task is generated properly.
+ Rake.application.instance_variable_set(:@rakefile, caller[0].match(/(.*):\d+/)[1])
+ self.rake_classes << base
+ end
+ end
+end
+
+class Object #:nodoc:
+ alias :rake_task :task
+ alias :rake_namespace :namespace
+
+ def task(*args, &block)
+ task = rake_task(*args, &block)
+
+ if klass = Thor::RakeCompat.rake_classes.last
+ non_namespaced_name = task.name.split(':').last
+
+ description = non_namespaced_name
+ description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ')
+ description.strip!
+
+ klass.desc description, task.comment || non_namespaced_name
+ klass.class_eval <<-METHOD
+ def #{non_namespaced_name}(#{task.arg_names.join(', ')})
+ Rake::Task[#{task.name.to_sym.inspect}].invoke(#{task.arg_names.join(', ')})
+ end
+ METHOD
+ end
+
+ task
+ end
+
+ def namespace(name, &block)
+ if klass = Thor::RakeCompat.rake_classes.last
+ const_name = Thor::Util.camel_case(name.to_s).to_sym
+ klass.const_set(const_name, Class.new(Thor))
+ new_klass = klass.const_get(const_name)
+ Thor::RakeCompat.rake_classes << new_klass
+ end
+
+ rake_namespace(name, &block)
+ Thor::RakeCompat.rake_classes.pop
+ end
+end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/runner.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/runner.rb
index 6782c61dec..3639ac0aa9 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/runner.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/runner.rb
@@ -4,7 +4,7 @@ require 'yaml'
require 'digest/md5'
require 'pathname'
-class Thor::Runner < Thor
+class Thor::Runner < Thor #:nodoc:
map "-T" => :list, "-i" => :install, "-u" => :update
# Override Thor#help so it can give information about any class and any method.
@@ -12,8 +12,9 @@ class Thor::Runner < Thor
def help(meth=nil)
if meth && !self.respond_to?(meth)
initialize_thorfiles(meth)
- klass, task = Thor::Util.namespace_to_thor_class(meth)
- klass.start(["-h", task].compact, :shell => self.shell) # send mapping -h because it works with Thor::Group too
+ klass, task = Thor::Util.namespace_to_thor_class_and_task(meth)
+ # Send mapping -h because it works with Thor::Group too
+ klass.start(["-h", task].compact, :shell => self.shell)
else
super
end
@@ -25,12 +26,12 @@ class Thor::Runner < Thor
def method_missing(meth, *args)
meth = meth.to_s
initialize_thorfiles(meth)
- klass, task = Thor::Util.namespace_to_thor_class(meth)
+ klass, task = Thor::Util.namespace_to_thor_class_and_task(meth)
args.unshift(task) if task
klass.start(args, :shell => shell)
end
- desc "install NAME", "Install a Thor file into your system tasks, optionally named for future updates"
+ desc "install NAME", "Install an optionally named Thor file into your system tasks"
method_options :as => :string, :relative => :boolean
def install(name)
initialize_thorfiles
@@ -76,7 +77,7 @@ class Thor::Runner < Thor
thor_yaml[as] = {
:filename => Digest::MD5.hexdigest(name + as),
:location => location,
- :namespaces => Thor::Util.namespaces_in_contents(contents, base)
+ :namespaces => Thor::Util.namespaces_in_content(contents, base)
}
save_yaml(thor_yaml)
@@ -130,8 +131,7 @@ class Thor::Runner < Thor
display_klasses(true, klasses)
end
- desc "list [SEARCH]",
- "List the available thor tasks (--substring means SEARCH anywhere in the namespace)"
+ desc "list [SEARCH]", "List the available thor tasks (--substring means .*SEARCH)"
method_options :substring => :boolean, :group => :string, :all => :boolean
def list(search="")
initialize_thorfiles
@@ -269,6 +269,10 @@ class Thor::Runner < Thor
end
unless klasses.empty?
+ klasses.dup.each do |klass|
+ klasses -= Thor::Util.thor_classes_in(klass)
+ end
+
klasses.each { |k| display_tasks(k) }
else
say "\033[1;34mNo Thor tasks available\033[0m"
@@ -285,7 +289,7 @@ class Thor::Runner < Thor
say shell.set_color(base, color, true)
say "-" * base.length
- klass.help(shell, :short => true, :namespace => true)
+ klass.help(shell, :short => true, :ident => 0, :namespace => true)
end
end
end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/shell.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/shell.rb
index 7ed4a24bfb..0d3f4d5951 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/shell.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/shell.rb
@@ -64,7 +64,7 @@ class Thor
# Allow shell to be shared between invocations.
#
- def _shared_configuration
+ def _shared_configuration #:nodoc:
super.merge!(:shell => self.shell)
end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/shell/basic.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/shell/basic.rb
index e294c87567..3c02e47c33 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/shell/basic.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/shell/basic.rb
@@ -11,9 +11,9 @@ class Thor
@base, @padding = nil, 0
end
- # Do not allow padding to be less than zero.
+ # Sets the output padding, not allowing less than zero values.
#
- def padding=(value) #:nodoc:
+ def padding=(value)
@padding = [0, value].max
end
@@ -52,7 +52,7 @@ class Thor
# in log_status, avoiding the message from being shown. If a Symbol is
# given in log_status, it's used as the color.
#
- def say_status(status, message, log_status=true) #:nodoc:
+ def say_status(status, message, log_status=true)
return if quiet? || log_status == false
spaces = " " * (padding + 1)
color = log_status.is_a?(Symbol) ? log_status : :green
@@ -80,17 +80,21 @@ class Thor
#
# ==== Parameters
# list<Array[String, String, ...]>
- # mode<Symbol>:: Can be :rows or :inline. Defaults to :rows.
#
- def print_list(list, mode=:rows)
+ # ==== Options
+ # mode:: Can be :rows or :inline. Defaults to :rows.
+ # ident:: Ident each item with the value given.
+ #
+ def print_list(list, options={})
return if list.empty?
- content = case mode
+ ident = " " * (options[:ident] || 0)
+ content = case options[:mode]
when :inline
last = list.pop
"#{list.join(", ")}, and #{last}"
else # rows
- list.join("\n")
+ ident + list.join("\n#{ident}")
end
$stdout.puts content
@@ -103,7 +107,6 @@ class Thor
#
# ==== Options
# ident<Integer>:: Ident the first column by ident value.
- # emphasize_last<Boolean>:: When true, add a different behavior to the last column.
#
def print_table(table, options={})
return if table.empty?
@@ -131,7 +134,7 @@ class Thor
#
# ==== Parameters
# destination<String>:: the destination file to solve conflicts
- # block<Proc>:: an optional proc that returns the value to be used in diff
+ # block<Proc>:: an optional block that returns the value to be used in diff
#
def file_collision(destination)
return true if @always_force
@@ -164,19 +167,20 @@ class Thor
# wrong, you can always raise an exception. If you raise a Thor::Error, it
# will be rescued and wrapped in the method below.
#
- def error(statement) #:nodoc:
+ def error(statement)
$stderr.puts statement
end
- # Apply color to the given string with optional bold.
+ # Apply color to the given string with optional bold. Disabled in the
+ # Thor::Shell::Basic class.
#
- def set_color(string, color, bold=false)
+ def set_color(string, color, bold=false) #:nodoc:
string
end
protected
- def is?(value)
+ def is?(value) #:nodoc:
value = value.to_s
if value.size == 1
@@ -186,7 +190,7 @@ class Thor
end
end
- def file_collision_help
+ def file_collision_help #:nodoc:
<<HELP
Y - yes, overwrite
n - no, do not overwrite
@@ -197,17 +201,17 @@ h - help, show this help
HELP
end
- def show_diff(destination, content)
+ def show_diff(destination, content) #:nodoc:
diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u'
Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
temp.write content
temp.rewind
- say `#{diff_cmd} "#{destination}" "#{temp.path}"`
+ system %(#{diff_cmd} "#{destination}" "#{temp.path}")
end
end
- def quiet?
+ def quiet? #:nodoc:
base && base.options[:quiet]
end
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/shell/color.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/shell/color.rb
index be7995146a..24704f7885 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/shell/color.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/shell/color.rb
@@ -2,7 +2,8 @@ require 'thor/shell/basic'
class Thor
module Shell
- # Set color in the output. Got color values from HighLine.
+ # Inherit from Thor::Shell::Basic and add set_color behavior. Check
+ # Thor::Shell::Basic to see all available methods.
#
class Color < Basic
# Embed in a String to clear all previous ANSI sequences.
@@ -44,9 +45,10 @@ class Thor
# Set the terminal's background ANSI color to white.
ON_WHITE = "\e[47m"
- # Set color by using a string or one of the defined constants. Based
- # on Highline implementation. CLEAR is automatically be embedded to
- # the end of the returned String.
+ # Set color by using a string or one of the defined constants. If a third
+ # option is set to true, it also adds bold to the string. This is based
+ # on Highline implementation and it automatically appends CLEAR to the end
+ # of the returned String.
#
def set_color(string, color, bold=false)
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
@@ -59,7 +61,7 @@ class Thor
# Overwrite show_diff to show diff with colors if Diff::LCS is
# available.
#
- def show_diff(destination, content)
+ def show_diff(destination, content) #:nodoc:
if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
actual = File.read(destination).to_s.split("\n")
content = content.to_s.split("\n")
@@ -72,7 +74,7 @@ class Thor
end
end
- def output_diff_line(diff)
+ def output_diff_line(diff) #:nodoc:
case diff.action
when '-'
say "- #{diff.old_element.chomp}", :red, true
@@ -89,7 +91,7 @@ class Thor
# Check if Diff::LCS is loaded. If it is, use it to create pretty output
# for diff.
#
- def diff_lcs_loaded?
+ def diff_lcs_loaded? #:nodoc:
return true if defined?(Diff::LCS)
return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/task.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/task.rb
index 92c0776c04..23d35b883c 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/task.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/task.rb
@@ -12,7 +12,7 @@ class Thor
super(name.to_s, description, usage, options || {})
end
- def initialize_copy(other)
+ def initialize_copy(other) #:nodoc:
super(other)
self.options = other.options.dup if other.options
end
@@ -36,11 +36,19 @@ class Thor
# Returns the formatted usage. If a class is given, the class arguments are
# injected in the usage.
#
- def formatted_usage(klass=nil, namespace=false)
+ def formatted_usage(klass=nil, namespace=false, show_options=true)
formatted = ''
- formatted << "#{klass.namespace.gsub(/^default/,'')}:" if klass && namespace
+
+ formatted = if namespace.is_a?(String)
+ "#{namespace}:"
+ elsif klass && namespace
+ "#{klass.namespace.gsub(/^default/,'')}:"
+ else
+ ""
+ end
+
formatted << formatted_arguments(klass)
- formatted << " #{formatted_options}"
+ formatted << " #{formatted_options}" if show_options
formatted.strip!
formatted
end
@@ -67,20 +75,20 @@ class Thor
# Given a target, checks if this class name is not a private/protected method.
#
- def public_method?(instance)
+ 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
end
# Clean everything that comes from the Thor gempath and remove the caller.
#
- def sans_backtrace(backtrace, caller)
+ def sans_backtrace(backtrace, caller) #:nodoc:
dirname = /^#{Regexp.escape(File.dirname(__FILE__))}/
saned = backtrace.reject { |frame| frame =~ dirname }
saned -= caller
end
- def parse_argument_error(instance, e, caller)
+ def parse_argument_error(instance, e, caller) #:nodoc:
backtrace = sans_backtrace(e.backtrace, caller)
if backtrace.empty? && e.message =~ /wrong number of arguments/
@@ -95,7 +103,7 @@ class Thor
end
end
- def parse_no_method_error(instance, e)
+ def parse_no_method_error(instance, e) #:nodoc:
if e.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
raise UndefinedTaskError, "The #{instance.class.namespace} namespace " <<
"doesn't have a '#{name}' task"
diff --git a/railties/lib/vendor/thor-0.11.3/lib/thor/util.rb b/railties/lib/vendor/thor-0.11.5/lib/thor/util.rb
index 26db24aadb..4938dc4aca 100644
--- a/railties/lib/vendor/thor-0.11.3/lib/thor/util.rb
+++ b/railties/lib/vendor/thor-0.11.5/lib/thor/util.rb
@@ -1,14 +1,14 @@
require 'rbconfig'
class Thor
- module Sandbox; end
+ module Sandbox #:nodoc:
+ end
# This module holds several utilities:
#
# 1) Methods to convert thor namespaces to constants and vice-versa.
#
- # Thor::Utils.constant_to_namespace(Foo::Bar::Baz) #=> "foo:bar:baz"
- # Thor::Utils.namespace_to_constant("foo:bar:baz") #=> Foo::Bar::Baz
+ # Thor::Utils.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
#
# 2) Loading thor files and sandboxing:
#
@@ -43,15 +43,15 @@ class Thor
# ==== Returns
# String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
#
- def self.constant_to_namespace(constant, remove_default=true)
+ def self.namespace_from_thor_class(constant, remove_default=true)
constant = constant.to_s.gsub(/^Thor::Sandbox::/, "")
constant = snake_case(constant).squeeze(":")
constant.gsub!(/^default/, '') if remove_default
constant
end
- # Given the contents, evaluate it inside the sandbox and returns the thor
- # classes defined in the sandbox.
+ # Given the contents, evaluate it inside the sandbox and returns the
+ # namespaces defined in the sandbox.
#
# ==== Parameters
# contents<String>
@@ -59,7 +59,7 @@ class Thor
# ==== Returns
# Array[Object]
#
- def self.namespaces_in_contents(contents, file=__FILE__)
+ def self.namespaces_in_content(contents, file=__FILE__)
old_constants = Thor::Base.subclasses.dup
Thor::Base.subclasses.clear
@@ -73,6 +73,14 @@ class Thor
new_constants
end
+ # Returns the thor classes declared inside the given class.
+ #
+ def self.thor_classes_in(klass)
+ Thor::Base.subclasses.select do |subclass|
+ klass.constants.include?(subclass.name.gsub("#{klass.name}::", ''))
+ end
+ end
+
# Receives a string and convert it to snake case. SnakeCase returns snake_case.
#
# ==== Parameters
@@ -87,6 +95,19 @@ class Thor
return $+.downcase
end
+ # Receives a string and convert it to camel case. camel_case returns CamelCase.
+ #
+ # ==== Parameters
+ # String
+ #
+ # ==== Returns
+ # String
+ #
+ def self.camel_case(str)
+ return str if str !~ /_/ && str =~ /[A-Z]+.*/
+ str.split('_').map { |i| i.capitalize }.join
+ end
+
# Receives a namespace and tries to retrieve a Thor or Thor::Group class
# from it. It first searches for a class using the all the given namespace,
# if it's not found, removes the highest entry and searches for the class
@@ -115,7 +136,7 @@ class Thor
# Thor::Error:: raised if the namespace evals to a class which does not
# inherit from Thor or Thor::Group.
#
- def self.namespace_to_thor_class(namespace, raise_if_nil=true)
+ def self.namespace_to_thor_class_and_task(namespace, raise_if_nil=true)
klass, task_name = Thor::Util.find_by_namespace(namespace), nil
if klass.nil? && namespace.include?(?:)
@@ -156,7 +177,7 @@ class Thor
yaml.each do |k, v|
next unless v[:constants] && v[:namespaces].nil?
yaml_changed = true
- yaml[k][:namespaces] = v[:constants].map{|c| Thor::Util.constant_to_namespace(c)}
+ yaml[k][:namespaces] = v[:constants].map{|c| Thor::Util.namespace_from_thor_class(c)}
end
yaml_changed
@@ -214,7 +235,7 @@ class Thor
# Return the path to the ruby interpreter taking into account multiple
# installations and windows extensions.
#
- def self.ruby_command #:nodoc:
+ def self.ruby_command
@ruby_command ||= begin
ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
ruby << Config::CONFIG['EXEEXT']