josevalim-thor 0.10.12 → 0.10.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/thor/actions.rb CHANGED
@@ -5,6 +5,11 @@ Dir[File.join(File.dirname(__FILE__), "actions", "*.rb")].each do |action|
5
5
  end
6
6
 
7
7
  class Thor
8
+ # Some actions require that a class method called source root is defined in
9
+ # the class. Remember to always cache the source root value, because Ruby
10
+ # __FILE__ always return the relative path, which may lead to mistakes if you
11
+ # are calling an action inside the "inside(path)" method.
12
+ #
8
13
  module Actions
9
14
  attr_accessor :behavior
10
15
 
data/lib/thor/base.rb CHANGED
@@ -65,9 +65,14 @@ class Thor
65
65
 
66
66
  # Whenever a class inherits from Thor or Thor::Group, we should track the
67
67
  # class and the file on Thor::Base. This is the method responsable for it.
68
+ # Also invoke the source_root if the klass respond to it. This is needed
69
+ # to ensure that the source_root does not change after FileUtils#cd is
70
+ # called.
68
71
  #
69
72
  def register_klass_file(klass) #:nodoc:
70
73
  file = caller[1].match(/(.*):\d+/)[1]
74
+
75
+ klass.source_root if klass.respond_to?(:source_root)
71
76
  Thor::Base.subclasses << klass unless Thor::Base.subclasses.include?(klass)
72
77
 
73
78
  file_subclasses = Thor::Base.subclass_files[File.expand_path(file)]
@@ -434,13 +439,10 @@ class Thor
434
439
  end
435
440
 
436
441
  # Everytime someone inherits from a Thor class, register the klass
437
- # and file into baseclass. Also invoke the source_root if the klass
438
- # respond to it. This is needed to ensure that the source_root does
439
- # not change after FileUtils#cd is called.
442
+ # and file into baseclass.
440
443
  #
441
444
  def inherited(klass)
442
445
  Thor::Base.register_klass_file(klass)
443
- klass.source_root if klass.respond_to?(:source_root)
444
446
  end
445
447
 
446
448
  # Fire this callback whenever a method is added. Added methods are
data/lib/thor/group.rb CHANGED
@@ -12,12 +12,7 @@ class Thor::Group
12
12
  def desc(description=nil)
13
13
  case description
14
14
  when nil
15
- usage = File.join(source_root, "..", "USAGE") if respond_to?(:source_root)
16
- @desc ||= if usage && File.exist?(usage)
17
- File.read(usage)
18
- else
19
- from_superclass(:desc, nil)
20
- end
15
+ @desc ||= from_superclass(:desc, nil)
21
16
  else
22
17
  @desc = description
23
18
  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.12
4
+ version: 0.10.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-23 00:00:00 -07:00
12
+ date: 2009-06-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15