dindi 0.4.0 → 0.5.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/Rakefile CHANGED
@@ -21,6 +21,7 @@ Jeweler::Tasks.new do |gem|
21
21
  gem.description = %Q{This gem will create a modular base for a new Sinatra app}
22
22
  gem.email = "samuelchandra@yahoo.com"
23
23
  gem.authors = ["Samuel Chandra"]
24
+ gem.files = FileList['lib/**/*', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
24
25
  gem.executables = ["dindi"]
25
26
  # dependencies defined in Gemfile
26
27
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.0
data/bin/dindi CHANGED
@@ -1,426 +1,37 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  # script to automate creation of new sinatra project
4
- require 'ostruct'
5
- require 'optparse'
6
- require 'fileutils'
7
4
  require 'colorize'
5
+ require 'ostruct'
6
+ require 'dindi'
8
7
 
9
- class OptionParser
10
-
11
- def self.parse(args)
12
- # The options specified on the command line will be collected in *options*.
13
- # We set the default value here
14
- options = OpenStruct.new
15
- options.project_name = nil
16
-
17
- opts = OptionParser.new do |opts|
18
- opts.banner = "Usage: dindi [options]"
19
-
20
- opts.separator " "
21
- opts.separator "Specific options:"
22
-
23
- opts.on("-n", "--name PROJECT_NAME",
24
- "Specify your project name PROJECT_NAME that will be created") do |lib|
25
- options.project_name = lib
26
- end
27
-
28
- opts.on("-r", "--ruby RUBY_VERSION",
29
- "Set RUBY_VERSION to 1.9.1 for compatibility mode") do |ver|
30
- options.ruby_version = ver
31
- end
32
-
33
- # No argument, shows at tail. This will print an options summary.
34
- # Try it and see!
35
- opts.on_tail("-h", "--help", "Show this message") do
36
- puts opts
37
- exit!
38
- end
39
-
40
- end
41
-
42
- opts.parse!(args)
43
- options
44
-
45
- rescue Exception => e
46
- if e.message.match(/invalid option/i) or e.message.match(/missing argument/i)
47
- puts "ERROR: #{e.message}".red
48
- puts ""
49
- puts opts
50
- end
51
- exit
52
- end
53
-
54
- end
55
-
56
- # make sure ARGV has values
8
+ # validate ARGV
57
9
  if ARGV.size == 0
58
10
  puts "ERROR: Parameters needed. Run with -h to view options".red
59
11
  exit
60
12
  end
61
13
 
62
- # parse option from command line
63
- options = OptionParser.parse(ARGV)
14
+ # parse ARGV
15
+ options = OpenStruct.new
16
+ Dindi::CommandParser.parse(ARGV, options)
64
17
 
65
18
  # make sure project name is valid
66
- if options.project_name.nil?
19
+ if options.project_name.nil? or options.project_absolute_dir.nil?
67
20
  puts "ERROR: PROJECT_NAME is needed. Run with -h to view options"
68
21
  exit
69
22
  end
70
23
 
71
- # make sure ruby version is valid
72
- if options.ruby_version.nil?
73
- options.ruby_version = "1.9.2"
74
- else
75
- options.ruby_version = "1.9.1"
76
- end
77
-
78
- project_absolute_dir = FileUtils.pwd + "/" + options.project_name
79
-
80
- # create default directories
81
- # lib, log, public, push, routes, tmp, views
82
- %w(tmp log public push views routes extlibs models helpers).each do |dir|
83
- FileUtils.mkdir_p(project_absolute_dir + "/" + dir)
84
- end
85
-
86
- if options.ruby_version == "1.9.2"
87
- #=================
88
- # create Gemfile
89
- #=================
90
- gemfile_contents = <<-gemfile
91
- source "http://rubygems.org"
92
- gem "sinatra"
93
- gem "mysql2"
94
- gem "haml"
95
- gem "activesupport"
96
- gem "activerecord"
97
- gem "json"
98
- gem "pony"
99
- gem "thin"
100
- gemfile
101
-
102
- File.open("#{project_absolute_dir}/Gemfile", "w") do |file|
103
- file.puts gemfile_contents
104
- end
105
-
106
- #=================
107
- # create config.ru
108
- #=================
109
-
110
- config_ru_contents = <<-config_ru
111
- $: << "."
112
-
113
- # we use bundler
114
- require 'bundler/setup'
115
-
116
- # modular sinatra app
117
- require 'sinatra/base'
118
-
119
- # gems
120
- %w(logger json haml csv digest date time active_support pony).each {|lib| require lib}
121
-
122
- # load db config and models
123
- require 'models'
124
-
125
- # extra library
126
- Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
127
-
128
- # helpers
129
- Dir.glob("./helpers/*.rb").each {|helper| require helper}
130
-
131
- # controllers
132
- Dir.glob("./routes/*.rb").each {|route| require route}
133
-
134
- # app file
135
- require '#{options.project_name}'
136
-
137
- # custom app logger different from sintra logging
138
- $APP_LOG = ::Logger.new("log/#{options.project_name}.log")
139
-
140
- # app name
141
- $APP_NAME = "#{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }}"
142
-
143
- class Sinatra::Base
144
- # helpers
145
- include DebugOn
146
-
147
- # set sinatra's variables
148
- set :root, File.dirname(__FILE__)
149
- set :environment, :production
150
- enable :sessions, :logging, :dump_errors, :show_exceptions
151
- disable :run, :reload
152
- end
153
-
154
- # app routes
155
- App = Rack::Builder.app do
156
- # routes
157
- # use Cms
158
-
159
- run #{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }}
160
- end
161
-
162
- # finally
163
- run App
164
- config_ru
165
-
166
- File.open("#{project_absolute_dir}/config.ru", "w") do |file|
167
- file.puts config_ru_contents
168
- end
169
- #====================
170
- # create database.yml
171
- #====================
172
-
173
- database_yml_contents = <<-database_yml
174
- production:
175
- adapter: mysql2
176
- username: root
177
- password: password
178
- host: localhost
179
- timezone: SGT
180
- reconnect: true
181
- database: #{options.project_name}
182
- encoding: utf8
183
- database_yml
184
-
185
- File.open("#{project_absolute_dir}/database.yml", "w") do |file|
186
- file.puts database_yml_contents
187
- end
188
-
189
- #=======================
190
- # create models.rb
191
- #=======================
192
-
193
- models_rb_contents = <<-models_rb
194
- require 'mysql2'
195
- require 'active_record'
196
-
197
- config = YAML.load_file('database.yml')
198
- ActiveRecord::Base.establish_connection(config["production"])
199
-
200
- Dir.glob("#{project_absolute_dir}/models/*.rb").each {|model| require model}
201
- models_rb
202
-
203
- File.open("#{project_absolute_dir}/models.rb", "w") do |file|
204
- file.puts models_rb_contents
205
- end
206
-
207
- else
208
- #=================
209
- # create Gemfile.191
210
- #=================
211
- gemfile191_contents = <<-gemfile191
212
- source "http://rubygems.org"
213
- gem "rack", "1.2.2"
214
- gem "sinatra", "1.2.6"
215
- gem "haml"
216
- gem "activesupport", "=2.3.14"
217
- gem "activerecord", "=2.3.14"
218
- gem "json"
219
- gem "pony"
220
- gem "thin"
221
- gemfile191
222
-
223
- File.open("#{project_absolute_dir}/Gemfile", "w") do |file|
224
- file.puts gemfile191_contents
225
- end
226
- #=================
227
- # create config.ru
228
- #=================
24
+ # create project default directories
25
+ Dindi::FileHelper.create_default_directories(options)
229
26
 
230
- config_ru_contents = <<-config_ru
231
- $: << "."
232
-
233
- # we use bundler
234
- require 'bundler/setup'
235
-
236
- # modular sinatra app
237
- require 'sinatra/base'
238
-
239
- # gems
240
- %w(logger json haml csv digest date time activesupport pony).each {|lib| require lib}
241
-
242
- # load db config and models
243
- require 'models'
244
-
245
- # extra library
246
- Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
247
-
248
- # helpers
249
- Dir.glob("./helpers/*.rb").each {|helper| require helper}
250
-
251
- # controllers
252
- Dir.glob("./routes/*.rb").each {|route| require route}
253
-
254
- # app file
255
- require '#{options.project_name}'
256
-
257
- # custom app logger different from sinatra logging
258
- $APP_LOG = ::Logger.new("log/#{options.project_name}.log")
259
-
260
- # app name
261
- $APP_NAME = "#{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }}"
262
-
263
- class Sinatra::Base
264
- # helpers
265
- include DebugOn
266
-
267
- # set sinatra's variables
268
- set :root, File.dirname(__FILE__)
269
- set :environment, :production
270
- enable :sessions, :logging, :dump_errors, :show_exceptions
271
- disable :run, :reload
272
- end
273
-
274
- # app routes
275
- App = Rack::Builder.app do
276
- # routes
277
- # use Cms
278
-
279
- run #{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }}
280
- end
281
-
282
- # finally
283
- run App
284
- config_ru
285
-
286
- File.open("#{project_absolute_dir}/config.ru", "w") do |file|
287
- file.puts config_ru_contents
288
- end
289
-
290
- #====================
291
- # create database.yml
292
- #====================
293
-
294
- database_yml_contents = <<-database_yml
295
- login: &login
296
- adapter: mysql
297
- username: root
298
- password: password
299
- host: localhost
300
- timezone: SGT
301
- reconnect: true
302
-
303
- production:
304
- <<: *login
305
- database: #{options.project_name}
306
- encoding: utf8
307
- database_yml
308
-
309
- File.open("#{project_absolute_dir}/database.yml", "w") do |file|
310
- file.puts database_yml_contents
311
- end
312
-
313
- #=======================
314
- # create models.rb
315
- #=======================
316
-
317
- models_rb_contents = <<-models_rb
318
- require 'activerecord'
319
-
320
- config = YAML.load_file('database.yml')
321
- ActiveRecord::Base.establish_connection(config["production"])
322
-
323
- Dir.glob("#{project_absolute_dir}/models/*.rb").each {|model| require model}
324
- models_rb
325
-
326
- File.open("#{project_absolute_dir}/models.rb", "w") do |file|
327
- file.puts models_rb_contents
328
- end
329
- end
330
-
331
-
332
- #==================
333
- # create helpers.rb
334
- #==================
335
-
336
- helpers_rb_contents = <<-helpers_rb
337
- module DebugOn
338
-
339
- def debug_on
340
- logger.info("===== START =====> #{Time.now.strftime("%d/%m/%Y %H:%M %p")}")
341
- logger.info(request.url)
342
- logger.info("Params:")
343
- params.each do |key, value|
344
- logger.info("\#{key} => \#{value}")
345
- end
346
- end
347
-
348
- def app_debug_on
349
- $APP_LOG.info("===== START =====> #{Time.now.strftime("%d/%m/%Y %H:%M %p")}")
350
- $APP_LOG.info(request.url)
351
- $APP_LOG.info("Params:")
352
- params.each do |key, value|
353
- $APP_LOG.info("\#{key} => \#{value}")
354
- end
355
- end
356
-
357
- def app_logger(text)
358
- $APP_LOG.info(text)
359
- end
360
-
361
- end
362
- helpers_rb
363
-
364
- File.open("#{project_absolute_dir}/helpers/debug_on.rb", "w") do |file|
365
- file.puts helpers_rb_contents
366
- end
367
-
368
-
369
- #=======================
370
- # create project_name.rb
371
- #=======================
372
-
373
- project_name_rb_contents = <<-project_name_rb
374
- class #{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }} < Sinatra::Base
375
-
376
- # index
377
- get '/' do
378
- '#{options.project_name}'
379
- end
380
-
381
- # docs
382
- get '/docs' do
383
- @page_title = "Docs"
384
- haml :docs
385
- end
386
-
387
- end
388
- project_name_rb
389
-
390
- File.open("#{project_absolute_dir}/#{options.project_name}.rb", "w") do |file|
391
- file.puts project_name_rb_contents
392
- end
393
-
394
- #=======================
395
- # create docs.haml
396
- #=======================
397
-
398
- docs_haml_contents = <<-docs_haml
399
- %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :summary => "API Docs"}
400
- %caption
401
- %em API Docs
402
- %thead
403
- %tr
404
- %th.span-4 URL
405
- %th.span-4.last Description
406
- %tfoot
407
- %tr
408
- %td{:colspan => "2"} Change http://servername with the correct address
409
- %tbody
410
- %tr
411
- %td http://servername
412
- %td (GET) Returns app name
413
- docs_haml
414
-
415
- File.open("#{project_absolute_dir}/views/docs.haml", "w") do |file|
416
- file.puts docs_haml_contents
417
- end
27
+ # create project files from templates
28
+ Dindi::FileHelper.copy_file_templates(options)
418
29
 
