thor 0.11.7 → 0.12.0
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/CHANGELOG.rdoc +6 -1
- data/Thorfile +7 -2
- data/bin/rake2thor +0 -1
- data/bin/thor +1 -1
- data/lib/thor/actions/create_file.rb +1 -0
- data/lib/thor/actions/directory.rb +12 -6
- data/lib/thor/actions/empty_directory.rb +1 -0
- data/lib/thor/group.rb +1 -1
- data/lib/thor/rake_compat.rb +2 -1
- data/lib/thor/runner.rb +1 -1
- data/lib/thor/shell.rb +8 -2
- data/lib/thor/util.rb +2 -2
- data/lib/thor/version.rb +3 -0
- data/lib/thor.rb +0 -1
- data/spec/actions/create_file_spec.rb +2 -2
- data/spec/actions/directory_spec.rb +12 -0
- data/spec/rake_compat_spec.rb +4 -0
- data/spec/spec_helper.rb +2 -2
- metadata +3 -4
- data/VERSION +0 -1
data/CHANGELOG.rdoc
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
* Improve spec coverage for Thor::Runner
|
|
4
4
|
|
|
5
|
-
== 0.
|
|
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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
# enconding: utf-8
|
|
2
|
+
|
|
3
|
+
require File.join(File.dirname(__FILE__), "lib", "thor", "version")
|
|
2
4
|
require 'thor/rake_compat'
|
|
3
5
|
require 'spec/rake/spectask'
|
|
4
6
|
require 'rdoc/task'
|
|
@@ -10,11 +12,13 @@ class Default < Thor
|
|
|
10
12
|
include Thor::RakeCompat
|
|
11
13
|
|
|
12
14
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
|
15
|
+
t.libs << 'lib'
|
|
13
16
|
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
14
17
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
Spec::Rake::SpecTask.new(:rcov) do |t|
|
|
21
|
+
t.libs << 'lib'
|
|
18
22
|
t.spec_opts = ['--options', "spec/spec.opts"]
|
|
19
23
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
|
20
24
|
t.rcov = true
|
|
@@ -34,6 +38,7 @@ class Default < Thor
|
|
|
34
38
|
require 'jeweler'
|
|
35
39
|
Jeweler::Tasks.new do |s|
|
|
36
40
|
s.name = GEM_NAME
|
|
41
|
+
s.version = Thor::VERSION
|
|
37
42
|
s.rubyforge_project = "textmate"
|
|
38
43
|
s.platform = Gem::Platform::RUBY
|
|
39
44
|
s.summary = "A scripting framework that replaces rake, sake and rubigen"
|
|
@@ -51,7 +56,7 @@ class Default < Thor
|
|
|
51
56
|
s.test_files.exclude 'spec/sandbox/**/*'
|
|
52
57
|
end
|
|
53
58
|
|
|
54
|
-
Jeweler::
|
|
59
|
+
Jeweler::GemcutterTasks.new
|
|
55
60
|
rescue LoadError
|
|
56
61
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
|
57
62
|
end
|
data/bin/rake2thor
CHANGED
data/bin/thor
CHANGED
|
@@ -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,14 +71,19 @@ 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$/
|
|
76
|
-
|
|
78
|
+
dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
|
|
79
|
+
next if dirname == given_destination
|
|
80
|
+
base.empty_directory(dirname, config)
|
|
77
81
|
when /\.tt$/
|
|
78
|
-
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
|
|
79
84
|
else
|
|
80
|
-
base.copy_file(file_source, file_destination, config)
|
|
85
|
+
destination = base.copy_file(file_source, file_destination, config)
|
|
86
|
+
@block.call(destination) if @block
|
|
81
87
|
end
|
|
82
88
|
end
|
|
83
89
|
end
|
data/lib/thor/group.rb
CHANGED
data/lib/thor/rake_compat.rb
CHANGED
|
@@ -22,7 +22,8 @@ class Thor
|
|
|
22
22
|
|
|
23
23
|
def self.included(base)
|
|
24
24
|
# Hack. Make rakefile point to invoker, so rdoc task is generated properly.
|
|
25
|
-
|
|
25
|
+
rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
|
|
26
|
+
Rake.application.instance_variable_set(:@rakefile, rakefile)
|
|
26
27
|
self.rake_classes << base
|
|
27
28
|
end
|
|
28
29
|
end
|
data/lib/thor/runner.rb
CHANGED
|
@@ -215,7 +215,7 @@ class Thor::Runner < Thor #:nodoc:
|
|
|
215
215
|
# 5. c:\ <-- no Thorfiles found!
|
|
216
216
|
#
|
|
217
217
|
def thorfiles(relevant_to=nil, skip_lookup=false)
|
|
218
|
-
#
|
|
218
|
+
# TODO Remove this dealing with deprecated thor when :namespaces: is available as constants
|
|
219
219
|
save_yaml(thor_yaml) if Thor::Util.convert_constants_to_namespaces(thor_yaml)
|
|
220
220
|
|
|
221
221
|
thorfiles = []
|
data/lib/thor/shell.rb
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
require 'rbconfig'
|
|
1
2
|
require 'thor/shell/color'
|
|
2
3
|
|
|
3
4
|
class Thor
|
|
4
5
|
module Base
|
|
5
|
-
# Returns the shell used in all Thor classes.
|
|
6
|
+
# Returns the shell used in all Thor classes. If you are in a Unix platform
|
|
7
|
+
# it will use a colored log, otherwise it will use a basic one without color.
|
|
6
8
|
#
|
|
7
9
|
def self.shell
|
|
8
|
-
@shell ||=
|
|
10
|
+
@shell ||= if Config::CONFIG['host_os'] =~ /mswin|mingw/
|
|
11
|
+
Thor::Shell::Basic
|
|
12
|
+
else
|
|
13
|
+
Thor::Shell::Color
|
|
14
|
+
end
|
|
9
15
|
end
|
|
10
16
|
|
|
11
17
|
# Sets the shell used in all Thor classes.
|
data/lib/thor/util.rb
CHANGED
|
@@ -209,7 +209,7 @@ class Thor
|
|
|
209
209
|
# Returns the root where thor files are located, dependending on the OS.
|
|
210
210
|
#
|
|
211
211
|
def self.thor_root
|
|
212
|
-
File.join(user_home, ".thor")
|
|
212
|
+
File.join(user_home, ".thor").gsub(/\\/, '/')
|
|
213
213
|
end
|
|
214
214
|
|
|
215
215
|
# Returns the files in the thor root. On Windows thor_root will be something
|
|
@@ -220,7 +220,7 @@ class Thor
|
|
|
220
220
|
# If we don't #gsub the \ character, Dir.glob will fail.
|
|
221
221
|
#
|
|
222
222
|
def self.thor_root_glob
|
|
223
|
-
files = Dir["#{thor_root
|
|
223
|
+
files = Dir["#{thor_root}/*"]
|
|
224
224
|
|
|
225
225
|
files.map! do |file|
|
|
226
226
|
File.directory?(file) ? File.join(file, "main.thor") : file
|
data/lib/thor/version.rb
ADDED
data/lib/thor.rb
CHANGED
|
@@ -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 ==
|
|
55
|
+
create_file("doc/config.rb").invoke!.must == "doc/config.rb"
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -96,6 +96,11 @@ describe Thor::Actions::Directory do
|
|
|
96
96
|
File.exists?(file).must be_true
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
it "does not copy empty directories twice" do
|
|
100
|
+
content = invoke!("doc/components", "docs/components")
|
|
101
|
+
content.must_not =~ /exist/
|
|
102
|
+
end
|
|
103
|
+
|
|
99
104
|
it "logs status" do
|
|
100
105
|
content = invoke!("doc")
|
|
101
106
|
content.must =~ /create doc\/README/
|
|
@@ -103,6 +108,13 @@ describe Thor::Actions::Directory do
|
|
|
103
108
|
content.must =~ /create doc\/rdoc\.rb/
|
|
104
109
|
content.must =~ /create doc\/components/
|
|
105
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
|
|
106
118
|
end
|
|
107
119
|
|
|
108
120
|
describe "#revoke!" do
|
data/spec/rake_compat_spec.rb
CHANGED
|
@@ -27,6 +27,10 @@ class ThorTask < Thor
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
describe Thor::RakeCompat do
|
|
30
|
+
it "sets the rakefile application" do
|
|
31
|
+
["rake_compat_spec.rb", "Thorfile"].must include(Rake.application.rakefile)
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
it "adds rake tasks to thor classes too" do
|
|
31
35
|
task = ThorTask.tasks["cool"]
|
|
32
36
|
task.must be
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
$TESTING=true
|
|
2
2
|
|
|
3
|
-
$:.unshift
|
|
4
|
-
|
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
5
4
|
require 'thor'
|
|
6
5
|
require 'stringio'
|
|
6
|
+
|
|
7
7
|
require 'rubygems'
|
|
8
8
|
require 'rr'
|
|
9
9
|
require 'diff/lcs' # You need diff/lcs installed to run specs (but not to run Thor).
|
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.
|
|
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-09
|
|
13
|
+
date: 2009-11-09 00:00:00 -02:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies: []
|
|
16
16
|
|
|
@@ -26,13 +26,11 @@ extra_rdoc_files:
|
|
|
26
26
|
- LICENSE
|
|
27
27
|
- README.rdoc
|
|
28
28
|
- Thorfile
|
|
29
|
-
- VERSION
|
|
30
29
|
files:
|
|
31
30
|
- CHANGELOG.rdoc
|
|
32
31
|
- LICENSE
|
|
33
32
|
- README.rdoc
|
|
34
33
|
- Thorfile
|
|
35
|
-
- VERSION
|
|
36
34
|
- bin/rake2thor
|
|
37
35
|
- bin/thor
|
|
38
36
|
- lib/thor.rb
|
|
@@ -60,6 +58,7 @@ files:
|
|
|
60
58
|
- lib/thor/shell/color.rb
|
|
61
59
|
- lib/thor/task.rb
|
|
62
60
|
- lib/thor/util.rb
|
|
61
|
+
- lib/thor/version.rb
|
|
63
62
|
has_rdoc: true
|
|
64
63
|
homepage: http://yehudakatz.com
|
|
65
64
|
licenses: []
|
data/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0.11.7
|