thor 0.11.8 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,12 @@
2
2
 
3
3
  * Improve spec coverage for Thor::Runner
4
4
 
5
- == 0.11.x, released 2009-07-01
5
+ == 0.12, released 2009-11-06
6
+
7
+ * [#7] Do not force white color on status
8
+ * [#8] Yield a block with the filename on directory
9
+
10
+ == 0.11, released 2009-07-01
6
11
 
7
12
  * Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
8
13
  Thor classes.
data/Thorfile CHANGED
@@ -56,7 +56,7 @@ class Default < Thor
56
56
  s.test_files.exclude 'spec/sandbox/**/*'
57
57
  end
58
58
 
59
- Jeweler::RubyforgeTasks.new
59
+ Jeweler::GemcutterTasks.new
60
60
  rescue LoadError
61
61
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
62
62
  end
@@ -60,6 +60,7 @@ class Thor
60
60
  FileUtils.mkdir_p(File.dirname(destination))
61
61
  File.open(destination, 'w'){ |f| f.write render }
62
62
  end
63
+ given_destination
63
64
  end
64
65
 
65
66
  protected
@@ -40,15 +40,16 @@ class Thor
40
40
  # directory "doc"
41
41
  # directory "doc", "docs", :recursive => false
42
42
  #
43
- def directory(source, destination=nil, config={})
44
- action Directory.new(self, source, destination || source, config)
43
+ def directory(source, destination=nil, config={}, &block)
44
+ action Directory.new(self, source, destination || source, config, &block)
45
45
  end
46
46
 
47
47
  class Directory < EmptyDirectory #:nodoc:
48
48
  attr_reader :source
49
49
 
50
- def initialize(base, source, destination=nil, config={})
50
+ def initialize(base, source, destination=nil, config={}, &block)
51
51
  @source = File.expand_path(base.find_in_source_paths(source.to_s))
52
+ @block = block
52
53
  super(base, destination, { :recursive => true }.merge(config))
53
54
  end
54
55
 
@@ -70,6 +71,7 @@ class Thor
70
71
  Dir[lookup].each do |file_source|
71
72
  next if File.directory?(file_source)
72
73
  file_destination = File.join(given_destination, file_source.gsub(source, '.'))
74
+ file_destination.gsub!('/./', '/')
73
75
 
74
76
  case file_source
75
77
  when /\.empty_directory$/
@@ -77,9 +79,11 @@ class Thor
77
79
  next if dirname == given_destination
78
80
  base.empty_directory(dirname, config)
79
81
  when /\.tt$/
80
- base.template(file_source, file_destination[0..-4], config)
82
+ destination = base.template(file_source, file_destination[0..-4], config)
83
+ @block.call(destination) if @block
81
84
  else
82
- base.copy_file(file_source, file_destination, config)
85
+ destination = base.copy_file(file_source, file_destination, config)
86
+ @block.call(destination) if @block
83
87
  end
84
88
  end
85
89
  end
@@ -55,6 +55,7 @@ class Thor
55
55
  def revoke!
56
56
  say_status :remove, :red
57
57
  ::FileUtils.rm_rf(destination) if !pretend? && exists?
58
+ given_destination
58
59
  end
59
60
 
60
61
  protected
@@ -74,7 +74,7 @@ class Thor::Group
74
74
  #
75
75
  def invoke(*names, &block)
76
76
  options = names.last.is_a?(Hash) ? names.pop : {}
77
- verbose = options.fetch(:verbose, :white)
77
+ verbose = options.fetch(:verbose, true)
78
78
 
79
79
  names.each do |name|
80
80
  invocations[name] = false
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "0.11.8".freeze
2
+ VERSION = "0.12.0".freeze
3
3
  end
@@ -50,9 +50,9 @@ describe Thor::Actions::CreateFile do
50
50
  invoke!.must be_empty
51
51
  end
52
52
 
53
- it "returns the destination" do
53
+ it "returns the given destination" do
54
54
  capture(:stdout) do
55
- create_file("doc/config.rb").invoke!.must == File.join(destination_root, "doc/config.rb")
55
+ create_file("doc/config.rb").invoke!.must == "doc/config.rb"
56
56
  end
57
57
  end
58
58
 
@@ -108,6 +108,13 @@ describe Thor::Actions::Directory do
108
108
  content.must =~ /create doc\/rdoc\.rb/
109
109
  content.must =~ /create doc\/components/
110
110
  end
111
+
112
+ it "yields a block" do
113
+ invoke!("doc") do |f|
114
+ %(doc/README doc/config.rb doc/rdoc.rb).must include(f)
115
+ %(doc/components/).must_not include(f)
116
+ end
117
+ end
111
118
  end
112
119
 
113
120
  describe "#revoke!" do
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.11.8
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-10-21 00:00:00 -02:00
13
+ date: 2009-11-09 00:00:00 -02:00
14
14
  default_executable:
15
15
  dependencies: []
16
16