419
30
  # Completion
420
31
  puts "Your project folder #{options.project_name} was successfully created".green
421
32
 
422
33
  puts "Running 'bundle install --path vendor/bundle' ......."
423
- bundler_result = system("cd #{project_absolute_dir}; bundle install --path vendor/bundle")
34
+ bundler_result = system("cd #{options.project_absolute_dir}; bundle install --path vendor/bundle")
424
35
  if bundler_result
425
36
  puts "passed".green + " bundler install"
426
37
  else
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ require 'optparse'
4
+ require 'fileutils'
5
+
6
+ module Dindi
7
+
8
+ module CommandParser
9
+
10
+ def self.parse(args, options)
11
+ # The options specified on the command line will be collected in *options*.
12
+ # We set the default value here
13
+ options.project_name = nil
14
+
15
+ opts = OptionParser.new do |opts|
16
+ opts.banner = "Usage: dindi [options]"
17
+
18
+ opts.separator " "
19
+ opts.separator "Specific options:"
20
+
21
+ opts.on("-n", "--name PROJECT_NAME",
22
+ "Specify your project name PROJECT_NAME that will be created") do |lib|
23
+ options.project_name = lib
24
+ end
25
+
26
+ opts.on("-r", "--ruby RUBY_VERSION",
27
+ "Set RUBY_VERSION to 1.9.1 for compatibility mode") do |ver|
28
+ options.ruby_version = ver
29
+ end
30
+
31
+ # No argument, shows at tail. This will print an options summary.
32
+ # Try it and see!
33
+ opts.on_tail("-h", "--help", "Show this message") do
34
+ puts opts
35
+ # exit!
36
+ end
37
+
38
+ end
39
+
40
+ opts.parse!(args)
41
+
42
+ if options.ruby_version.nil? or options.ruby_version.gsub(".", "").to_i > 191
43
+ options.ruby_version = "1.9.2"
44
+ else
45
+ options.ruby_version = "1.9.1"
46
+ end
47
+
48
+ # set project absolute dir early
49
+ options.project_absolute_dir = if options.project_name
50
+ FileUtils.pwd + "/" + options.project_name
51
+ else
52
+ nil
53
+ end
54
+
55
+ rescue Exception => e
56
+ if e.message.match(/invalid option/i) or e.message.match(/missing argument/i)
57
+ puts "ERROR: #{e.message}".red
58
+ puts ""
59
+ puts opts
60
+ end
61
+ # exit
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ require 'erb'
4
+
5
+ module Dindi
6
+ module FileHelper
7
+
8
+ def self.create_default_directories(options)
9
+ project_absolute_dir = options.project_absolute_dir
10
+ %w(tmp log public push views routes extlibs models helpers).each do |dir|
11
+ FileUtils.mkdir_p(project_absolute_dir + "/" + dir)
12
+ end
13
+ end
14
+
15
+ def self.copy_file_templates(options)
16
+ project_absolute_dir = options.project_absolute_dir
17
+ ruby_version = options.ruby_version
18
+
19
+ # version specific file templates and shared template together
20
+ [ruby_version, "shared"].each do |dir_name|
21
+
22
+ Dir.glob(File.dirname(__FILE__) + "/file_templates/#{dir_name}/*").each do |file|
23
+ filename = file.split("/").last.gsub(".erb", "")
24
+
25
+ # read file as ERB templates
26
+ content = File.open(file, "r").read
27
+ template = ERB.new content
28
+
29
+ # file copy location
30
+ file_location = template_file_copy_location(filename, options)
31
+
32
+ # write the contents of each file to the project directory
33
+ File.open(file_location, "w") do |file|
34
+
35
+ # write file after running the templates
36
+ file.puts template.result(binding)
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ def self.template_file_copy_location(filename, options)
45
+ project_absolute_dir = options.project_absolute_dir
46
+
47
+ # copy location for not common template files
48
+ special_location_hash = {"helpers.rb" => "#{project_absolute_dir}/helpers/helpers.rb",
49
+ "docs.haml" => "#{project_absolute_dir}/views/docs.haml",
50
+ "project_name.rb" => "#{project_absolute_dir}/#{options.project_name}.rb"
51
+ }
52
+
53
+ if special_location_hash[filename]
54
+ return special_location_hash[filename]
55
+ else
56
+ return "#{project_absolute_dir}/#{filename}"
57
+ end
58
+
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rack", "1.2.2"
4
+ gem "sinatra", "1.2.6"
5
+ gem "haml"
6
+ gem "activesupport", "=2.3.14"
7
+ gem "activerecord", "=2.3.14"
8
+ gem "json"
9
+ gem "pony"
10
+ gem "thin"
@@ -0,0 +1,53 @@
1
+ $: << "."
2
+
3
+ # we use bundler
4
+ require 'bundler/setup'
5
+
6
+ # modular sinatra app
7
+ require 'sinatra/base'
8
+
9
+ # gems
10
+ %w(logger json haml csv digest date time activesupport pony).each {|lib| require lib}
11
+
12
+ # load db config and models
13
+ require 'models'
14
+
15
+ # extra library
16
+ Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
17
+
18
+ # helpers
19
+ Dir.glob("./helpers/*.rb").each {|helper| require helper}
20
+
21
+ # controllers
22
+ Dir.glob("./routes/*.rb").each {|route| require route}
23
+
24
+ # app file
25
+ require '<%= options.project_name %>'
26
+
27
+ # custom app logger different from sinatra logging
28
+ $APP_LOG = ::Logger.new("log/<%= options.project_name %>.log")
29
+
30
+ # app name
31
+ $APP_NAME = "<%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>"
32
+
33
+ class Sinatra::Base
34
+ # helpers
35
+ include DebugOn
36
+
37
+ # set sinatra's variables
38
+ set :root, File.dirname(__FILE__)
39
+ set :environment, :production
40
+ enable :sessions, :logging, :dump_errors, :show_exceptions
41
+ disable :run, :reload
42
+ end
43
+
44
+ # app routes
45
+ App = Rack::Builder.app do
46
+ # routes
47
+ # use Cms
48
+
49
+ run <%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>
50
+ end
51
+
52
+ # finally
53
+ run App
@@ -0,0 +1,9 @@
1
+ production:
2
+ adapter: mysql
3
+ username: root
4
+ password: password
5
+ host: localhost
6
+ timezone: SGT
7
+ reconnect: true
8
+ database: <%= options.project_name %>
9
+ encoding: utf8
@@ -0,0 +1,6 @@
1
+ require 'activerecord'
2
+
3
+ config = YAML.load_file('database.yml')
4
+ ActiveRecord::Base.establish_connection(config["production"])
5
+
6
+ Dir.glob("<%= project_absolute_dir %>/models/*.rb").each {|model| require model}
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "sinatra"
4
+ gem "mysql2"
5
+ gem "haml"
6
+ gem "activesupport"
7
+ gem "activerecord"
8
+ gem "json"
9
+ gem "pony"
10
+ gem "thin"
@@ -0,0 +1,53 @@
1
+ $: << "."
2
+
3
+ # we use bundler
4
+ require 'bundler/setup'
5
+
6
+ # modular sinatra app
7
+ require 'sinatra/base'
8
+
9
+ # gems
10
+ %w(logger json haml csv digest date time active_support pony).each {|lib| require lib}
11
+
12
+ # load db config and models
13
+ require 'models'
14
+
15
+ # extra library
16
+ Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
17
+
18
+ # helpers
19
+ Dir.glob("./helpers/*.rb").each {|helper| require helper}
20
+
21
+ # controllers
22
+ Dir.glob("./routes/*.rb").each {|route| require route}
23
+
24
+ # app file
25
+ require '<%= options.project_name %>'
26
+
27
+ # custom app logger different from sintra logging
28
+ $APP_LOG = ::Logger.new("log/<%= options.project_name %>.log")
29
+
30
+ # app name
31
+ $APP_NAME = "<%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>"
32
+
33
+ class Sinatra::Base
34
+ # helpers
35
+ include DebugOn
36
+
37
+ # set sinatra's variables
38
+ set :root, File.dirname(__FILE__)
39
+ set :environment, :production
40
+ enable :sessions, :logging, :dump_errors, :show_exceptions
41
+ disable :run, :reload
42
+ end
43
+
44
+ # app routes
45
+ App = Rack::Builder.app do
46
+ # routes
47
+ # use Cms
48
+
49
+ run <%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %>
50
+ end
51
+
52
+ # finally
53
+ run App
@@ -0,0 +1,9 @@
1
+ production:
2
+ adapter: mysql2
3
+ username: root
4
+ password: password
5
+ host: localhost
6
+ timezone: SGT
7
+ reconnect: true
8
+ database: <%= options.project_name %>
9
+ encoding: utf8
@@ -0,0 +1,7 @@
1
+ require 'mysql2'
2
+ require 'active_record'
3
+
4
+ config = YAML.load_file('database.yml')
5
+ ActiveRecord::Base.establish_connection(config["production"])
6
+
7
+ Dir.glob("<%= project_absolute_dir %>/models/*.rb").each {|model| require model}
@@ -0,0 +1,14 @@
1
+ %table{:border => "0", :cellpadding => "0", :cellspacing => "0", :summary => "API Docs"}
2
+ %caption
3
+ %em API Docs
4
+ %thead
5
+ %tr
6
+ %th.span-4 URL
7
+ %th.span-4.last Description
8
+ %tfoot
9
+ %tr
10
+ %td{:colspan => "2"} Change http://servername with the correct address
11
+ %tbody
12
+ %tr
13
+ %td http://servername
14
+ %td (GET) Returns app name
@@ -0,0 +1,25 @@
1
+ module DebugOn
2
+
3
+ def debug_on
4
+ logger.info("===== START =====> #{Time.now.strftime("%d/%m/%Y %H:%M %p")}")
5
+ logger.info(request.url)
6
+ logger.info("Params:")
7
+ params.each do |key, value|
8
+ logger.info("\#{key} => \#{value}")
9
+ end
10
+ end
11
+
12
+ def app_debug_on
13
+ $APP_LOG.info("===== START =====> #{Time.now.strftime("%d/%m/%Y %H:%M %p")}")
14
+ $APP_LOG.info(request.url)
15
+ $APP_LOG.info("Params:")
16
+ params.each do |key, value|
17
+ $APP_LOG.info("\#{key} => \#{value}")
18
+ end
19
+ end
20
+
21
+ def app_logger(text)
22
+ $APP_LOG.info(text)
23
+ end
24
+
25
+ end
@@ -0,0 +1,14 @@
1
+ class <%= options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase } %> < Sinatra::Base
2
+
3
+ # index
4
+ get '/' do
5
+ '<%= options.project_name %>'
6
+ end
7
+
8
+ # docs
9
+ get '/docs' do
10
+ @page_title = "Docs"
11
+ haml :docs
12
+ end
13
+
14
+ end
data/lib/dindi.rb CHANGED
@@ -0,0 +1,2 @@
1
+ require File.dirname(__FILE__) + '/dindi/command_parser'
2
+ require File.dirname(__FILE__) + '/dindi/file_helper'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dindi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-01 00:00:00.000000000Z
12
+ date: 2012-02-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
16
- requirement: &70138797241020 !ruby/object:Gem::Requirement
16
+ requirement: &70228993019520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70138797241020
24
+ version_requirements: *70228993019520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &70138797240020 !ruby/object:Gem::Requirement
27
+ requirement: &70228993018800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70138797240020
35
+ version_requirements: *70228993018800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &70138797239280 !ruby/object:Gem::Requirement
38
+ requirement: &70228993017880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70138797239280
46
+ version_requirements: *70228993017880
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70138797238400 !ruby/object:Gem::Requirement
49
+ requirement: &70228993017080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70138797238400
57
+ version_requirements: *70228993017080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70138797237580 !ruby/object:Gem::Requirement
60
+ requirement: &70228993016220 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.6.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70138797237580
68
+ version_requirements: *70228993016220
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rcov
71
- requirement: &70138797236600 !ruby/object:Gem::Requirement
71
+ requirement: &70228993015400 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70138797236600
79
+ version_requirements: *70228993015400
80
80
  description: This gem will create a modular base for a new Sinatra app
