josevalim-thor 0.10.5 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/thor/actions.rb CHANGED
@@ -53,8 +53,15 @@ class Thor
53
53
  :invoke
54
54
  end
55
55
 
56
- self.root = config[:root]
57
56
  super
57
+
58
+ self.root = config[:root]
59
+
60
+ # For last, invoke source root to allow the result to be cached. This is
61
+ # needed because source root depends on the file location (__FILE__) which
62
+ # returns the wrong value if invoked after FileUtils#cd.
63
+ #
64
+ self.source_root if self.class.respond_to?(:source_root)
58
65
  end
59
66
 
60
67
  # Wraps an action object and call it accordingly to the thor class behavior.
data/lib/thor/group.rb CHANGED
@@ -47,10 +47,10 @@ class Thor::Group
47
47
  #
48
48
  def help(shell, options={})
49
49
  if options[:short]
50
- shell.say "#{self.namespace} #{self.arguments.map {|o| o.usage }.join(' ')}"
50
+ shell.say banner
51
51
  else
52
52
  shell.say "Usage:"
53
- shell.say " #{self.namespace} #{self.arguments.map {|o| o.usage }.join(' ')}"
53
+ shell.say " #{banner}"
54
54
  shell.say
55
55
  class_options_help(shell)
56
56
  shell.say self.desc if self.desc
@@ -59,6 +59,13 @@ class Thor::Group
59
59
 
60
60
  protected
61
61
 
62
+ # The banner for this class. You can customize it if you are invoking the
63
+ # thor class by another means which is not the Thor::Runner.
64
+ #
65
+ def banner #:nodoc:
66
+ "#{self.namespace} #{self.arguments.map {|o| o.usage }.join(' ')}"
67
+ end
68
+
62
69
  def baseclass #:nodoc:
63
70
  Thor::Group
64
71
  end
data/lib/thor.rb CHANGED
@@ -157,13 +157,13 @@ class Thor
157
157
  raise UndefinedTaskError, "task '#{meth}' could not be found in namespace '#{self.namespace}'" unless task
158
158
 
159
159
  shell.say "Usage:"
160
- shell.say " #{task.formatted_usage(self, options[:namespace])}"
160
+ shell.say " #{banner(task, options[:namespace])}"
161
161
  shell.say
162
162
  class_options_help(shell, "Class")
163
163
  shell.say task.description
164
164
  else
165
165
  list = (options[:short] ? tasks : all_tasks).map do |_, task|
166
- [ task.formatted_usage(self, options[:namespace]), task.short_description || '' ]
166
+ [ banner(task, options[:namespace]), task.short_description || '' ]
167
167
  end
168
168
 
169
169
  if options[:short]
@@ -180,6 +180,15 @@ class Thor
180
180
 
181
181
  protected
182
182
 
183
+ # The banner for this class. You can customize it if you are invoking the
184
+ # thor class by another means which is not the Thor::Runner. It receives
185
+ # the task that is going to be invoked and if the namespace should be
186
+ # displayed.
187
+ #
188
+ def banner(task, namespace=true) #:nodoc:
189
+ task.formatted_usage(self, namespace)
190
+ end
191
+
183
192
  def baseclass #:nodoc:
184
193
  Thor
185
194
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: josevalim-thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz