thor 0.9.5 → 0.9.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.
Files changed (3) hide show
  1. data/lib/thor/runner.rb +1 -1
  2. data/lib/thor/util.rb +19 -5
  3. metadata +3 -3
@@ -176,7 +176,7 @@ class Thor::Runner < Thor
176
176
  raise Error, "No Thor tasks available" if klasses.empty?
177
177
 
178
178
  if with_modules && !(yaml = thor_yaml).empty?
179
- max_name = yaml.max {|(xk,xv),(yk,yv)| xk.size <=> yk.size }.first.size
179
+ max_name = yaml.max {|(xk,xv),(yk,yv)| xk.to_s.size <=> yk.to_s.size }.first.size
180
180
  modules_label = "Modules"
181
181
  namespaces_label = "Namespaces"
182
182
  column_width = [max_name + 4, modules_label.size + 1].max
@@ -1,5 +1,19 @@
1
1
  require 'thor/error'
2
2
 
3
+ module ObjectSpace
4
+
5
+ class << self
6
+
7
+ # @return <Array[Class]> All the classes in the object space.
8
+ def classes
9
+ klasses = []
10
+ ObjectSpace.each_object(Class) {|o| klasses << o}
11
+ klasses
12
+ end
13
+ end
14
+
15
+ end
16
+
3
17
  class Thor
4
18
  module Util
5
19
 
@@ -22,11 +36,11 @@ class Thor
22
36
  end
23
37
 
24
38
  def self.constants_in_contents(str)
25
- klasses = self.constants.dup
26
- eval(str)
27
- ret = self.constants - klasses
28
- ret.each {|k| self.send(:remove_const, k)}
29
- ret
39
+ klasses = ObjectSpace.classes.dup
40
+ Module.new.class_eval(str)
41
+ klasses = ObjectSpace.classes - klasses
42
+ klasses = klasses.select {|k| k < Thor }
43
+ klasses.map! {|k| k.to_s.gsub(/#<Module:\w+>::/, '')}
30
44
  end
31
45
 
32
46
  def self.make_constant(str)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
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: 2008-08-27 00:00:00 +02:00
12
+ date: 2008-09-12 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,8 +22,8 @@ extensions: []
22
22
 
23
23
  extra_rdoc_files:
24
24
  - README.markdown
25
- - CHANGELOG.rdoc
26
25
  - LICENSE
26
+ - CHANGELOG.rdoc
27
27
  files:
28
28
  - README.markdown
29
29
  - LICENSE