sprout 1.1.4.pre → 1.1.5.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4.pre
1
+ 1.1.5.pre
@@ -209,8 +209,6 @@ module Sprout
209
209
  create_search_paths.select { |path| File.directory?(path) }
210
210
  end
211
211
 
212
- private
213
-
214
212
  def create_search_paths
215
213
  paths = [
216
214
  File.join('config', 'generators'),
@@ -221,6 +219,8 @@ module Sprout
221
219
  paths
222
220
  end
223
221
 
222
+ private
223
+
224
224
  ##
225
225
  # I know this seems weird - but we can't instantiate the classes
226
226
  # during registration because they register before they've been fully
@@ -30,6 +30,11 @@ module Sprout
30
30
  # status to standard output.
31
31
  add_param :quiet, Boolean
32
32
 
33
+ ##
34
+ # Display the paths this generator will use to look
35
+ # for templates on this system and exit.
36
+ add_param :show_template_paths, Boolean
37
+
33
38
  ##
34
39
  # A collection of paths to look in for named templates.
35
40
  add_param :templates, Paths
@@ -72,10 +77,16 @@ module Sprout
72
77
  ##
73
78
  # Record the actions and trigger them
74
79
  def execute
80
+ return do_show_template_paths if show_template_paths
75
81
  return prepare_command.unexecute if destroy
76
82
  prepare_command.execute
77
83
  end
78
84
 
85
+ def validate
86
+ return true if show_template_paths
87
+ super
88
+ end
89
+
79
90
  ##
80
91
  # Rollback the generator
81
92
  def unexecute
@@ -105,12 +116,32 @@ module Sprout
105
116
  # Sprout::Generator.search_paths + 'templates' folders.
106
117
  #
107
118
  def template_paths
108
- templates << Sprout::Generator::template_folder_for(self)
109
- templates.concat default_search_paths
119
+ create_template_paths
120
+ end
121
+
122
+ def create_template_paths
123
+ paths = templates.dup
124
+ paths = paths.concat Sprout::Generator.search_paths
125
+ paths << Sprout::Generator::template_folder_for(self)
110
126
  end
111
127
 
112
128
  protected
113
129
 
130
+ def do_show_template_paths
131
+ @logger ||= $stdout
132
+ message = "The following paths will be checked for templates:\n"
133
+
134
+ paths = ["--templates+=[value]"]
135
+ paths = paths.concat Sprout::Generator.create_search_paths
136
+ paths << "ENV['SPROUT_GENERATORS']"
137
+ paths << Sprout::Generator::template_folder_for(self)
138
+
139
+ message << " * "
140
+ message << paths.join("\n * ")
141
+ say message
142
+ message
143
+ end
144
+
114
145
  def default_search_paths
115
146
  Sprout::Generator.search_paths.collect { |path| File.join(path, 'templates') }
116
147
  end
@@ -58,6 +58,13 @@ class GeneratorTest < Test::Unit::TestCase
58
58
  end
59
59
  end
60
60
 
61
+ should "show template paths and nothing else" do
62
+ @generator.parse! ['--show-template-paths']
63
+ output = @generator.execute
64
+
65
+ assert_equal 7, output.split("\n").size
66
+ end
67
+
61
68
  should "not clobber existing files" do
62
69
  dir = File.join(@fixture, 'some_project', 'src')
63
70
  FileUtils.mkdir_p dir
@@ -149,7 +156,7 @@ class GeneratorTest < Test::Unit::TestCase
149
156
  end
150
157
 
151
158
  should "not update superclass parameter collection" do
152
- assert_equal 6, Sprout::Generator::Base.static_parameter_collection.size
159
+ assert_equal 7, Sprout::Generator::Base.static_parameter_collection.size
153
160
  assert_equal 1, Sprout::Generator::Base.static_default_value_collection.size
154
161
  end
155
162
 
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 4
8
+ - 5
9
9
  - pre
10
- version: 1.1.4.pre
10
+ version: 1.1.5.pre
11
11
  platform: ruby
12
12
  authors:
13
13
  - Luke Bayes