81
81
  email: samuelchandra@yahoo.com
82
82
  executables:
@@ -86,7 +86,6 @@ extra_rdoc_files:
86
86
  - LICENSE.txt
87
87
  - README.rdoc
88
88
  files:
89
- - .document
90
89
  - Gemfile
91
90
  - Gemfile.lock
92
91
  - LICENSE.txt
@@ -94,8 +93,20 @@ files:
94
93
  - Rakefile
95
94
  - VERSION
96
95
  - bin/dindi
97
- - dindi.gemspec
98
96
  - lib/dindi.rb
97
+ - lib/dindi/command_parser.rb
98
+ - lib/dindi/file_helper.rb
99
+ - lib/dindi/file_templates/1.9.1/Gemfile.erb
100
+ - lib/dindi/file_templates/1.9.1/config.ru.erb
101
+ - lib/dindi/file_templates/1.9.1/database.yml.erb
102
+ - lib/dindi/file_templates/1.9.1/models.rb.erb
103
+ - lib/dindi/file_templates/1.9.2/Gemfile.erb
104
+ - lib/dindi/file_templates/1.9.2/config.ru.erb
105
+ - lib/dindi/file_templates/1.9.2/database.yml.erb
106
+ - lib/dindi/file_templates/1.9.2/models.rb.erb
107
+ - lib/dindi/file_templates/shared/docs.haml.erb
108
+ - lib/dindi/file_templates/shared/helpers.rb.erb
109
+ - lib/dindi/file_templates/shared/project_name.rb.erb
99
110
  - test/helper.rb
