padrino-gen 0.10.7 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/padrino-gen/generators/actions.rb +139 -102
- data/lib/padrino-gen/generators/app/app.rb.tt +55 -53
- data/lib/padrino-gen/generators/app.rb +16 -16
- data/lib/padrino-gen/generators/cli.rb +3 -3
- data/lib/padrino-gen/generators/components/actions.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/activerecord.rb +22 -18
- data/lib/padrino-gen/generators/components/orms/couchrest.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/datamapper.rb +2 -1
- data/lib/padrino-gen/generators/components/orms/{mini_record.rb → minirecord.rb} +9 -9
- data/lib/padrino-gen/generators/components/orms/mongoid.rb +60 -6
- data/lib/padrino-gen/generators/components/orms/mongomapper.rb +2 -2
- data/lib/padrino-gen/generators/components/orms/mongomatic.rb +2 -2
- data/lib/padrino-gen/generators/components/orms/ohm.rb +57 -10
- data/lib/padrino-gen/generators/components/orms/ripple.rb +1 -1
- data/lib/padrino-gen/generators/components/orms/sequel.rb +15 -6
- data/lib/padrino-gen/generators/components/stylesheets/compass.rb +1 -1
- data/lib/padrino-gen/generators/components/stylesheets/less.rb +1 -0
- data/lib/padrino-gen/generators/components/tests/bacon.rb +0 -2
- data/lib/padrino-gen/generators/components/tests/minitest.rb +0 -1
- data/lib/padrino-gen/generators/components/tests/riot.rb +0 -1
- data/lib/padrino-gen/generators/components/tests/rspec.rb +14 -15
- data/lib/padrino-gen/generators/components/tests/shoulda.rb +0 -1
- data/lib/padrino-gen/generators/components/tests/testspec.rb +0 -1
- data/lib/padrino-gen/generators/controller.rb +14 -11
- data/lib/padrino-gen/generators/mailer.rb +14 -11
- data/lib/padrino-gen/generators/migration.rb +5 -5
- data/lib/padrino-gen/generators/model.rb +8 -7
- data/lib/padrino-gen/generators/plugin.rb +15 -9
- data/lib/padrino-gen/generators/project/.gitignore +2 -1
- data/lib/padrino-gen/generators/project/config/apps.rb.tt +10 -8
- data/lib/padrino-gen/generators/project/config.ru +0 -0
- data/lib/padrino-gen/generators/project/public/favicon.ico +0 -0
- data/lib/padrino-gen/generators/project.rb +53 -25
- data/lib/padrino-gen/generators/runner.rb +1 -1
- data/lib/padrino-gen/generators/templates/Gemfile.tt +8 -3
- data/lib/padrino-gen/generators/templates/Rakefile.tt +8 -0
- data/lib/padrino-gen/generators/templates/controller.rb.tt +8 -9
- data/lib/padrino-gen/generators/templates/gem/README.md.tt +29 -0
- data/lib/padrino-gen/generators/templates/gem/gemspec.tt +19 -0
- data/lib/padrino-gen/generators/templates/gem/lib/libname/version.tt +3 -0
- data/lib/padrino-gen/generators/templates/gem/lib/libname.tt +6 -0
- data/lib/padrino-gen/generators/templates/helper.rb.tt +1 -1
- data/lib/padrino-gen/generators/templates/mailer.rb.tt +1 -1
- data/lib/padrino-gen/generators/templates/static/js/dojo.js +238 -1
- data/lib/padrino-gen/generators/templates/static/js/ext.js +38 -1
- data/lib/padrino-gen/generators/templates/static/js/jquery.js +4 -4
- data/lib/padrino-gen/generators/templates/static/js/mootools.js +335 -276
- data/lib/padrino-gen/generators/templates/static/js/protopak.js +1 -1
- data/lib/padrino-gen/generators/templates/static/js/right.js +7 -1
- data/lib/padrino-gen/generators/templates/static/ujs/jquery.js +76 -75
- data/lib/padrino-gen/padrino-tasks/activerecord.rb +8 -2
- data/lib/padrino-gen/padrino-tasks/database.rb +11 -0
- data/lib/padrino-gen/padrino-tasks/datamapper.rb +38 -12
- data/lib/padrino-gen/padrino-tasks/minirecord.rb +19 -0
- data/lib/padrino-gen/padrino-tasks/mongoid.rb +76 -18
- data/lib/padrino-gen/padrino-tasks/mongomapper.rb +9 -1
- data/lib/padrino-gen/padrino-tasks/sequel.rb +6 -1
- data/lib/padrino-gen.rb +2 -2
- data/padrino-gen.gemspec +0 -0
- data/test/helper.rb +1 -1
- data/test/test_app_generator.rb +23 -4
- data/test/test_controller_generator.rb +8 -8
- data/test/test_mailer_generator.rb +5 -5
- data/test/test_model_generator.rb +26 -23
- data/test/test_plugin_generator.rb +23 -0
- data/test/test_project_generator.rb +82 -47
- metadata +17 -17
- data/lib/padrino-gen/padrino-tasks/seed.rb +0 -5
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a6a1654d8ee352072e435cb364d88153983be16
|
4
|
+
data.tar.gz: 42ca8996ee141fa779627859b7d95e454d5ef3b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1ac55f683cba6782dc31abcb5e8732f45ced510600415b0ee2d0681b32cdfcd703526ff2136651bb2d70192db37dd47a02ebfa3624a956766b33fbcae27e2ff3
|
7
|
+
data.tar.gz: 95d1e97c9a31b4d25290305f6fc45ca8ca14afe03e20949a14eecd203100fbdd1d3952238fea09a71d9e28f3637ed59641f0cda8e508c97d2fbecb7699fc716a
|
@@ -11,12 +11,12 @@ module Padrino
|
|
11
11
|
base.extend(ClassMethods)
|
12
12
|
end
|
13
13
|
|
14
|
-
# Performs the necessary generator for a given component choice
|
14
|
+
# Performs the necessary generator for a given component choice.
|
15
15
|
#
|
16
16
|
# @param [Symbol] component
|
17
|
-
# The type of component module
|
17
|
+
# The type of component module.
|
18
18
|
# @param [String] choice
|
19
|
-
# The name of the component module choice
|
19
|
+
# The name of the component module choice.
|
20
20
|
#
|
21
21
|
# @example
|
22
22
|
# execute_component_setup(:mock, 'rr')
|
@@ -29,19 +29,19 @@ module Padrino
|
|
29
29
|
send("setup_#{component}") if respond_to?("setup_#{component}")
|
30
30
|
end
|
31
31
|
|
32
|
-
# Returns the related module for a given component and option
|
32
|
+
# Returns the related module for a given component and option.
|
33
33
|
#
|
34
34
|
# @param [String] choice
|
35
|
-
# The name of the component module
|
35
|
+
# The name of the component module.
|
36
36
|
# @param [Symbol] component
|
37
|
-
# The type of the component module
|
37
|
+
# The type of the component module.
|
38
38
|
#
|
39
39
|
# @example
|
40
40
|
# generator_module_for('rr', :mock)
|
41
41
|
#
|
42
42
|
# @api private
|
43
43
|
def apply_component_for(choice, component)
|
44
|
-
# I need to override Thor#apply because for unknow reason :
|
44
|
+
# I need to override Thor#apply because for unknow reason :verbose => false break tasks.
|
45
45
|
path = File.expand_path(File.dirname(__FILE__) + "/components/#{component.to_s.pluralize}/#{choice}.rb")
|
46
46
|
say_status :apply, "#{component.to_s.pluralize}/#{choice}"
|
47
47
|
shell.padding += 1
|
@@ -49,13 +49,13 @@ module Padrino
|
|
49
49
|
shell.padding -= 1
|
50
50
|
end
|
51
51
|
|
52
|
-
# Includes the component module for the given component and choice
|
53
|
-
#
|
52
|
+
# Includes the component module for the given component and choice.
|
53
|
+
# It determines the choice using .components file.
|
54
54
|
#
|
55
55
|
# @param [Symbol] component
|
56
|
-
# The type of component module
|
56
|
+
# The type of component module.
|
57
57
|
# @param [String] choice
|
58
|
-
# The name of the component module
|
58
|
+
# The name of the component module.
|
59
59
|
#
|
60
60
|
# @example
|
61
61
|
# include_component_module_for(:mock)
|
@@ -68,12 +68,12 @@ module Padrino
|
|
68
68
|
apply_component_for(choice, component)
|
69
69
|
end
|
70
70
|
|
71
|
-
# Returns the component choice stored within the .component file of an application
|
71
|
+
# Returns the component choice stored within the .component file of an application.
|
72
72
|
#
|
73
73
|
# @param [Symbol] component
|
74
|
-
# The type of component module
|
74
|
+
# The type of component module.
|
75
75
|
#
|
76
|
-
# @return [String] Name of the component module
|
76
|
+
# @return [String] Name of the component module.
|
77
77
|
#
|
78
78
|
# @example
|
79
79
|
# fetch_component_choice(:mock)
|
@@ -83,14 +83,14 @@ module Padrino
|
|
83
83
|
retrieve_component_config(destination_root('.components'))[component]
|
84
84
|
end
|
85
85
|
|
86
|
-
# Set the component choice
|
86
|
+
# Set the component choice in the .component file of the application.
|
87
87
|
#
|
88
88
|
# @param [Symbol] key
|
89
|
-
# The type of component module
|
89
|
+
# The type of component module.
|
90
90
|
# @param [Symbol] value
|
91
|
-
# The name of the component module
|
91
|
+
# The name of the component module.
|
92
92
|
#
|
93
|
-
# @return [Symbol]
|
93
|
+
# @return [Symbol] The name of the component module.
|
94
94
|
#
|
95
95
|
# @example
|
96
96
|
# store_component_choice(:renderer, :haml)
|
@@ -104,12 +104,12 @@ module Padrino
|
|
104
104
|
value
|
105
105
|
end
|
106
106
|
|
107
|
-
# Loads the component config back into a hash
|
107
|
+
# Loads the component config back into a hash.
|
108
108
|
#
|
109
109
|
# @param [String] target
|
110
|
-
# Path to component config file
|
110
|
+
# Path to component config file.
|
111
111
|
#
|
112
|
-
# @return [Hash] Loaded YAML file
|
112
|
+
# @return [Hash] Loaded YAML file.
|
113
113
|
#
|
114
114
|
# @example
|
115
115
|
# retrieve_component_config(...)
|
@@ -120,15 +120,15 @@ module Padrino
|
|
120
120
|
YAML.load_file(target)
|
121
121
|
end
|
122
122
|
|
123
|
-
# Prompts the user if necessary until a valid choice is returned for the component
|
123
|
+
# Prompts the user if necessary until a valid choice is returned for the component.
|
124
124
|
#
|
125
125
|
# @param [Symbol] component
|
126
|
-
# The type of component module
|
126
|
+
# The type of component module.
|
127
127
|
#
|
128
128
|
# @return [String] Name of component if valid, otherwise ask for valid choice.
|
129
129
|
#
|
130
130
|
# @example
|
131
|
-
# resolve_valid_choice(:mock)
|
131
|
+
# resolve_valid_choice(:mock)
|
132
132
|
#
|
133
133
|
# @api private
|
134
134
|
def resolve_valid_choice(component)
|
@@ -141,31 +141,31 @@ module Padrino
|
|
141
141
|
choice
|
142
142
|
end
|
143
143
|
|
144
|
-
# Returns true if the option passed is a valid choice for component
|
144
|
+
# Returns true if the option passed is a valid choice for component.
|
145
145
|
#
|
146
146
|
# @param [Symbol] component
|
147
|
-
# The type of component module
|
147
|
+
# The type of component module.
|
148
148
|
# @param [String] choice
|
149
|
-
# The name of the component module
|
149
|
+
# The name of the component module.
|
150
150
|
#
|
151
151
|
# @return [Boolean] Boolean of whether the choice is valid.
|
152
152
|
#
|
153
153
|
# @example
|
154
|
-
# valid_choice?(:mock, 'rr')
|
154
|
+
# valid_choice?(:mock, 'rr')
|
155
155
|
#
|
156
156
|
# @api public
|
157
157
|
def valid_choice?(component, choice)
|
158
158
|
choice.present? && self.class.available_choices_for(component).include?(choice.to_sym)
|
159
159
|
end
|
160
160
|
|
161
|
-
# Creates a component_config file at the destination containing all component options
|
162
|
-
# Content is a
|
161
|
+
# Creates a component_config file at the destination containing all component options.
|
162
|
+
# Content is a YAMLized version of a hash containing component name mapping to chosen value.
|
163
163
|
#
|
164
164
|
# @param [String] destination
|
165
165
|
# The file path to store the component config.
|
166
166
|
#
|
167
167
|
# @example
|
168
|
-
# store_component_config
|
168
|
+
# store_component_config('/foo/bar')
|
169
169
|
#
|
170
170
|
# @api private
|
171
171
|
def store_component_config(destination)
|
@@ -185,26 +185,21 @@ module Padrino
|
|
185
185
|
# @return [String] The full path
|
186
186
|
#
|
187
187
|
# @example
|
188
|
-
# destination_root
|
188
|
+
# destination_root('config/boot.rb')
|
189
189
|
#
|
190
190
|
# @api public
|
191
191
|
def destination_root(*paths)
|
192
192
|
File.expand_path(File.join(@destination_stack.last, paths))
|
193
193
|
end
|
194
194
|
|
195
|
-
# Returns true if inside a Padrino application
|
196
|
-
#
|
197
|
-
# @return [Boolean] Boolean if in app root
|
198
|
-
#
|
199
|
-
# @example
|
200
|
-
# in_app_root? => true
|
195
|
+
# Returns true if inside a Padrino application.
|
201
196
|
#
|
202
197
|
# @api public
|
203
198
|
def in_app_root?
|
204
199
|
File.exist?(destination_root('config/boot.rb'))
|
205
200
|
end
|
206
201
|
|
207
|
-
# Returns the field with an unacceptable name(for symbol) else returns nil
|
202
|
+
# Returns the field with an unacceptable name(for symbol) else returns nil.
|
208
203
|
#
|
209
204
|
# @param [Array<String>] fields
|
210
205
|
# Field names for generators
|
@@ -220,16 +215,57 @@ module Padrino
|
|
220
215
|
results.empty? ? nil : results
|
221
216
|
end
|
222
217
|
|
223
|
-
#
|
218
|
+
# Apply default field types.
|
219
|
+
#
|
220
|
+
# @param [Array<String>] fields
|
221
|
+
# Field names for generators
|
222
|
+
#
|
223
|
+
# @return [Array<String>] fields with default types
|
224
|
+
#
|
225
|
+
# @api semipublic
|
226
|
+
def apply_default_fields(fields)
|
227
|
+
fields.map! { |field| field =~ /:/ ? field : "#{field}:string" }
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns the namespace for the project.
|
224
231
|
#
|
225
232
|
# @param [String] app
|
226
|
-
# folder name of application
|
233
|
+
# folder name of application.
|
227
234
|
#
|
228
|
-
# @return [String]
|
235
|
+
# @return [String] namespace for application.
|
229
236
|
#
|
230
237
|
# @example
|
231
|
-
#
|
232
|
-
#
|
238
|
+
# fetch_project_name
|
239
|
+
#
|
240
|
+
# @api public
|
241
|
+
def fetch_project_name(app='app')
|
242
|
+
app_path = destination_root(app, 'app.rb')
|
243
|
+
@project_name = fetch_component_choice(:namespace) if @project_name.empty?
|
244
|
+
@project_name ||= begin
|
245
|
+
say "Autodetecting project namespace using folder name.", :red
|
246
|
+
say ""
|
247
|
+
detected_namespace = File.basename(destination_root('.')).gsub(/\W/, '_').camelize
|
248
|
+
say(<<-WARNING, :red)
|
249
|
+
From v0.11.0 on, applications should have a `namespace` setting
|
250
|
+
in their .components file. Please include a line like the following
|
251
|
+
in your .components file:
|
252
|
+
WARNING
|
253
|
+
say "\t:namespace: #{detected_namespace}", :yellow
|
254
|
+
say ""
|
255
|
+
|
256
|
+
detected_namespace
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# Returns the app_name for the application at root.
|
261
|
+
#
|
262
|
+
# @param [String] app
|
263
|
+
# folder name of application.
|
264
|
+
#
|
265
|
+
# @return [String] class name for application.
|
266
|
+
#
|
267
|
+
# @example
|
268
|
+
# fetch_app_name('subapp')
|
233
269
|
#
|
234
270
|
# @api public
|
235
271
|
def fetch_app_name(app='app')
|
@@ -237,17 +273,17 @@ module Padrino
|
|
237
273
|
@app_name ||= File.read(app_path).scan(/class\s(.*?)\s</).flatten[0]
|
238
274
|
end
|
239
275
|
|
240
|
-
# Adds all the specified gems into the Gemfile for bundler
|
276
|
+
# Adds all the specified gems into the Gemfile for bundler.
|
241
277
|
#
|
242
278
|
# @param [Array<String>] gem_names
|
243
|
-
# Splat of gems to require in
|
279
|
+
# Splat of gems to require in Gemfile.
|
244
280
|
# @param [Hash] options
|
245
|
-
# The options to pass to gem in
|
281
|
+
# The options to pass to gem in Gemfile.
|
246
282
|
#
|
247
283
|
# @example
|
248
|
-
# require_dependencies
|
249
|
-
# require_dependencies
|
250
|
-
# require_dependencies
|
284
|
+
# require_dependencies('active_record')
|
285
|
+
# require_dependencies('mocha', 'bacon', :group => 'test')
|
286
|
+
# require_dependencies('json', :version => ">=1.2.3")
|
251
287
|
#
|
252
288
|
# @api public
|
253
289
|
def require_dependencies(*gem_names)
|
@@ -255,12 +291,12 @@ module Padrino
|
|
255
291
|
gem_names.reverse.each { |lib| insert_into_gemfile(lib, options) }
|
256
292
|
end
|
257
293
|
|
258
|
-
# Inserts a required gem into the Gemfile to add the bundler dependency
|
294
|
+
# Inserts a required gem into the Gemfile to add the bundler dependency.
|
259
295
|
#
|
260
296
|
# @param [String] name
|
261
|
-
# Name of gem to insert into Gemfile
|
297
|
+
# Name of gem to insert into Gemfile.
|
262
298
|
# @param [Hash] options
|
263
|
-
# Options to generate into Gemfile for gem
|
299
|
+
# Options to generate into Gemfile for gem.
|
264
300
|
#
|
265
301
|
# @example
|
266
302
|
# insert_into_gemfile(name)
|
@@ -270,20 +306,20 @@ module Padrino
|
|
270
306
|
# @api public
|
271
307
|
def insert_into_gemfile(name, options={})
|
272
308
|
after_pattern = options[:group] ? "#{options[:group].to_s.capitalize} requirements\n" : "Component requirements\n"
|
273
|
-
version
|
274
|
-
gem_options = options.map { |k, v| "
|
275
|
-
write_option
|
276
|
-
write_version = version.present? ? ", #{version.
|
277
|
-
include_text = "gem '#{name}'"<< write_version << write_option << "\n"
|
309
|
+
version = options.delete(:version)
|
310
|
+
gem_options = options.map { |k, v| ":#{k} => '#{v.to_s}'" }.join(", ")
|
311
|
+
write_option = gem_options.present? ? ", #{gem_options}" : ''
|
312
|
+
write_version = version.present? ? ", '#{version.to_s}'" : ''
|
313
|
+
include_text = "gem '#{name}'" << write_version << write_option << "\n"
|
278
314
|
inject_into_file('Gemfile', include_text, :after => after_pattern)
|
279
315
|
end
|
280
316
|
|
281
|
-
# Inserts an hook before or after load in our boot.rb
|
317
|
+
# Inserts an hook before or after load in our boot.rb.
|
282
318
|
#
|
283
319
|
# @param [String] include_text
|
284
|
-
# Text to include into hooks in boot.rb
|
320
|
+
# Text to include into hooks in boot.rb.
|
285
321
|
# @param [Symbol] where
|
286
|
-
# method hook to call from Padrino, i.e :after_load, :before_load
|
322
|
+
# method hook to call from Padrino, i.e :after_load, :before_load.
|
287
323
|
#
|
288
324
|
# @example
|
289
325
|
# insert_hook("DataMapper.finalize", :after_load)
|
@@ -293,10 +329,10 @@ module Padrino
|
|
293
329
|
inject_into_file('config/boot.rb', " #{include_text}\n", :after => "Padrino.#{where} do\n")
|
294
330
|
end
|
295
331
|
|
296
|
-
# Inserts a
|
332
|
+
# Inserts a middleware inside app.rb.
|
297
333
|
#
|
298
334
|
# @param [String] include_text
|
299
|
-
# Text to include into hooks in boot.rb
|
335
|
+
# Text to include into hooks in boot.rb.
|
300
336
|
#
|
301
337
|
# @example
|
302
338
|
# insert_middleware(ActiveRecord::ConnectionAdapters::ConnectionManagement)
|
@@ -304,23 +340,24 @@ module Padrino
|
|
304
340
|
# @api public
|
305
341
|
def insert_middleware(include_text, app=nil)
|
306
342
|
name = app || (options[:name].present? ? @app_name.downcase : 'app')
|
307
|
-
inject_into_file("#{name}/app.rb", "
|
343
|
+
inject_into_file("#{name}/app.rb", " use #{include_text}\n", :after => "Padrino::Application\n")
|
308
344
|
end
|
309
345
|
|
310
|
-
# Registers and
|
346
|
+
# Registers and creates initializer.
|
311
347
|
#
|
312
348
|
# @param [Symbol] name
|
313
|
-
# Name of the initializer
|
349
|
+
# Name of the initializer.
|
314
350
|
# @param [String] data
|
315
|
-
# Text to generate into the initializer file
|
351
|
+
# Text to generate into the initializer file.
|
316
352
|
#
|
317
353
|
# @example
|
318
|
-
# initializer
|
354
|
+
# initializer(:test, "some stuff here")
|
355
|
+
# #=> generates 'lib/test_init.rb'
|
319
356
|
#
|
320
357
|
# @api public
|
321
358
|
def initializer(name, data=nil)
|
322
359
|
@_init_name, @_init_data = name, data
|
323
|
-
register = data.present? ? "
|
360
|
+
register = data.present? ? " register #{name.to_s.underscore.camelize}Initializer\n" : " register #{name}\n"
|
324
361
|
inject_into_file destination_root("/app/app.rb"), register, :after => "Padrino::Application\n"
|
325
362
|
template "templates/initializer.rb.tt", destination_root("/lib/#{name}_init.rb") if data.present?
|
326
363
|
end
|
@@ -331,7 +368,7 @@ module Padrino
|
|
331
368
|
# name of library from padrino-contrib
|
332
369
|
#
|
333
370
|
# @example
|
334
|
-
# require_contrib
|
371
|
+
# require_contrib('auto_locale')
|
335
372
|
#
|
336
373
|
# @api public
|
337
374
|
def require_contrib(contrib)
|
@@ -340,36 +377,36 @@ module Padrino
|
|
340
377
|
inject_into_file destination_root("/config/boot.rb"), contrib, :before => "\nPadrino.load!"
|
341
378
|
end
|
342
379
|
|
343
|
-
# Return true if our project has test component
|
380
|
+
# Return true if our project has test component.
|
344
381
|
#
|
345
382
|
# @api public
|
346
383
|
def test?
|
347
384
|
fetch_component_choice(:test).to_s != 'none'
|
348
385
|
end
|
349
386
|
|
350
|
-
# Return true if we have a tiny skeleton
|
387
|
+
# Return true if we have a tiny skeleton.
|
351
388
|
#
|
352
389
|
# @api public
|
353
390
|
def tiny?
|
354
|
-
File.exist?(destination_root(
|
391
|
+
File.exist?(destination_root('app/controllers.rb'))
|
355
392
|
end
|
356
393
|
|
357
|
-
# Run the bundler
|
394
|
+
# Run the bundler.
|
358
395
|
#
|
359
396
|
# @api semipublic
|
360
397
|
def run_bundler
|
361
|
-
say
|
398
|
+
say 'Bundling application dependencies using bundler...', :yellow
|
362
399
|
in_root { run 'bundle install' }
|
363
400
|
end
|
364
401
|
|
365
402
|
# Ask something to the user and receives a response.
|
366
403
|
#
|
367
404
|
# @param [String] statement
|
368
|
-
# String of statement to display for input
|
405
|
+
# String of statement to display for input.
|
369
406
|
# @param [String] default
|
370
|
-
# Default value for input
|
407
|
+
# Default value for input.
|
371
408
|
# @param [String] color
|
372
|
-
# Name of color to display input
|
409
|
+
# Name of color to display input.
|
373
410
|
#auto_locale
|
374
411
|
# @return [String] Input value
|
375
412
|
#
|
@@ -385,10 +422,10 @@ module Padrino
|
|
385
422
|
result.blank? ? default : result
|
386
423
|
end
|
387
424
|
|
388
|
-
# Raise SystemExit if the app
|
425
|
+
# Raise SystemExit if the app does not exist.
|
389
426
|
#
|
390
427
|
# @param [String] app
|
391
|
-
#
|
428
|
+
# Directory name of application.
|
392
429
|
#
|
393
430
|
# @example
|
394
431
|
# check_app_existence 'app'
|
@@ -401,16 +438,16 @@ module Padrino
|
|
401
438
|
say "Unable to locate '#{app.underscore.camelize}' application "
|
402
439
|
say "================================================================="
|
403
440
|
say
|
404
|
-
|
441
|
+
raise SystemExit
|
405
442
|
end
|
406
443
|
end
|
407
444
|
|
408
|
-
# Generates standard and tiny applications within a project
|
445
|
+
# Generates standard and tiny applications within a project.
|
409
446
|
#
|
410
447
|
# @param [String] app
|
411
|
-
#
|
448
|
+
# Name of application.
|
412
449
|
# @param [Boolean] tiny
|
413
|
-
# Boolean to generate a tiny structure
|
450
|
+
# Boolean to generate a tiny structure.
|
414
451
|
#
|
415
452
|
# @example
|
416
453
|
# app_skeleton 'some_app'
|
@@ -418,12 +455,12 @@ module Padrino
|
|
418
455
|
#
|
419
456
|
# @api private
|
420
457
|
def app_skeleton(app, tiny=false)
|
421
|
-
directory(
|
458
|
+
directory('app/', destination_root(app))
|
422
459
|
if tiny # generate tiny structure
|
423
|
-
template
|
424
|
-
template
|
460
|
+
template 'templates/controller.rb.tt', destination_root(app, 'controllers.rb')
|
461
|
+
template 'templates/helper.rb.tt', destination_root(app, 'helpers.rb')
|
425
462
|
@short_name = 'notifier'
|
426
|
-
template
|
463
|
+
template 'templates/mailer.rb.tt', destination_root(app, 'mailers.rb')
|
427
464
|
else # generate standard folders
|
428
465
|
empty_directory destination_root(app, 'controllers')
|
429
466
|
empty_directory destination_root(app, 'helpers')
|
@@ -432,12 +469,12 @@ module Padrino
|
|
432
469
|
end
|
433
470
|
end
|
434
471
|
|
435
|
-
# Ensure that project name is valid, else raise an NameError
|
472
|
+
# Ensure that project name is valid, else raise an NameError.
|
436
473
|
#
|
437
474
|
# @param [String] name
|
438
475
|
# name of project
|
439
476
|
#
|
440
|
-
# @return [Exception] Exception with error
|
477
|
+
# @return [Exception] Exception with error message if not valid.
|
441
478
|
#
|
442
479
|
# @example
|
443
480
|
# valid_constant '1235Stuff'
|
@@ -454,15 +491,15 @@ module Padrino
|
|
454
491
|
|
455
492
|
# Class methods for Thor generators to support the generators and component choices.
|
456
493
|
module ClassMethods
|
457
|
-
# Defines a class option to allow a component to be chosen and add to component type list
|
458
|
-
# Also builds the available_choices hash of which component choices are supported
|
494
|
+
# Defines a class option to allow a component to be chosen and add to component type list.
|
495
|
+
# Also builds the available_choices hash of which component choices are supported.
|
459
496
|
#
|
460
497
|
# @param [Symbol] name
|
461
|
-
# Name of component
|
498
|
+
# Name of component.
|
462
499
|
# @param [String] caption
|
463
|
-
# Description of the component
|
500
|
+
# Description of the component.
|
464
501
|
# @param [Hash] options
|
465
|
-
# Additional parameters for component choice
|
502
|
+
# Additional parameters for component choice.
|
466
503
|
#
|
467
504
|
# @example
|
468
505
|
# component_option :test, "Testing framework", :aliases => '-t', :choices => [:bacon, :shoulda]
|
@@ -475,33 +512,33 @@ module Padrino
|
|
475
512
|
class_option name, :default => options[:default] || options[:choices].first, :aliases => options[:aliases], :desc => description
|
476
513
|
end
|
477
514
|
|
478
|
-
# Tell
|
515
|
+
# Tell Padrino that for this Thor::Group it is a necessary task to run.
|
479
516
|
#
|
480
517
|
# @api private
|
481
518
|
def require_arguments!
|
482
519
|
@require_arguments = true
|
483
520
|
end
|
484
521
|
|
485
|
-
# Return true if we need an arguments for our Thor::Group
|
522
|
+
# Return true if we need an arguments for our Thor::Group.
|
486
523
|
#
|
487
524
|
# @api private
|
488
525
|
def require_arguments?
|
489
526
|
@require_arguments
|
490
527
|
end
|
491
528
|
|
492
|
-
# Returns the compiled list of component types which can be specified
|
529
|
+
# Returns the compiled list of component types which can be specified.
|
493
530
|
#
|
494
531
|
# @api private
|
495
532
|
def component_types
|
496
533
|
@component_types
|
497
534
|
end
|
498
535
|
|
499
|
-
# Returns the list of available choices for the given component (including none)
|
536
|
+
# Returns the list of available choices for the given component (including none).
|
500
537
|
#
|
501
538
|
# @param [Symbol] component
|
502
|
-
# The type of the component module
|
539
|
+
# The type of the component module.
|
503
540
|
#
|
504
|
-
# @return [Array<Symbol>] Array of component choices
|
541
|
+
# @return [Array<Symbol>] Array of component choices.
|
505
542
|
#
|
506
543
|
# @example
|
507
544
|
# available_choices_for :test
|
@@ -511,7 +548,7 @@ module Padrino
|
|
511
548
|
def available_choices_for(component)
|
512
549
|
@available_choices[component] + [:none]
|
513
550
|
end
|
514
|
-
end
|
551
|
+
end # ClassMethods
|
515
552
|
end # Actions
|
516
553
|
end # Generators
|
517
554
|
end # Padrino
|