thor 0.14.0 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/Thorfile +2 -1
- data/lib/thor.rb +2 -2
- data/lib/thor/actions/directory.rb +1 -1
- data/lib/thor/base.rb +7 -0
- data/lib/thor/group.rb +3 -3
- data/lib/thor/parser/options.rb +9 -1
- data/lib/thor/shell.rb +1 -1
- data/lib/thor/shell/basic.rb +1 -1
- data/lib/thor/shell/html.rb +1 -1
- data/lib/thor/util.rb +2 -2
- data/lib/thor/version.rb +1 -1
- data/spec/actions/directory_spec.rb +1 -1
- data/spec/base_spec.rb +1 -1
- data/spec/fixtures/doc/components/.empty_directory +0 -0
- data/spec/shell/basic_spec.rb +4 -4
- metadata +6 -4
data/README.md
CHANGED
@@ -160,6 +160,8 @@ The output is "1 2 3", which means that the three task was invoked only once.
|
|
160
160
|
You can even invoke tasks from another class, so be sure to check the
|
161
161
|
[documentation](http://rdoc.info/rdoc/wycats/thor/blob/f939a3e8a854616784cac1dcff04ef4f3ee5f7ff/Thor.html).
|
162
162
|
|
163
|
+
Notice invocations do not share the same object. I.e, Thor will instantiate Counter once to invoke the task one, then, it instantiates another to invoke the task two and another for task three. This happens to allow options and arguments to parsed again. For example, if two and three have different options and both of them were given to the command line, calling invoke makes them be parsed each time and used accordingly by each task.
|
164
|
+
|
163
165
|
## Thor::Group
|
164
166
|
|
165
167
|
Thor has a special class called Thor::Group. The main difference to Thor class
|
data/Thorfile
CHANGED
@@ -10,7 +10,7 @@ rescue LoadError
|
|
10
10
|
end
|
11
11
|
|
12
12
|
GEM_NAME = 'thor'
|
13
|
-
EXTRA_RDOC_FILES = ["README.md", "LICENSE", "CHANGELOG.rdoc", "
|
13
|
+
EXTRA_RDOC_FILES = ["README.md", "LICENSE", "CHANGELOG.rdoc", "Thorfile"]
|
14
14
|
|
15
15
|
class Default < Thor
|
16
16
|
include Thor::RakeCompat
|
@@ -59,6 +59,7 @@ class Default < Thor
|
|
59
59
|
s.executables = %w( thor rake2thor )
|
60
60
|
s.files = s.extra_rdoc_files + Dir.glob("{bin,lib}/**/*")
|
61
61
|
s.test_files.include 'spec/**/*'
|
62
|
+
s.test_files.include 'spec/fixtures/doc/components/.empty_directory'
|
62
63
|
s.test_files.exclude 'spec/sandbox/**/*'
|
63
64
|
end
|
64
65
|
|
data/lib/thor.rb
CHANGED
@@ -200,7 +200,7 @@ class Thor
|
|
200
200
|
else
|
201
201
|
@check_unknown_options.delete(key)
|
202
202
|
end
|
203
|
-
end
|
203
|
+
end
|
204
204
|
@check_unknown_options
|
205
205
|
end
|
206
206
|
|
@@ -252,7 +252,7 @@ class Thor
|
|
252
252
|
# the namespace should be displayed as arguments.
|
253
253
|
#
|
254
254
|
def banner(task, namespace = nil, subcommand = false)
|
255
|
-
"#{
|
255
|
+
"#{basename} #{task.formatted_usage(self, $thor_runner, subcommand)}"
|
256
256
|
end
|
257
257
|
|
258
258
|
def baseclass #:nodoc:
|
@@ -21,7 +21,7 @@ class Thor
|
|
21
21
|
# directory "doc"
|
22
22
|
#
|
23
23
|
# It will create a doc directory in the destination with the following
|
24
|
-
# files (assuming that the app_name
|
24
|
+
# files (assuming that the `app_name` method returns the value "blog"):
|
25
25
|
#
|
26
26
|
# doc/
|
27
27
|
# components/
|
data/lib/thor/base.rb
CHANGED
@@ -531,6 +531,13 @@ class Thor
|
|
531
531
|
false
|
532
532
|
end
|
533
533
|
|
534
|
+
#
|
535
|
+
# The basename of the program invoking the thor class.
|
536
|
+
#
|
537
|
+
def basename
|
538
|
+
File.basename($0).split(' ').first
|
539
|
+
end
|
540
|
+
|
534
541
|
# SIGNATURE: Sets the baseclass. This is where the superclass lookup
|
535
542
|
# finishes.
|
536
543
|
def baseclass #:nodoc:
|
data/lib/thor/group.rb
CHANGED
@@ -6,7 +6,7 @@ require 'thor/base'
|
|
6
6
|
# tasks.
|
7
7
|
class Thor::Group
|
8
8
|
class << self
|
9
|
-
# The
|
9
|
+
# The description for this Thor::Group. If none is provided, but a source root
|
10
10
|
# exists, tries to find the USAGE one folder above it, otherwise searches
|
11
11
|
# in the superclass.
|
12
12
|
#
|
@@ -114,7 +114,7 @@ class Thor::Group
|
|
114
114
|
|
115
115
|
names.each do |name|
|
116
116
|
unless class_options.key?(name)
|
117
|
-
raise ArgumentError, "You have to define the option #{name.inspect} " <<
|
117
|
+
raise ArgumentError, "You have to define the option #{name.inspect} " <<
|
118
118
|
"before setting invoke_from_option."
|
119
119
|
end
|
120
120
|
|
@@ -230,7 +230,7 @@ class Thor::Group
|
|
230
230
|
# The banner for this class. You can customize it if you are invoking the
|
231
231
|
# thor class by another ways which is not the Thor::Runner.
|
232
232
|
def banner
|
233
|
-
"#{
|
233
|
+
"#{basename} #{self_task.formatted_usage(self, false)}"
|
234
234
|
end
|
235
235
|
|
236
236
|
# Represents the whole class as a task.
|
data/lib/thor/parser/options.rb
CHANGED
@@ -134,7 +134,15 @@ class Thor
|
|
134
134
|
#
|
135
135
|
def parse_boolean(switch)
|
136
136
|
if current_is_value?
|
137
|
-
["true", "TRUE", "t", "T", true].include?(
|
137
|
+
if ["true", "TRUE", "t", "T", true].include?(peek)
|
138
|
+
shift
|
139
|
+
true
|
140
|
+
elsif ["false", "FALSE", "f", "F", false].include?(peek)
|
141
|
+
shift
|
142
|
+
false
|
143
|
+
else
|
144
|
+
true
|
145
|
+
end
|
138
146
|
else
|
139
147
|
@switches.key?(switch) || !no_or_skip?(switch)
|
140
148
|
end
|
data/lib/thor/shell.rb
CHANGED
@@ -8,7 +8,7 @@ class Thor
|
|
8
8
|
def self.shell
|
9
9
|
@shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0
|
10
10
|
Thor::Shell.const_get(ENV['THOR_SHELL'])
|
11
|
-
elsif
|
11
|
+
elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
12
12
|
Thor::Shell::Basic
|
13
13
|
else
|
14
14
|
Thor::Shell::Color
|
data/lib/thor/shell/basic.rb
CHANGED
data/lib/thor/shell/html.rb
CHANGED
data/lib/thor/util.rb
CHANGED
@@ -216,8 +216,8 @@ class Thor
|
|
216
216
|
#
|
217
217
|
def self.ruby_command
|
218
218
|
@ruby_command ||= begin
|
219
|
-
ruby = File.join(
|
220
|
-
ruby <<
|
219
|
+
ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
220
|
+
ruby << RbConfig::CONFIG['EXEEXT']
|
221
221
|
|
222
222
|
# escape string in case path to ruby executable contain spaces.
|
223
223
|
ruby.sub!(/.*\s.*/m, '"\&"')
|
data/lib/thor/version.rb
CHANGED
@@ -84,7 +84,7 @@ describe Thor::Actions::Directory do
|
|
84
84
|
File.directory?(file).must be_true
|
85
85
|
end
|
86
86
|
|
87
|
-
it "does not copy .
|
87
|
+
it "does not copy .empty_directory files" do
|
88
88
|
invoke! "doc", "docs"
|
89
89
|
file = File.join(destination_root, "docs", "components", ".empty_directory")
|
90
90
|
File.exists?(file).must be_false
|
data/spec/base_spec.rb
CHANGED
@@ -74,7 +74,7 @@ describe Thor::Base do
|
|
74
74
|
MyCounter.start(["1", "2", "--third", "3"])[2].must == 3
|
75
75
|
end
|
76
76
|
|
77
|
-
it "does not create an
|
77
|
+
it "does not create an accessor for it" do
|
78
78
|
BrokenCounter.start(["1", "2", "--third", "3"])[3].must be_false
|
79
79
|
end
|
80
80
|
end
|
File without changes
|
data/spec/shell/basic_spec.rb
CHANGED
@@ -27,11 +27,11 @@ describe Thor::Shell::Basic do
|
|
27
27
|
it "asks the user and returns true if the user replies yes" do
|
28
28
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
29
29
|
$stdin.should_receive(:gets).and_return('y')
|
30
|
-
shell.yes?("Should I overwrite it?").must
|
30
|
+
shell.yes?("Should I overwrite it?").must === true
|
31
31
|
|
32
32
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
33
33
|
$stdin.should_receive(:gets).and_return('n')
|
34
|
-
shell.yes?("Should I overwrite it?").must_not
|
34
|
+
shell.yes?("Should I overwrite it?").must_not === true
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -39,11 +39,11 @@ describe Thor::Shell::Basic do
|
|
39
39
|
it "asks the user and returns true if the user replies no" do
|
40
40
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
41
41
|
$stdin.should_receive(:gets).and_return('n')
|
42
|
-
shell.no?("Should I overwrite it?").must
|
42
|
+
shell.no?("Should I overwrite it?").must === true
|
43
43
|
|
44
44
|
$stdout.should_receive(:print).with("Should I overwrite it? ")
|
45
45
|
$stdin.should_receive(:gets).and_return('Yes')
|
46
|
-
shell.no?("Should I overwrite it?").must
|
46
|
+
shell.no?("Should I overwrite it?").must === false
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 37
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 14
|
9
|
-
-
|
10
|
-
version: 0.14.
|
9
|
+
- 1
|
10
|
+
version: 0.14.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Yehuda Katz
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-09-17 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- spec/fixtures/script.thor
|
105
105
|
- spec/fixtures/task.thor
|
106
106
|
- spec/spec.opts
|
107
|
+
- spec/fixtures/doc/components/.empty_directory
|
107
108
|
has_rdoc: true
|
108
109
|
homepage: http://yehudakatz.com
|
109
110
|
licenses: []
|
@@ -176,3 +177,4 @@ test_files:
|
|
176
177
|
- spec/fixtures/script.thor
|
177
178
|
- spec/fixtures/task.thor
|
178
179
|
- spec/spec.opts
|
180
|
+
- spec/fixtures/doc/components/.empty_directory
|