100
111
  - test/test_dindi.rb
101
112
  homepage: http://github.com/schandra/dindi
@@ -113,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
124
  version: '0'
114
125
  segments:
115
126
  - 0
116
- hash: -1787470773293439694
127
+ hash: 23520019865919934
117
128
  required_rubygems_version: !ruby/object:Gem::Requirement
118
129
  none: false
119
130
  requirements:
@@ -122,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
133
  version: '0'
123
134
  requirements: []
124
135
  rubyforge_project:
125
- rubygems_version: 1.8.15
136
+ rubygems_version: 1.8.10
126
137
  signing_key:
127
138
  specification_version: 3
128
139
  summary: Dindi is a hit of Sinatra
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/dindi.gemspec DELETED
@@ -1,67 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "dindi"
8
- s.version = "0.4.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Samuel Chandra"]
12
- s.date = "2012-02-01"
13
- s.description = "This gem will create a modular base for a new Sinatra app"
14
- s.email = "samuelchandra@yahoo.com"
15
- s.executables = ["dindi"]
16
- s.extra_rdoc_files = [
17
- "LICENSE.txt",
18
- "README.rdoc"
19
- ]
20
- s.files = [
21
- ".document",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "bin/dindi",
29
- "dindi.gemspec",
30
- "lib/dindi.rb",
31
- "test/helper.rb",
32
- "test/test_dindi.rb"
33
- ]
34
- s.homepage = "http://github.com/schandra/dindi"
35
- s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = "1.8.15"
38
- s.summary = "Dindi is a hit of Sinatra"
39
-
40
- if s.respond_to? :specification_version then
41
- s.specification_version = 3
42
-
43
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<colorize>, [">= 0"])
45
- s.add_runtime_dependency(%q<bundler>, ["~> 1.0.0"])
46
- s.add_development_dependency(%q<shoulda>, [">= 0"])
47
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
49
- s.add_development_dependency(%q<rcov>, [">= 0"])
50
- else
51
- s.add_dependency(%q<colorize>, [">= 0"])
52
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
53
- s.add_dependency(%q<shoulda>, [">= 0"])
54
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
56
- s.add_dependency(%q<rcov>, [">= 0"])
57
- end
58
- else
59
- s.add_dependency(%q<colorize>, [">= 0"])
60
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
- s.add_dependency(%q<shoulda>, [">= 0"])
62
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
64
- s.add_dependency(%q<rcov>, [">= 0"])
65
- end
66
- end
67
-