josevalim-thor 0.10.4 → 0.10.5
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/lib/thor/actions/directory.rb +13 -3
- data/lib/thor/base.rb +7 -11
- data/lib/thor/group.rb +8 -5
- data/lib/thor/option.rb +1 -1
- data/lib/thor/runner.rb +1 -1
- data/lib/thor/shell/basic.rb +1 -3
- metadata +2 -2
@@ -32,20 +32,30 @@ class Thor
|
|
32
32
|
# ==== Parameters
|
33
33
|
# source<String>:: the relative path to the source root
|
34
34
|
# destination<String>:: the relative path to the destination root
|
35
|
+
# recursive<Boolean>:: if the directory must be copied recursively, true by default
|
35
36
|
# log_status<Boolean>:: if false, does not log the status. True by default.
|
36
37
|
#
|
37
38
|
# ==== Examples
|
38
39
|
#
|
39
40
|
# directory "doc"
|
41
|
+
# directory "doc", "docs", false
|
40
42
|
#
|
41
|
-
def directory(source, destination=nil, log_status=true)
|
42
|
-
action Directory.new(self, source, destination || source, log_status)
|
43
|
+
def directory(source, destination=nil, recursive=true, log_status=true)
|
44
|
+
action Directory.new(self, source, destination || source, recursive, log_status)
|
43
45
|
end
|
44
46
|
|
45
47
|
class Directory < Templater #:nodoc:
|
48
|
+
attr_reader :recursive
|
49
|
+
|
50
|
+
def initialize(base, source, destination=nil, recursive=true, log_status=true)
|
51
|
+
@recursive = recursive
|
52
|
+
super(base, source, destination, log_status)
|
53
|
+
end
|
46
54
|
|
47
55
|
def invoke!
|
48
|
-
|
56
|
+
lookup = recursive ? File.join(source, '**', '*') : File.join(source, '*')
|
57
|
+
|
58
|
+
Dir[lookup].each do |file_source|
|
49
59
|
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
50
60
|
|
51
61
|
if File.directory?(file_source)
|
data/lib/thor/base.rb
CHANGED
@@ -165,17 +165,13 @@ class Thor
|
|
165
165
|
# ==== Parameters
|
166
166
|
# name<String|Symbol>
|
167
167
|
#
|
168
|
-
def group(name)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
# String
|
176
|
-
#
|
177
|
-
def group_name
|
178
|
-
@group_name ||= from_superclass(:group_name, 'standard')
|
168
|
+
def group(name=nil)
|
169
|
+
case name
|
170
|
+
when nil
|
171
|
+
@group ||= from_superclass(:group, 'standard')
|
172
|
+
else
|
173
|
+
@group = name.to_s
|
174
|
+
end
|
179
175
|
end
|
180
176
|
|
181
177
|
# Returns the tasks for this Thor class.
|
data/lib/thor/group.rb
CHANGED
@@ -2,18 +2,21 @@ class Thor::Group
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
|
5
|
-
# The descrition for this Thor::Group
|
5
|
+
# The descrition for this Thor::Group. If none is provided, but a source root
|
6
|
+
# exists and we have an USAGE inside, this file is used as description. This
|
7
|
+
# is good because we will load such files only when we need it.
|
6
8
|
#
|
7
9
|
# ==== Parameters
|
8
10
|
# description<String>:: The description for this Thor::Group.
|
9
11
|
#
|
10
12
|
def desc(description=nil)
|
11
13
|
case description
|
12
|
-
# TODO When a symbol is given, read a file in the current directory
|
13
|
-
# when Symbol
|
14
|
-
# @desc = File.read
|
15
14
|
when nil
|
16
|
-
@desc ||=
|
15
|
+
@desc ||= if respond_to?(:source_root) && File.exist?(File.join(source_root, "USAGE"))
|
16
|
+
File.read(File.join(source_root, "USAGE"))
|
17
|
+
else
|
18
|
+
from_superclass(:desc, nil)
|
19
|
+
end
|
17
20
|
else
|
18
21
|
@desc = description
|
19
22
|
end
|
data/lib/thor/option.rb
CHANGED
data/lib/thor/runner.rb
CHANGED
@@ -141,7 +141,7 @@ class Thor::Runner < Thor
|
|
141
141
|
group = options[:group] || "standard"
|
142
142
|
|
143
143
|
klasses = Thor::Base.subclasses.select do |k|
|
144
|
-
(options[:all] || k.
|
144
|
+
(options[:all] || k.group == group) && k.namespace =~ search
|
145
145
|
end
|
146
146
|
|
147
147
|
display_klasses(false, klasses)
|
data/lib/thor/shell/basic.rb
CHANGED
@@ -38,9 +38,7 @@ class Thor
|
|
38
38
|
#
|
39
39
|
def say_status(status, message, color=nil)
|
40
40
|
return if base && base.options[:quiet]
|
41
|
-
|
42
|
-
status_flag = "[#{status.to_s.upcase}]".rjust(12)
|
43
|
-
say "#{status_flag} #{message}", color, true
|
41
|
+
say "#{status.to_s.rjust(12)} #{message}", color, true
|
44
42
|
end
|
45
43
|
|
46
44
|
# Make a question the to user and returns true if the user replies "y" or
|
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.
|
4
|
+
version: 0.10.5
|
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-
|
12
|
+
date: 2009-06-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|