grippy-doozer 0.1.0
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/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +57 -0
- data/Rakefile +59 -0
- data/VERSION +1 -0
- data/bin/doozer +8 -0
- data/doozer.gemspec +114 -0
- data/lib/doozer/README.rb +40 -0
- data/lib/doozer/active_support/array.rb +14 -0
- data/lib/doozer/active_support/class.rb +221 -0
- data/lib/doozer/active_support/date_time.rb +23 -0
- data/lib/doozer/active_support/object.rb +43 -0
- data/lib/doozer/active_support/time.rb +32 -0
- data/lib/doozer/app.rb +265 -0
- data/lib/doozer/configs.rb +131 -0
- data/lib/doozer/controller.rb +335 -0
- data/lib/doozer/extend.rb +10 -0
- data/lib/doozer/initializer.rb +95 -0
- data/lib/doozer/lib.rb +32 -0
- data/lib/doozer/logger.rb +11 -0
- data/lib/doozer/orm/active_record.rb +19 -0
- data/lib/doozer/orm/data_mapper.rb +19 -0
- data/lib/doozer/orm/sequel.rb +18 -0
- data/lib/doozer/partial.rb +99 -0
- data/lib/doozer/plugins/paginate/init.rb +2 -0
- data/lib/doozer/plugins/paginate/lib/paginate/collection.rb +60 -0
- data/lib/doozer/plugins/paginate/lib/paginate/finder.rb +116 -0
- data/lib/doozer/plugins/paginate/lib/paginate/view_helpers.rb +37 -0
- data/lib/doozer/plugins/paginate/lib/paginate.rb +32 -0
- data/lib/doozer/rackup/server.ru +37 -0
- data/lib/doozer/rackup/test.rb +19 -0
- data/lib/doozer/redirect.rb +12 -0
- data/lib/doozer/route.rb +264 -0
- data/lib/doozer/scripts/cluster.rb +132 -0
- data/lib/doozer/scripts/migrate.rb +108 -0
- data/lib/doozer/scripts/task.rb +60 -0
- data/lib/doozer/scripts/test.rb +23 -0
- data/lib/doozer/version.rb +8 -0
- data/lib/doozer/view_helpers.rb +163 -0
- data/lib/doozer/watcher.rb +375 -0
- data/lib/doozer.rb +30 -0
- data/lib/generator/generator.rb +547 -0
- data/templates/skeleton/Rakefile +3 -0
- data/templates/skeleton/app/controllers/application_controller.rb +2 -0
- data/templates/skeleton/app/controllers/index_controller.rb +7 -0
- data/templates/skeleton/app/helpers/application_helper.rb +17 -0
- data/templates/skeleton/app/views/global/_header.html.erb +7 -0
- data/templates/skeleton/app/views/global/_navigation.html.erb +6 -0
- data/templates/skeleton/app/views/index/index.html.erb +108 -0
- data/templates/skeleton/app/views/layouts/default.html.erb +23 -0
- data/templates/skeleton/config/app.yml +31 -0
- data/templates/skeleton/config/database.yml +25 -0
- data/templates/skeleton/config/environment.rb +13 -0
- data/templates/skeleton/config/rack.rb +30 -0
- data/templates/skeleton/config/routes.rb +69 -0
- data/templates/skeleton/script/cluster +5 -0
- data/templates/skeleton/script/migrate +5 -0
- data/templates/skeleton/script/task +5 -0
- data/templates/skeleton/script/test +4 -0
- data/templates/skeleton/static/404.html +16 -0
- data/templates/skeleton/static/500.html +16 -0
- data/templates/skeleton/static/css/style.css +32 -0
- data/templates/skeleton/static/favicon.ico +0 -0
- data/templates/skeleton/static/js/application.js +1 -0
- data/templates/skeleton/static/js/jquery-1.3.min.js +19 -0
- data/templates/skeleton/static/robots.txt +5 -0
- data/templates/skeleton/test/fixtures/setup.rb +6 -0
- data/templates/skeleton/test/setup.rb +33 -0
- data/test/doozer_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +126 -0
@@ -0,0 +1,547 @@
|
|
1
|
+
module Doozer
|
2
|
+
|
3
|
+
#= Generate Project Skeletons and Files
|
4
|
+
class Generator
|
5
|
+
APP_PATH = Dir.pwd
|
6
|
+
PATH = File.expand_path( File.join(File.dirname(__FILE__), '..', '..', 'templates') )
|
7
|
+
|
8
|
+
def self.run(*args)
|
9
|
+
return help_all if args.empty?
|
10
|
+
|
11
|
+
action = args[0].downcase
|
12
|
+
if not ['generate', '-h', '--help', '-v', '--version'].include?(action)
|
13
|
+
skeleton(action)
|
14
|
+
else
|
15
|
+
if action == 'generate'
|
16
|
+
|
17
|
+
action = args[1]
|
18
|
+
case action.to_sym
|
19
|
+
when :model, :"-M"
|
20
|
+
if args.length == 3
|
21
|
+
name = args[2]
|
22
|
+
Doozer::Configs.load(:development)
|
23
|
+
model(Doozer::Configs.orm, name.downcase)
|
24
|
+
else
|
25
|
+
help?(:help, :model)
|
26
|
+
end
|
27
|
+
when :view, :"-V"
|
28
|
+
args.push('html') if args.length == 3
|
29
|
+
if args.length == 4
|
30
|
+
name = args[2]
|
31
|
+
formats = args[3].split(',')
|
32
|
+
view(name.downcase, formats)
|
33
|
+
else
|
34
|
+
help?(:help, :view)
|
35
|
+
end
|
36
|
+
when :controller, :"-C"
|
37
|
+
if args.length == 3
|
38
|
+
name = args[2]
|
39
|
+
controller(name.downcase)
|
40
|
+
else
|
41
|
+
help?(:help, :controller)
|
42
|
+
end
|
43
|
+
when :helper, :"-H"
|
44
|
+
if args.length == 3
|
45
|
+
name = args[2]
|
46
|
+
helper(name.downcase)
|
47
|
+
else
|
48
|
+
help?(:help, :helper)
|
49
|
+
end
|
50
|
+
when :db, :migrate, :migration, :"-D"
|
51
|
+
if args.length == 3
|
52
|
+
name = args[2]
|
53
|
+
Doozer::Configs.load(:development)
|
54
|
+
migrate(Doozer::Configs.orm, name.downcase)
|
55
|
+
else
|
56
|
+
help?(:help, :migrate)
|
57
|
+
end
|
58
|
+
when :task, :"-T"
|
59
|
+
if args.length == 3
|
60
|
+
name = args[2]
|
61
|
+
task(name.downcase)
|
62
|
+
else
|
63
|
+
help?(:help, :task)
|
64
|
+
end
|
65
|
+
else
|
66
|
+
help_all
|
67
|
+
end
|
68
|
+
elsif ['-v', '--version']
|
69
|
+
p "Doozer #{Doozer::Version::STRING}"
|
70
|
+
else
|
71
|
+
help_all
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.help_all
|
77
|
+
printf "Doozer Version: #{Doozer::Version::STRING}\n"
|
78
|
+
printf "Doozer commands:\n"
|
79
|
+
help(:project)
|
80
|
+
help(:model)
|
81
|
+
help(:view)
|
82
|
+
help(:controller)
|
83
|
+
help(:helper)
|
84
|
+
help(:migrate)
|
85
|
+
help(:task)
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.controller(name)
|
89
|
+
return if help?(name, :controller)
|
90
|
+
printf "Generating File(s)..."
|
91
|
+
path = "#{APP_PATH}/app/controllers/#{name.downcase}_controller.rb"
|
92
|
+
if not File.exist?(path)
|
93
|
+
p "-- Generating Controller: #{path}"
|
94
|
+
file = File.new(path, "w+")
|
95
|
+
if file
|
96
|
+
template = "class #{Doozer::Lib.classify(name)}Controller < ApplicationController\nend"
|
97
|
+
file.syswrite(template)
|
98
|
+
#make the view directory for this controller
|
99
|
+
path = "#{APP_PATH}/app/views/#{name.downcase}"
|
100
|
+
if not File.exist?(path)
|
101
|
+
p "-- Generating View Folder: #{path}"
|
102
|
+
FileUtils.mkdir path
|
103
|
+
end
|
104
|
+
else
|
105
|
+
p "Unable to open file!"
|
106
|
+
end
|
107
|
+
else
|
108
|
+
p "-- Skipping: #{path} (already exists)"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.model(orm, name)
|
113
|
+
return if help?(name, :model)
|
114
|
+
raise "No ORM is defined. Please set this in database.yml" if orm.nil?
|
115
|
+
p "Loaded ORM: #{orm}"
|
116
|
+
path = "#{APP_PATH}/app/models/#{name}.rb"
|
117
|
+
if not File.exist?(path)
|
118
|
+
p "-- Generating Model: #{path}"
|
119
|
+
file = File.new(path, "w+")
|
120
|
+
if file
|
121
|
+
template = eval("model_#{orm}('#{name}')")
|
122
|
+
file.syswrite(template)
|
123
|
+
else
|
124
|
+
p "Unable to open file!"
|
125
|
+
end
|
126
|
+
else
|
127
|
+
p "-- Skipping: #{path} (already exists)"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
def self.model_active_record(name)
|
131
|
+
klass=Doozer::Lib.classify(name)
|
132
|
+
return """#= #{klass}
|
133
|
+
class #{klass} < ActiveRecord::Base
|
134
|
+
end
|
135
|
+
"""
|
136
|
+
end
|
137
|
+
def self.model_data_mapper(name)
|
138
|
+
klass = Doozer::Lib.classify(name)
|
139
|
+
return """#= #{klass}
|
140
|
+
class #{klass}
|
141
|
+
include DataMapper::Resource
|
142
|
+
property :id, Serial
|
143
|
+
end
|
144
|
+
"""
|
145
|
+
end
|
146
|
+
def self.model_sequel(name)
|
147
|
+
klass = Doozer::Lib.classify(name)
|
148
|
+
return """ #see http://sequel.rubyforge.org/rdoc/index.html
|
149
|
+
#= #{klass}
|
150
|
+
class #{klass} < Sequel::Model
|
151
|
+
end
|
152
|
+
"""
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.view(view, formats)
|
156
|
+
return if help?(view, :view)
|
157
|
+
printf "Generating View File(s)..."
|
158
|
+
raise "Not sure which controller to associate this view with. Needs to be controller_name/action_name. Example: index/login" if not view.index('/')
|
159
|
+
formats.each{|f|
|
160
|
+
file="#{APP_PATH}/app/views/#{view}.#{f.strip}.erb"
|
161
|
+
if not File.exist?(file)
|
162
|
+
p "-- Generating: #{file}"
|
163
|
+
FileUtils.touch file
|
164
|
+
else
|
165
|
+
p "-- Skipping: #{file} (already exists)"
|
166
|
+
end
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
def self.migrate(orm, name)
|
172
|
+
return if help?(name, :migrate)
|
173
|
+
|
174
|
+
raise "No ORM is defined. Please set this in database.yml" if orm.nil?
|
175
|
+
version = migrate_next
|
176
|
+
p "Loaded ORM: #{orm}"
|
177
|
+
path = "#{APP_PATH}/db/#{version}_#{name.downcase}.rb"
|
178
|
+
if not File.exist?(path)
|
179
|
+
p "-- Generating Migration: #{path}"
|
180
|
+
file = File.new(path, "w+")
|
181
|
+
if file
|
182
|
+
template = eval("migrate_#{orm}('#{name}')")
|
183
|
+
file.syswrite(template)
|
184
|
+
else
|
185
|
+
p "Unable to open file!"
|
186
|
+
end
|
187
|
+
else
|
188
|
+
p "-- Skipping: #{path} (already exists)"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
def self.migrate_next
|
192
|
+
migrations = Dir.glob(File.join(APP_PATH,'db/*_*.rb')).reverse
|
193
|
+
for m in migrations
|
194
|
+
file = m.split('/').last
|
195
|
+
if file.index('_')
|
196
|
+
num = file.split('_').first
|
197
|
+
return "%03d" % (num.to_i + 1) if num.index('0')
|
198
|
+
end
|
199
|
+
end
|
200
|
+
return "%03d" % 1
|
201
|
+
end
|
202
|
+
def self.migrate_active_record(name)
|
203
|
+
klass = Doozer::Lib.classify(name)
|
204
|
+
return """
|
205
|
+
class #{klass} < ActiveRecord::Migration
|
206
|
+
def self.up
|
207
|
+
ActiveRecord::Base.transaction do
|
208
|
+
end
|
209
|
+
end
|
210
|
+
def self.down
|
211
|
+
ActiveRecord::Base.transaction do
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
"""
|
216
|
+
end
|
217
|
+
def self.migrate_data_mapper(name)
|
218
|
+
klass = Doozer::Lib.classify(name)
|
219
|
+
return """
|
220
|
+
# See for more details
|
221
|
+
# http://datamapper.rubyforge.org/dm-core/
|
222
|
+
# http://datamapper.rubyforge.org/dm-more/
|
223
|
+
# http://github.com/datamapper/dm-more/tree/master/dm-migrations
|
224
|
+
require 'dm-more'
|
225
|
+
class #{klass}
|
226
|
+
def self.up
|
227
|
+
end
|
228
|
+
def self.down
|
229
|
+
end
|
230
|
+
end
|
231
|
+
"""
|
232
|
+
end
|
233
|
+
def self.migrate_sequel(name)
|
234
|
+
klass = Doozer::Lib.classify(name)
|
235
|
+
return """
|
236
|
+
class #{klass}
|
237
|
+
def self.db
|
238
|
+
Doozer::Configs.db
|
239
|
+
end
|
240
|
+
def self.up
|
241
|
+
# db.create_table :name do
|
242
|
+
# end
|
243
|
+
end
|
244
|
+
def self.down
|
245
|
+
# db.drop_table :name
|
246
|
+
end
|
247
|
+
end
|
248
|
+
"""
|
249
|
+
end
|
250
|
+
|
251
|
+
def self.task(name)
|
252
|
+
return if help?(name, :task)
|
253
|
+
p "Generating file..."
|
254
|
+
path = "#{APP_PATH}/tasks/#{name}.rb"
|
255
|
+
if not File.exist?(path)
|
256
|
+
p "-- Generating Task: #{path}"
|
257
|
+
file = File.new(path, "w+")
|
258
|
+
if file
|
259
|
+
klass = Doozer::Lib.classify(name)
|
260
|
+
template = """
|
261
|
+
#= Task #{klass}
|
262
|
+
class #{klass}
|
263
|
+
def self.run
|
264
|
+
#place your task here
|
265
|
+
end
|
266
|
+
end
|
267
|
+
"""
|
268
|
+
file.syswrite(template)
|
269
|
+
else
|
270
|
+
p "Unable to open file!"
|
271
|
+
end
|
272
|
+
else
|
273
|
+
p "-- Skipping: #{path} (already exists)"
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
def self.helper(name)
|
278
|
+
return if help?(name, :helper)
|
279
|
+
p "Generating file..."
|
280
|
+
path = "#{APP_PATH}/app/helpers/#{name}_helper.rb"
|
281
|
+
if not File.exist?(path)
|
282
|
+
p "-- Generating Helper: #{path}"
|
283
|
+
file = File.new(path, "w+")
|
284
|
+
if file
|
285
|
+
klass = Doozer::Lib.classify(name)
|
286
|
+
template = """
|
287
|
+
#= #{klass}Helper
|
288
|
+
module #{klass}Helper
|
289
|
+
end
|
290
|
+
"""
|
291
|
+
file.syswrite(template)
|
292
|
+
else
|
293
|
+
p "Unable to open file!"
|
294
|
+
end
|
295
|
+
else
|
296
|
+
p "-- Skipping: #{path} (already exists)"
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def self.help?(name, action=nil)
|
301
|
+
if name.to_sym == :"-h" or name == :help
|
302
|
+
printf "doozer commands:\n"
|
303
|
+
help(action)
|
304
|
+
return true
|
305
|
+
end
|
306
|
+
return false
|
307
|
+
end
|
308
|
+
|
309
|
+
def self.help(action=nil)
|
310
|
+
h = ""
|
311
|
+
case action
|
312
|
+
|
313
|
+
when :project
|
314
|
+
h += """
|
315
|
+
Project - Create a new Doozer skeleton.
|
316
|
+
Command: doozer project_name
|
317
|
+
Example: doozer hello_world\n"""
|
318
|
+
when :model, :"-M"
|
319
|
+
h += """
|
320
|
+
Model - Create a new model file in project/app/models with a class name of ModelName for the configured ORM.
|
321
|
+
Command: doozer generate (model or -M) model_name
|
322
|
+
Example: doozer generate model user\n"""
|
323
|
+
when :view, :"-V"
|
324
|
+
h += """
|
325
|
+
View - Create a view erb file in project/app/views for each of the provided formats. If format not specified an html format is automatically created.
|
326
|
+
Command: doozer generate (view or -V) controller_name/action_name format_csv
|
327
|
+
Example: doozer generate view admin/login html,xml,json,etc\n"""
|
328
|
+
when :controller, :"-C"
|
329
|
+
h += """
|
330
|
+
Controller - Create a controller file in project/app/controllers (and view folder) with a class name ControllerName.
|
331
|
+
Command: doozer generate (controller or -C) controller_name
|
332
|
+
Example: doozer generate controller admin\n"""
|
333
|
+
when :helper, :"-H"
|
334
|
+
h += """
|
335
|
+
Helper - Create a helper file in project/app/helpers with the module name of HelperName. '_helper' is automatically appended to the helper_name.
|
336
|
+
Command: doozer generate (helper or -H) helper_name
|
337
|
+
Example: doozer generate helper helper_name\n"""
|
338
|
+
when :db, :migrate, :migration, :"-D"
|
339
|
+
h += """
|
340
|
+
Migration - Create a migration file in project/db with the next available version number and with a class name of MigrationName for the specified ORM.
|
341
|
+
Command: doozer generate (db, migrate, migration or -D) migration_name
|
342
|
+
Example: doozer generate migrate create_user\n"""
|
343
|
+
when :task, :"-T"
|
344
|
+
h += """
|
345
|
+
Task - Create a task file in project/tasks with the class name of TaskName.
|
346
|
+
Command: doozer generate (task or -T) task_name
|
347
|
+
Example: doozer generate task task_name\n"""
|
348
|
+
end
|
349
|
+
printf h
|
350
|
+
end
|
351
|
+
|
352
|
+
# TODO: Dry this up...
|
353
|
+
def self.skeleton(name)
|
354
|
+
|
355
|
+
# create application skeleton
|
356
|
+
if not File.exist?(name)
|
357
|
+
p "Creating #{name}/"
|
358
|
+
system("mkdir #{name}")
|
359
|
+
else
|
360
|
+
p "Skipping application directory (already exists)"
|
361
|
+
end
|
362
|
+
|
363
|
+
#create app folder
|
364
|
+
if not File.exist?("#{name}/app")
|
365
|
+
p "Creating app directory"
|
366
|
+
system("mkdir #{name}/app")
|
367
|
+
else
|
368
|
+
p "Skipping #{name}/app directory (already exists)"
|
369
|
+
end
|
370
|
+
|
371
|
+
#copy controllers
|
372
|
+
if not File.exist?("#{name}/app/controllers")
|
373
|
+
p "Creating #{name}/app/controllers directory and files"
|
374
|
+
system("mkdir #{name}/app/controllers")
|
375
|
+
system("cp #{skeleton_path 'app/controllers/*.rb'} #{name}/app/controllers")
|
376
|
+
else
|
377
|
+
p "Skipping #{name}/app/controllers directory (already exists)"
|
378
|
+
end
|
379
|
+
|
380
|
+
#copy models
|
381
|
+
if not File.exist?("#{name}/app/models")
|
382
|
+
p "Creating #{name}/app/models directory and files"
|
383
|
+
system("mkdir #{name}/app/models")
|
384
|
+
else
|
385
|
+
p "Skipping #{name}/app/models directory (already exists)"
|
386
|
+
end
|
387
|
+
|
388
|
+
#copy views
|
389
|
+
if not File.exist?("#{name}/app/views")
|
390
|
+
p "Creating #{name}/app/views directory and files"
|
391
|
+
system("mkdir #{name}/app/views")
|
392
|
+
else
|
393
|
+
p "Skipping #{name}/app/views directory (already exists)"
|
394
|
+
end
|
395
|
+
|
396
|
+
#copy views/layouts
|
397
|
+
if not File.exist?("#{name}/app/views/layouts")
|
398
|
+
p "Creating #{name}/app/views/layouts directory and files"
|
399
|
+
system("mkdir #{name}/app/views/layouts")
|
400
|
+
system("cp #{skeleton_path 'app/views/layouts/*.erb'} #{name}/app/views/layouts")
|
401
|
+
else
|
402
|
+
p "Skipping #{name}/app/views/layouts directory (already exists)"
|
403
|
+
end
|
404
|
+
|
405
|
+
#copy views/index
|
406
|
+
if not File.exist?("#{name}/app/views/index")
|
407
|
+
p "Creating #{name}/app/views/index directory and files"
|
408
|
+
system("mkdir #{name}/app/views/index")
|
409
|
+
system("cp #{skeleton_path 'app/views/index/*.erb'} #{name}/app/views/index")
|
410
|
+
else
|
411
|
+
p "Skipping #{name}/app/views/index directory (already exists)"
|
412
|
+
end
|
413
|
+
|
414
|
+
#copy views/global
|
415
|
+
if not File.exist?("#{name}/app/views/global")
|
416
|
+
p "Creating #{name}/app/views/global directory and files"
|
417
|
+
system("mkdir #{name}/app/views/global")
|
418
|
+
system("cp #{skeleton_path 'app/views/global/*.erb'} #{name}/app/views/global")
|
419
|
+
else
|
420
|
+
p "Skipping #{name}/app/views/global directory (already exists)"
|
421
|
+
end
|
422
|
+
|
423
|
+
#copy helpers
|
424
|
+
if not File.exist?("#{name}/app/helpers")
|
425
|
+
p "Creating #{name}/app/helpers directory and files"
|
426
|
+
system("mkdir #{name}/app/helpers")
|
427
|
+
system("cp #{skeleton_path 'app/helpers/*.rb'} #{name}/app/helpers")
|
428
|
+
else
|
429
|
+
p "Skipping #{name}/app/helpers directory (already exists)"
|
430
|
+
end
|
431
|
+
|
432
|
+
#copy configs
|
433
|
+
if not File.exist?("#{name}/config")
|
434
|
+
p "Creating #{name}/config directory and files"
|
435
|
+
system("mkdir #{name}/config")
|
436
|
+
system("cp #{skeleton_path 'config/*.yml'} #{name}/config")
|
437
|
+
system("cp #{skeleton_path 'config/*.rb'} #{name}/config")
|
438
|
+
else
|
439
|
+
p "Skipping #{name}/config directory (already exists)"
|
440
|
+
end
|
441
|
+
|
442
|
+
# create log folder
|
443
|
+
if not File.exist?("#{name}/log")
|
444
|
+
p "Creating #{name}/log directory"
|
445
|
+
system("mkdir #{name}/log")
|
446
|
+
else
|
447
|
+
p "Skipping #{name}/log directory (already exists)"
|
448
|
+
end
|
449
|
+
|
450
|
+
#copy db
|
451
|
+
if not File.exist?("#{name}/db")
|
452
|
+
p "Creating #{name}/db directory and files"
|
453
|
+
system("mkdir #{name}/db")
|
454
|
+
else
|
455
|
+
p "Skipping #{name}/db directory (already exists)"
|
456
|
+
end
|
457
|
+
|
458
|
+
#copy lib
|
459
|
+
if not File.exist?("#{name}/lib")
|
460
|
+
p "Creating #{name}/lib directory and files"
|
461
|
+
system("mkdir #{name}/lib")
|
462
|
+
else
|
463
|
+
p "Skipping #{name}/lib directory (already exists)"
|
464
|
+
end
|
465
|
+
|
466
|
+
#copy script
|
467
|
+
if not File.exist?("#{name}/script")
|
468
|
+
p "Creating #{name}/script directory and files"
|
469
|
+
system("mkdir #{name}/script")
|
470
|
+
system("cp #{skeleton_path 'script/*'} #{name}/script")
|
471
|
+
else
|
472
|
+
p "Skipping #{name}/script directory (already exists)"
|
473
|
+
end
|
474
|
+
|
475
|
+
#copy static
|
476
|
+
if not File.exist?("#{name}/static")
|
477
|
+
p "Creating #{name}/static directory and files"
|
478
|
+
system("mkdir #{name}/static")
|
479
|
+
system("cp #{skeleton_path 'static/*.*'} #{name}/static/")
|
480
|
+
else
|
481
|
+
p "Skipping #{name}/static directory (already exists)"
|
482
|
+
end
|
483
|
+
|
484
|
+
#copy static/images
|
485
|
+
if not File.exist?("#{name}/static/images")
|
486
|
+
p "Creating #{name}/script/images directory and files"
|
487
|
+
system("mkdir #{name}/static/images")
|
488
|
+
else
|
489
|
+
p "Skipping #{name}/static/images directory (already exists)"
|
490
|
+
end
|
491
|
+
|
492
|
+
#copy static/css
|
493
|
+
if not File.exist?("#{name}/static/css")
|
494
|
+
p "Creating #{name}/script/css directory and files"
|
495
|
+
system("mkdir #{name}/static/css")
|
496
|
+
system("cp #{skeleton_path 'static/css/*.css'} #{name}/static/css")
|
497
|
+
else
|
498
|
+
p "Skipping #{name}/static/css directory (already exists)"
|
499
|
+
end
|
500
|
+
|
501
|
+
#copy static/images
|
502
|
+
if not File.exist?("#{name}/static/html")
|
503
|
+
p "Creating #{name}/script/html directory and files"
|
504
|
+
system("mkdir #{name}/static/html")
|
505
|
+
else
|
506
|
+
p "Skipping #{name}/static/html directory (already exists)"
|
507
|
+
end
|
508
|
+
|
509
|
+
#copy static/images
|
510
|
+
if not File.exist?("#{name}/static/js")
|
511
|
+
p "Creating #{name}/script/js directory and files"
|
512
|
+
system("mkdir #{name}/static/js")
|
513
|
+
system("cp #{skeleton_path 'static/js/*.js'} #{name}/static/js")
|
514
|
+
else
|
515
|
+
p "Skipping #{name}/static/js directory (already exists)"
|
516
|
+
end
|
517
|
+
|
518
|
+
#copy test
|
519
|
+
if not File.exist?("#{name}/test")
|
520
|
+
p "Creating #{name}/test directory and files"
|
521
|
+
system("mkdir #{name}/test")
|
522
|
+
system("cp #{skeleton_path 'test/*.rb'} #{name}/test")
|
523
|
+
system("mkdir #{name}/test/fixtures")
|
524
|
+
system("cp #{skeleton_path 'test/fixtures/*.rb'} #{name}/test/fixtures")
|
525
|
+
else
|
526
|
+
p "Skipping test directory (already exists)"
|
527
|
+
end
|
528
|
+
|
529
|
+
#copy test
|
530
|
+
if not File.exist?("#{name}/tasks")
|
531
|
+
p "Creating #{name}/tasks directory and files"
|
532
|
+
system("mkdir #{name}/tasks")
|
533
|
+
else
|
534
|
+
p "Skipping #{name}/test directory (already exists)"
|
535
|
+
end
|
536
|
+
|
537
|
+
#copy rakefile
|
538
|
+
system("cp #{skeleton_path 'Rakefile'} #{name}")
|
539
|
+
|
540
|
+
end
|
541
|
+
|
542
|
+
def self.skeleton_path(file)
|
543
|
+
"#{PATH}/skeleton/#{file}"
|
544
|
+
end
|
545
|
+
|
546
|
+
end
|
547
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This is the default ApplicationHelper.
|
2
|
+
# Place methods here which are global to your application.
|
3
|
+
# By default all controllers include this file.
|
4
|
+
#
|
5
|
+
# To load a helper file into a controller:
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
#
|
9
|
+
# -files: app_root/app/helpers/helper1_helper.rb, app_root/app/helpers/helper2_helper.rb
|
10
|
+
#
|
11
|
+
# -declare inside controller: self.require_view_helpers=[:helper1, :helper2]
|
12
|
+
#
|
13
|
+
# By default all helpers are automatically included into the base partial class.
|
14
|
+
# Be care to avoid methods with the same names between helper modules.
|
15
|
+
# The helpers are included alphabetically by file name
|
16
|
+
module ApplicationHelper
|
17
|
+
end
|