Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update banner.

  • Loading branch information...
commit c999a8da6dd5550614e55102c36ee36d99b36806 1 parent 4853f31
@josevalim josevalim authored
View
8 CHANGELOG.rdoc
@@ -1,9 +1,7 @@
-== TODO
-
-* Improve spec coverage for Thor::Runner
-
-== 0.12, released 2009-11-06
+== 0.12, released 2010-01-02
+* Removed rr in favor to rspec mock framework
+* Improved output for thor -T
* [#7] Do not force white color on status
* [#8] Yield a block with the filename on directory
View
1  bin/thor
@@ -4,4 +4,5 @@
require 'thor'
require 'thor/runner'
+$thor_runner = true
Thor::Runner.start
View
3  lib/thor.rb
@@ -193,7 +193,8 @@ def printable_tasks(all=true)
# the namespace should be displayed as arguments.
#
def banner(task)
- "thor " + task.formatted_usage(self)
+ base = $thor_runner ? "thor" : File.basename($0.split(" ").first)
+ "#{base} #{task.formatted_usage(self, base == "thor")}"
end
def baseclass #:nodoc:
View
38 lib/thor/group.rb
@@ -224,7 +224,8 @@ def printable_tasks(*)
# thor class by another ways which is not the Thor::Runner.
#
def banner
- "thor #{self_task.formatted_usage(self, false)}"
+ base = $thor_runner ? "thor" : File.basename($0.split(" ").first)
+ "#{base} #{self_task.formatted_usage(self, false)}"
end
# Represents the whole class as a task.
@@ -246,22 +247,25 @@ def create_task(meth) #:nodoc:
protected
- # 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) #:nodoc:
- shell.padding += 1
-
- result = if block_given?
- if block.arity == 2
- block.call(self, klass)
- else
- block.call(self, klass, task)
- end
- else
- invoke klass, task, *args
+ # 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) #:nodoc:
+ shell.padding += 1
+
+ result = if block_given?
+ case block.arity
+ when 3
+ block.call(self, klass, task)
+ when 2
+ block.call(self, klass)
+ when 1
+ instance_exec(klass, &block)
end
-
- shell.padding -= 1
- result
+ else
+ invoke klass, task, *args
end
+
+ shell.padding -= 1
+ result
+ end
end
View
4 lib/thor/task.rb
@@ -40,8 +40,8 @@ def run(instance, args=[])
# Returns the formatted usage by injecting given required arguments
# and required options into the given usage.
- def formatted_usage(klass, namespace=nil)
- namespace = klass.namespace if namespace.nil?
+ def formatted_usage(klass, namespace=true)
+ namespace = klass.namespace unless namespace == false
# Add namespace
formatted = if namespace
View
2  lib/thor/version.rb
@@ -1,3 +1,3 @@
class Thor
- VERSION = "0.12.2".freeze
+ VERSION = "0.12.3".freeze
end
View
2  spec/spec_helper.rb
@@ -8,6 +8,8 @@
require 'rdoc'
require 'diff/lcs' # You need diff/lcs installed to run specs (but not to run Thor).
+$thor_runner = true
+
# Load fixtures
load File.join(File.dirname(__FILE__), "fixtures", "task.thor")
load File.join(File.dirname(__FILE__), "fixtures", "group.thor")
Please sign in to comment.
Something went wrong with that request. Please try again.