dindi 0.2.1 → 0.3.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/README.rdoc +11 -3
- data/VERSION +1 -1
- data/bin/dindi +224 -95
- data/dindi.gemspec +1 -1
- metadata +10 -10
data/README.rdoc
CHANGED
@@ -6,15 +6,23 @@ Dindi help you create a spanking new sinatra app (modular only) with default dir
|
|
6
6
|
|
7
7
|
== Usage
|
8
8
|
|
9
|
-
To view dindi options
|
9
|
+
To view dindi options:
|
10
10
|
|
11
11
|
dindi -h
|
12
12
|
|
13
|
-
Creating a new sinatra app called appname
|
13
|
+
Creating a new sinatra app called appname:
|
14
14
|
|
15
15
|
dindi -n appname
|
16
16
|
|
17
|
-
|
17
|
+
OR
|
18
|
+
|
19
|
+
Creating a new sinatra app for ruby 1.9.1:
|
20
|
+
|
21
|
+
dindi -n appname -r 1.9.1
|
22
|
+
|
23
|
+
IMPORTANT
|
24
|
+
|
25
|
+
Dont forget to run bundle install for the gems:
|
18
26
|
|
19
27
|
bundle install --path vendor/bundle
|
20
28
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/dindi
CHANGED
@@ -25,6 +25,11 @@ class OptionParser
|
|
25
25
|
options.project_name = lib
|
26
26
|
end
|
27
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
|
+
|
28
33
|
# No argument, shows at tail. This will print an options summary.
|
29
34
|
# Try it and see!
|
30
35
|
opts.on_tail("-h", "--help", "Show this message") do
|
@@ -55,6 +60,13 @@ if options.project_name.nil?
|
|
55
60
|
exit
|
56
61
|
end
|
57
62
|
|
63
|
+
# make sure ruby version is valid
|
64
|
+
if options.ruby_version.nil?
|
65
|
+
options.ruby_version = "1.9.2"
|
66
|
+
else
|
67
|
+
options.ruby_version = "1.9.1"
|
68
|
+
end
|
69
|
+
|
58
70
|
project_absolute_dir = FileUtils.pwd + "/" + options.project_name
|
59
71
|
|
60
72
|
# create default directories
|
@@ -63,80 +75,237 @@ project_absolute_dir = FileUtils.pwd + "/" + options.project_name
|
|
63
75
|
FileUtils.mkdir_p(project_absolute_dir + "/" + dir)
|
64
76
|
end
|
65
77
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
gem "
|
73
|
-
gem "
|
74
|
-
gem "
|
75
|
-
gem "
|
76
|
-
gem "
|
77
|
-
gem "
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
78
|
+
if options.ruby_version == "1.9.2"
|
79
|
+
#=================
|
80
|
+
# create Gemfile
|
81
|
+
#=================
|
82
|
+
gemfile_contents = <<-gemfile
|
83
|
+
source "http://rubygems.org"
|
84
|
+
gem "sinatra"
|
85
|
+
gem "mysql2"
|
86
|
+
gem "haml"
|
87
|
+
gem "activesupport"
|
88
|
+
gem "activerecord"
|
89
|
+
gem "json"
|
90
|
+
gem "pony"
|
91
|
+
gemfile
|
92
|
+
|
93
|
+
File.open("#{project_absolute_dir}/Gemfile", "w") do |file|
|
94
|
+
file.puts gemfile_contents
|
95
|
+
end
|
83
96
|
|
84
|
-
#=================
|
85
|
-
# create config.ru
|
86
|
-
#=================
|
97
|
+
#=================
|
98
|
+
# create config.ru
|
99
|
+
#=================
|
87
100
|
|
88
|
-
config_ru_contents = <<-config_ru
|
89
|
-
$: << "."
|
101
|
+
config_ru_contents = <<-config_ru
|
102
|
+
$: << "."
|
90
103
|
|
91
|
-
# we use bundler
|
92
|
-
require 'bundler/setup'
|
104
|
+
# we use bundler
|
105
|
+
require 'bundler/setup'
|
93
106
|
|
94
|
-
# modular sinatra app
|
95
|
-
require 'sinatra/base'
|
107
|
+
# modular sinatra app
|
108
|
+
require 'sinatra/base'
|
96
109
|
|
97
|
-
# gems
|
98
|
-
%w(logger json haml csv digest date time active_support pony).each {|lib| require lib}
|
110
|
+
# gems
|
111
|
+
%w(logger json haml csv digest date time active_support pony).each {|lib| require lib}
|
99
112
|
|
100
|
-
# load db config and models
|
101
|
-
require 'models'
|
113
|
+
# load db config and models
|
114
|
+
require 'models'
|
102
115
|
|
103
|
-
# extra library
|
104
|
-
Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
|
116
|
+
# extra library
|
117
|
+
Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
|
105
118
|
|
106
|
-
# helpers
|
107
|
-
#Dir.glob("./helpers/*.rb").each {|helper| require helper}
|
119
|
+
# helpers
|
120
|
+
#Dir.glob("./helpers/*.rb").each {|helper| require helper}
|
108
121
|
|
109
|
-
# controllers
|
110
|
-
Dir.glob("./routes/*.rb").each {|route| require route}
|
122
|
+
# controllers
|
123
|
+
Dir.glob("./routes/*.rb").each {|route| require route}
|
111
124
|
|
112
|
-
# app file
|
113
|
-
require '#{options.project_name}'
|
125
|
+
# app file
|
126
|
+
require '#{options.project_name}'
|
114
127
|
|
115
|
-
# app logger
|
116
|
-
$LOG = ::Logger.new("log/#{options.project_name}.log")
|
128
|
+
# app logger
|
129
|
+
$LOG = ::Logger.new("log/#{options.project_name}.log")
|
117
130
|
|
118
|
-
class Sinatra::Base
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
131
|
+
class Sinatra::Base
|
132
|
+
# set sinatra's variables
|
133
|
+
set :environment, :production
|
134
|
+
enable :sessions, :logging, :dump_errors, :show_exceptions
|
135
|
+
disable :run, :reload
|
136
|
+
end
|
124
137
|
|
125
|
-
# app routes
|
126
|
-
App = Rack::Builder.app do
|
138
|
+
# app routes
|
139
|
+
App = Rack::Builder.app do
|
127
140
|
|
128
|
-
|
129
|
-
end
|
141
|
+
run #{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }}
|
142
|
+
end
|
143
|
+
|
144
|
+
# finally
|
145
|
+
run App
|
146
|
+
|
147
|
+
config_ru
|
148
|
+
|
149
|
+
File.open("#{project_absolute_dir}/config.ru", "w") do |file|
|
150
|
+
file.puts config_ru_contents
|
151
|
+
end
|
152
|
+
#====================
|
153
|
+
# create database.yml
|
154
|
+
#====================
|
155
|
+
|
156
|
+
database_yml_contents = <<-database_yml
|
157
|
+
login: &login
|
158
|
+
adapter: mysql2
|
159
|
+
username: root
|
160
|
+
password: password
|
161
|
+
host: localhost
|
162
|
+
timezone: SGT
|
163
|
+
reconnect: true
|
164
|
+
|
165
|
+
production:
|
166
|
+
<<: *login
|
167
|
+
database: #{options.project_name}
|
168
|
+
encoding: utf8
|
169
|
+
database_yml
|
170
|
+
|
171
|
+
File.open("#{project_absolute_dir}/database.yml", "w") do |file|
|
172
|
+
file.puts database_yml_contents
|
173
|
+
end
|
174
|
+
|
175
|
+
#=======================
|
176
|
+
# create models.rb
|
177
|
+
#=======================
|
178
|
+
|
179
|
+
models_rb_contents = <<-models_rb
|
180
|
+
require 'mysql2'
|
181
|
+
require 'active_record'
|
182
|
+
|
183
|
+
config = YAML.load_file('database.yml')
|
184
|
+
ActiveRecord::Base.establish_connection(config["production"])
|
185
|
+
|
186
|
+
Dir.glob("#{project_absolute_dir}/models/*.rb").each {|model| require model}
|
187
|
+
models_rb
|
188
|
+
|
189
|
+
File.open("#{project_absolute_dir}/models.rb", "w") do |file|
|
190
|
+
file.puts models_rb_contents
|
191
|
+
end
|
192
|
+
|
193
|
+
else
|
194
|
+
#=================
|
195
|
+
# create Gemfile.191
|
196
|
+
#=================
|
197
|
+
gemfile191_contents = <<-gemfile191
|
198
|
+
source "http://rubygems.org"
|
199
|
+
gem "rack", "1.2.2"
|
200
|
+
gem "sinatra", "1.2.6"
|
201
|
+
gem "haml"
|
202
|
+
gem "activesupport", "=2.3.14"
|
203
|
+
gem "activerecord", "=2.3.14"
|
204
|
+
gem "json"
|
205
|
+
gem "pony"
|
206
|
+
gemfile191
|
207
|
+
|
208
|
+
File.open("#{project_absolute_dir}/Gemfile", "w") do |file|
|
209
|
+
file.puts gemfile191_contents
|
210
|
+
end
|
211
|
+
#=================
|
212
|
+
# create config.ru
|
213
|
+
#=================
|
214
|
+
|
215
|
+
config_ru_contents = <<-config_ru
|
216
|
+
$: << "."
|
217
|
+
|
218
|
+
# we use bundler
|
219
|
+
require 'bundler/setup'
|
220
|
+
|
221
|
+
# modular sinatra app
|
222
|
+
require 'sinatra/base'
|
223
|
+
|
224
|
+
# gems
|
225
|
+
%w(logger json haml csv digest date time activesupport pony).each {|lib| require lib}
|
226
|
+
|
227
|
+
# load db config and models
|
228
|
+
require 'models'
|
229
|
+
|
230
|
+
# extra library
|
231
|
+
Dir.glob("./extlibs/*.rb").each {|extlib| require extlib}
|
130
232
|
|
131
|
-
#
|
132
|
-
|
233
|
+
# helpers
|
234
|
+
#Dir.glob("./helpers/*.rb").each {|helper| require helper}
|
133
235
|
|
134
|
-
|
236
|
+
# controllers
|
237
|
+
Dir.glob("./routes/*.rb").each {|route| require route}
|
135
238
|
|
136
|
-
|
137
|
-
|
239
|
+
# app file
|
240
|
+
require '#{options.project_name}'
|
241
|
+
|
242
|
+
# app logger
|
243
|
+
$LOG = ::Logger.new("log/#{options.project_name}.log")
|
244
|
+
|
245
|
+
class Sinatra::Base
|
246
|
+
# set sinatra's variables
|
247
|
+
set :environment, :production
|
248
|
+
enable :sessions, :logging, :dump_errors, :show_exceptions
|
249
|
+
disable :run, :reload
|
250
|
+
end
|
251
|
+
|
252
|
+
# app routes
|
253
|
+
App = Rack::Builder.app do
|
254
|
+
|
255
|
+
run #{options.project_name.gsub(/(?:^|_)(.)/) { $1.upcase }}
|
256
|
+
end
|
257
|
+
|
258
|
+
# finally
|
259
|
+
run App
|
260
|
+
|
261
|
+
config_ru
|
262
|
+
|
263
|
+
File.open("#{project_absolute_dir}/config.ru", "w") do |file|
|
264
|
+
file.puts config_ru_contents
|
265
|
+
end
|
266
|
+
|
267
|
+
#====================
|
268
|
+
# create database.yml
|
269
|
+
#====================
|
270
|
+
|
271
|
+
database_yml_contents = <<-database_yml
|
272
|
+
login: &login
|
273
|
+
adapter: mysql
|
274
|
+
username: root
|
275
|
+
password: password
|
276
|
+
host: localhost
|
277
|
+
timezone: SGT
|
278
|
+
reconnect: true
|
279
|
+
|
280
|
+
production:
|
281
|
+
<<: *login
|
282
|
+
database: #{options.project_name}
|
283
|
+
encoding: utf8
|
284
|
+
database_yml
|
285
|
+
|
286
|
+
File.open("#{project_absolute_dir}/database.yml", "w") do |file|
|
287
|
+
file.puts database_yml_contents
|
288
|
+
end
|
289
|
+
|
290
|
+
#=======================
|
291
|
+
# create models.rb
|
292
|
+
#=======================
|
293
|
+
|
294
|
+
models_rb_contents = <<-models_rb
|
295
|
+
require 'activerecord'
|
296
|
+
|
297
|
+
config = YAML.load_file('database.yml')
|
298
|
+
ActiveRecord::Base.establish_connection(config["production"])
|
299
|
+
|
300
|
+
Dir.glob("#{project_absolute_dir}/models/*.rb").each {|model| require model}
|
301
|
+
models_rb
|
302
|
+
|
303
|
+
File.open("#{project_absolute_dir}/models.rb", "w") do |file|
|
304
|
+
file.puts models_rb_contents
|
305
|
+
end
|
138
306
|
end
|
139
307
|
|
308
|
+
|
140
309
|
#==================
|
141
310
|
# create helpers.rb
|
142
311
|
#==================
|
@@ -164,46 +333,6 @@ File.open("#{project_absolute_dir}/helpers/debug_on.rb", "w") do |file|
|
|
164
333
|
file.puts helpers_rb_contents
|
165
334
|
end
|
166
335
|
|
167
|
-
#====================
|
168
|
-
# create database.yml
|
169
|
-
#====================
|
170
|
-
|
171
|
-
database_yml_contents = <<-database_yml
|
172
|
-
login: &login
|
173
|
-
adapter: mysql2
|
174
|
-
username: root
|
175
|
-
password: password
|
176
|
-
host: localhost
|
177
|
-
timezone: SGT
|
178
|
-
reconnect: true
|
179
|
-
|
180
|
-
production:
|
181
|
-
<<: *login
|
182
|
-
database: #{options.project_name}
|
183
|
-
encoding: utf8
|
184
|
-
database_yml
|
185
|
-
|
186
|
-
File.open("#{project_absolute_dir}/database.yml", "w") do |file|
|
187
|
-
file.puts database_yml_contents
|
188
|
-
end
|
189
|
-
|
190
|
-
#=======================
|
191
|
-
# create models.rb
|
192
|
-
#=======================
|
193
|
-
|
194
|
-
models_rb_contents = <<-models_rb
|
195
|
-
require 'mysql2'
|
196
|
-
require 'active_record'
|
197
|
-
|
198
|
-
config = YAML.load_file('database.yml')
|
199
|
-
ActiveRecord::Base.establish_connection(config["production"])
|
200
|
-
|
201
|
-
Dir.glob("#{project_absolute_dir}/models/*.rb").each {|model| require model}
|
202
|
-
models_rb
|
203
|
-
|
204
|
-
File.open("#{project_absolute_dir}/models.rb", "w") do |file|
|
205
|
-
file.puts models_rb_contents
|
206
|
-
end
|
207
336
|
|
208
337
|
#=======================
|
209
338
|
# create project_name.rb
|
data/dindi.gemspec
CHANGED
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
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-11-29 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
16
|
-
requirement: &
|
16
|
+
requirement: &70127703985040 !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: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70127703985040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &70127703984300 !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: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70127703984300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jeweler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70127703983580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.6.4
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70127703983580
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rcov
|
49
|
-
requirement: &
|
49
|
+
requirement: &70127703982760 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70127703982760
|
58
58
|
description: This gem will create a barebone base for a new Sinatra Project
|
59
59
|
email: samuelchandra@yahoo.com
|
60
60
|
executables:
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash:
|
94
|
+
hash: -2284743464459468648
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|