thor 0.13.5 → 0.13.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/thor/actions.rb +18 -5
- data/lib/thor/version.rb +1 -1
- data/spec/actions/directory_spec.rb +1 -1
- data/spec/actions_spec.rb +1 -1
- data/spec/fixtures/group.thor +1 -3
- metadata +3 -3
data/lib/thor/actions.rb
CHANGED
@@ -20,7 +20,13 @@ class Thor
|
|
20
20
|
# inherited paths and the source root.
|
21
21
|
#
|
22
22
|
def source_paths
|
23
|
-
@
|
23
|
+
@_source_paths ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
# Stores and return the source root for this class
|
27
|
+
def source_root(path=nil)
|
28
|
+
@_source_root = path if path
|
29
|
+
@_source_root
|
24
30
|
end
|
25
31
|
|
26
32
|
# Returns the source paths in the following order:
|
@@ -32,7 +38,7 @@ class Thor
|
|
32
38
|
def source_paths_for_search
|
33
39
|
paths = []
|
34
40
|
paths += self.source_paths
|
35
|
-
paths << self.source_root if self.
|
41
|
+
paths << self.source_root if self.source_root
|
36
42
|
paths += from_superclass(:source_paths, [])
|
37
43
|
paths
|
38
44
|
end
|
@@ -126,12 +132,19 @@ class Thor
|
|
126
132
|
return source_file if File.exists?(source_file)
|
127
133
|
end
|
128
134
|
|
135
|
+
message = "Could not find #{file.inspect} in any of your source paths. "
|
136
|
+
|
137
|
+
unless self.class.source_root
|
138
|
+
message << "Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. "
|
139
|
+
end
|
140
|
+
|
129
141
|
if source_paths.empty?
|
130
|
-
|
131
|
-
"you can define a source_root in your class."
|
142
|
+
message << "Currently you have no source paths."
|
132
143
|
else
|
133
|
-
|
144
|
+
message << "Your current source paths are: \n#{source_paths.join("\n")}"
|
134
145
|
end
|
146
|
+
|
147
|
+
raise Error, message
|
135
148
|
end
|
136
149
|
|
137
150
|
# Do something in the root or on a provided subfolder. If a relative path
|
data/lib/thor/version.rb
CHANGED
@@ -37,7 +37,7 @@ describe Thor::Actions::Directory do
|
|
37
37
|
it "raises an error if the source does not exist" do
|
38
38
|
lambda {
|
39
39
|
invoke! "unknown"
|
40
|
-
}.must raise_error(Thor::Error, /Could not find "unknown" in source paths/)
|
40
|
+
}.must raise_error(Thor::Error, /Could not find "unknown" in any of your source paths/)
|
41
41
|
end
|
42
42
|
|
43
43
|
it "copies the whole directory recursively to the default destination" do
|
data/spec/actions_spec.rb
CHANGED
@@ -107,7 +107,7 @@ describe Thor::Actions do
|
|
107
107
|
it "raises an error if source path is empty" do
|
108
108
|
lambda {
|
109
109
|
A.new.find_in_source_paths("foo")
|
110
|
-
}.must raise_error(Thor::Error, /
|
110
|
+
}.must raise_error(Thor::Error, /Currently you have no source paths/)
|
111
111
|
end
|
112
112
|
|
113
113
|
it "finds a template inside the source path" do
|
data/spec/fixtures/group.thor
CHANGED
@@ -6,9 +6,7 @@ class MyCounter < Thor::Group
|
|
6
6
|
from_superclass(:get_from_super, 13)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
File.expand_path(File.dirname(__FILE__))
|
11
|
-
end
|
9
|
+
source_root File.expand_path(File.dirname(__FILE__))
|
12
10
|
source_paths << File.expand_path("broken", File.dirname(__FILE__))
|
13
11
|
|
14
12
|
argument :first, :type => :numeric
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 13
|
8
|
-
-
|
9
|
-
version: 0.13.
|
8
|
+
- 6
|
9
|
+
version: 0.13.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Yehuda Katz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-04-
|
18
|
+
date: 2010-04-30 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|