rails_baseline 0.1.3

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5ba8dfa939906dcbdf9584f578e7f96bcf639d01
4
+ data.tar.gz: 9b097bc63311f9f568469c0462362d07d3178b10
5
+ SHA512:
6
+ metadata.gz: 71af800882a0db5adbd959b45df9af8d15dca905f1db098f369aedb26cd71ae7d72f98280b7d6d29333794b8968959e9a8e703dac9d111f00d12ef52b9f1f1ae
7
+ data.tar.gz: 91b10c56f60c052e56146882533a30528dc18bae5cc8ffe301ed2297c62ef1beb551cdaef5db10fe3ae9a0e396935fd462986eabaf972c8982a5dc72b453d099
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_baseline.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Yoon Wai Yan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ ## !!Under Active Development
2
+
3
+ This gem is still under active development.
4
+
5
+ # Rails 4.2 Baseline
6
+
7
+ This gem is a wrapper of a Rails Applications Template to create a new Rails 4.2 application based on the normal practices in [cloudcoder.com.my](http://cloudcoder.com.my). Just go through a simple wizard to get all the gems set and you'll be good to proceed with migrations and start coding your project.
8
+
9
+ This gem is heavily based on [rails_wizard](https://github.com/intridea/rails_wizard) for the overall idea of the gem and refers to [rails-composer](https://github.com/RailsApps/rails-composer) for the code organization.
10
+
11
+ ## Installation
12
+
13
+ $ gem install rails_baseline
14
+
15
+ ## Usage
16
+
17
+ Create a new Rails app:
18
+
19
+ $ rails_baseline new APP_NAME
20
+
21
+ Please replace APP_NAME with your new Rails app name.
22
+
23
+ List out all available recipes:
24
+
25
+ $ rails_baseline list
26
+
27
+ ## Changelog
28
+
29
+ 1. 0.0.5 - Executable file
30
+ 2. 0.1.0 - Rearrange wizard orders and order listing
31
+ 3. 0.1.1 - Added jQuery Validation, CanCanCan and Google Tag Manager
32
+ 3. 0.1.2 - Added Paranoia, Better Errors, Hirb and jQuery DataTables
33
+ 4. 0.1.3 - Added Quiet Assets, Decent Exposure, Paperclip, State Machines, Delayed Job and Kaminari
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/cloudcodermy/baseline/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
5
+
6
+ require 'rails_baseline'
7
+ require 'rails_baseline/command'
8
+
9
+ RailsBaseline::Command.start ARGV
@@ -0,0 +1 @@
1
+ require "rails_baseline/version"
@@ -0,0 +1,40 @@
1
+ require "thor"
2
+
3
+ module RailsBaseline
4
+ class Command < Thor
5
+ include Thor::Actions
6
+ desc "new APP_NAME", "create a new Rails app"
7
+ def new(name)
8
+ run_template(name)
9
+ end
10
+
11
+ desc "list", "list all recipes"
12
+ def list
13
+ list_all_recipes
14
+ end
15
+
16
+ no_tasks do
17
+ def cyan; "\033[36m" end
18
+ def clear; "\033[0m" end
19
+ def bold; "\033[1m" end
20
+ def red; "\033[31m" end
21
+ def green; "\033[32m" end
22
+ def yellow; "\033[33m" end
23
+
24
+ def run_template(name)
25
+ puts "#{bold}Generating and Running Template..."
26
+ template_path = File.join( File.dirname(__FILE__), 'template.rb' )
27
+ file = File.open( template_path )
28
+ system "rails new #{name} -m #{file.path} --skip-bundle"
29
+ end
30
+
31
+ def list_all_recipes
32
+ puts "#{yellow}All recipes in order:#{clear}"
33
+ recipes_list_path = File.join( File.dirname(__FILE__), 'recipes.txt' )
34
+ File.open(recipes_list_path, "r").each_line.with_index do |line, index|
35
+ puts "#{index+1}. #{line}"
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,23 @@
1
+ Rails Deflator
2
+ SMTP Configurations
3
+ Rails Config
4
+ Quiet Assets
5
+ RSpec test suite
6
+ Database(Mongoid, MySQL, Postgresql, SQLite)
7
+ Devise
8
+ ActiveAdmin
9
+ CanCanCan
10
+ Decent Exposure
11
+ Paperclip
12
+ State Machines
13
+ Delayed Job
14
+ Application views
15
+ Paranoia
16
+ Better Errors
17
+ Hirb
18
+ SASS
19
+ Bootstrap
20
+ jQuery Validate
21
+ jQuery dataTables
22
+ Kaminari
23
+ Git
@@ -0,0 +1,544 @@
1
+ # >----------------------------[ Initial Setup ]------------------------------<
2
+
3
+ # @recipes = ["database", "mongoid", "devise", "activeadmin", "git", "sass"]
4
+ @database_choice = nil
5
+
6
+ def recipes; @recipes end
7
+ def recipe?(name); @recipes.include?(name) end
8
+
9
+ def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + " #{text}" end
10
+ def say_recipe(name); say "\033[1m\033[36m" + "recipe".rjust(10) + "\033[0m" + " Running #{name} recipe..." end
11
+ def say_wizard(text); say_custom(@current_recipe || 'wizard', text) end
12
+
13
+ def ask_wizard(question)
14
+ ask "\033[1m\033[30m\033[46m" + (@current_recipe || "prompt").rjust(10) + "\033[0m\033[36m" + " #{question}\033[0m"
15
+ end
16
+
17
+ def yes_wizard?(question)
18
+ answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
19
+ case answer.downcase
20
+ when "yes", "y"
21
+ true
22
+ when "no", "n"
23
+ false
24
+ else
25
+ yes_wizard?(question)
26
+ end
27
+ end
28
+
29
+ def no_wizard?(question); !yes_wizard?(question) end
30
+
31
+ def multiple_choice(question, choices)
32
+ say_custom('question', question)
33
+ values = {}
34
+ choices.each_with_index do |choice,i|
35
+ values[(i + 1).to_s] = choice[1]
36
+ say_custom (i + 1).to_s + ')', choice[0]
37
+ end
38
+ answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
39
+ values[answer]
40
+ end
41
+
42
+ @current_recipe = nil
43
+ @configs = {}
44
+
45
+ @after_blocks = []
46
+ def after_bundler(&block); @after_blocks << [@current_recipe, block]; end
47
+ @after_everything_blocks = []
48
+ def after_everything(&block); @after_everything_blocks << [@current_recipe, block]; end
49
+ @before_configs = {}
50
+ def before_config(&block); @before_configs[@current_recipe] = block; end
51
+
52
+ # >-----------------------[ Deflator and Autoloads ]--------------------------<
53
+ @current_recipe = "deflator"
54
+
55
+ insertion_text = <<-TEXT
56
+ \n
57
+ config.middleware.use Rack::Deflater
58
+ TEXT
59
+
60
+ inject_into_file "config/application.rb", insertion_text, :after => "# config.i18n.default_locale = :de"
61
+
62
+ # >--------------------------------[ Email Settings ]---------------------------------<
63
+ @current_recipe = "smtp"
64
+
65
+ email_configuration_text = <<-TEXT
66
+ \n
67
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
68
+
69
+ config.action_mailer.delivery_method = :smtp
70
+ config.action_mailer.smtp_settings = {
71
+ :enable_starttls_auto => true,
72
+ :address => "smtp.mandrillapp.com",
73
+ :port => 587,
74
+ :domain => 'YOUR_DOMAIN',
75
+ :user_name => "USERNAME",
76
+ :password => "PASSWORD",
77
+ :authentication => :plain
78
+ }
79
+ TEXT
80
+
81
+ after_bundler do
82
+ inject_into_file 'config/environments/development.rb', email_configuration_text, :after => "config.assets.debug = true"
83
+ inject_into_file 'config/environments/production.rb', email_configuration_text, :after => "config.active_support.deprecation = :notify"
84
+ say_wizard "------------------------ EMAIL SETTINGS --------------------------"
85
+ say_wizard "| Please change your email settings in development.rb |"
86
+ say_wizard "| and production.rb |"
87
+ say_wizard "------------------------------------------------------------------"
88
+ end
89
+
90
+ # >--------------------------------[ Rails Config ]---------------------------------<
91
+
92
+ @current_recipe = "rails_config"
93
+ @before_configs["rails_config"].call if @before_configs["rails_config"]
94
+ say_recipe 'Rails Config'
95
+
96
+ gem 'rails_config', '0.5.0.beta1'
97
+
98
+ after_bundler do
99
+ generate 'rails_config:install'
100
+ end
101
+
102
+ # >--------------------------------[ Quiet Assets ]---------------------------------<
103
+
104
+ @current_recipe = "quiet_assets"
105
+ @before_configs["quiet_assets"].call if @before_configs["quiet_assets"]
106
+ say_recipe 'Quiet Assets'
107
+
108
+ gem 'quiet_assets', group: :development
109
+
110
+ # >--------------------------------[ RSpec ]---------------------------------<
111
+ @current_recipe = "rspec"
112
+ @before_configs["rspec"].call if @before_configs["rspec"]
113
+ say_recipe 'RSpec'
114
+
115
+ gem_group :development do
116
+ gem 'spring-commands-rspec'
117
+ gem 'rails_apps_testing'
118
+ end
119
+
120
+ gem_group :development, :test do
121
+ gem "rspec-rails"
122
+ gem 'factory_girl_rails'
123
+ gem 'faker'
124
+ end
125
+
126
+ gem_group :test do
127
+ gem 'capybara'
128
+ gem 'database_cleaner'
129
+ gem 'launchy'
130
+ gem 'selenium-webdriver'
131
+ end
132
+
133
+ rspec_text = <<-TEXT
134
+ \n
135
+ config.generators do |g|
136
+ g.test_framework :rspec,
137
+ fixtures: true,
138
+ view_specs: false,
139
+ helper_specs: false,
140
+ routing_specs: false,
141
+ controller_specs: true,
142
+ request_specs: false
143
+ g.fixture_replacement :factory_girl, dir: "spec/factories"
144
+ end
145
+ TEXT
146
+
147
+ after_bundler do
148
+ run 'bundle binstubs rspec-core'
149
+ generate 'rspec:install'
150
+ remove_dir 'test'
151
+
152
+ inject_into_file "config/application.rb", rspec_text, :after => "# config.i18n.default_locale = :de"
153
+ end
154
+
155
+ # >---------------------------[ ActiveRecord/Mongoid ]----------------------------<
156
+
157
+ @current_recipe = "database"
158
+ @before_configs["activerecord"].call if @before_configs["activerecord"]
159
+ say_recipe 'Database'
160
+
161
+ database_option = "activerecord"
162
+
163
+ config = {}
164
+ config['database'] = multiple_choice("Which database are you using?", [["MongoDB", "mongoid"], ["MySQL", "mysql"], ["PostgreSQL", "postgresql"], ["SQLite", "sqlite3"]]) if true && true unless config.key?('database')
165
+ database_option = config['database']
166
+ @configs[@current_recipe] = config
167
+
168
+
169
+ if config['database']
170
+ say_wizard "Configuring '#{config['database']}' database settings..."
171
+ @options = @options.dup.merge(:database => config['database'])
172
+ say_recipe "Currently selected as #{database_option}"
173
+ if database_option != "mongoid"
174
+ config['auto_create'] = yes_wizard?("Automatically create database with default configuration?") if true && true unless config.key?('auto_create')
175
+ gem gem_for_database
176
+ template "config/databases/#{@options[:database]}.yml", "config/database.yml.new"
177
+ run 'mv config/database.yml.new config/database.yml'
178
+ else
179
+ database_option = "mongoid"
180
+ gem 'mongoid', '~> 4.0.0'
181
+ end
182
+ end
183
+
184
+ after_bundler do
185
+ if database_option == "activerecord"
186
+ rake "db:create" if config['auto_create']
187
+ elsif database_option == "mongoid"
188
+ generate 'mongoid:config'
189
+ end
190
+ end
191
+
192
+ # >--------------------------------[ Devise ]---------------------------------<
193
+
194
+ @current_recipe = "devise"
195
+ @before_configs["devise"].call if @before_configs["devise"]
196
+ say_recipe 'Devise'
197
+
198
+ gem 'devise'
199
+
200
+ after_bundler do
201
+ generate 'devise:install'
202
+ end
203
+
204
+ if yes_wizard?("Generate Devise model?")
205
+ model_name = ask_wizard("Enter the model name for Devise. Leave it blank to default as User.")
206
+ after_bundler do
207
+ if model_name.present?
208
+ generate "devise #{model_name}"
209
+ else
210
+ generate "devise user"
211
+ end
212
+ end
213
+ end
214
+
215
+ # >--------------------------------[ Active Admin ]---------------------------------<
216
+
217
+ # Disable activeadmin for mongoid at the moment
218
+ if config['database'] != "mongoid"
219
+ @current_recipe = "activeadmin"
220
+ @before_configs["activeadmin"].call if @before_configs["activeadmin"]
221
+ say_recipe 'Active Admin'
222
+
223
+ gem 'activeadmin', github: 'activeadmin'
224
+
225
+ if yes_wizard?("Active Admin with Users?(no to skip users)")
226
+ model_name = ask_wizard("Enter the model name of ActiveAdmin. Leave it blank to default as AdminUser.")
227
+ after_bundler do
228
+ if model_name.present?
229
+ generate "active_admin:install #{model_name}"
230
+ else
231
+ generate "active_admin:install"
232
+ end
233
+ end
234
+ else
235
+ after_bundler do
236
+ generate "active_admin:install --skip-users"
237
+ end
238
+ end
239
+ end
240
+
241
+ # >--------------------------------[ CanCanCan ]---------------------------------<
242
+
243
+ @current_recipe = "cancancan"
244
+ @before_configs["cancancan"].call if @before_configs["cancancan"]
245
+ say_recipe 'CanCanCan'
246
+
247
+ gem 'cancancan', '~> 1.10'
248
+
249
+ after_bundler do
250
+ generate "cancan:ability"
251
+ end
252
+
253
+ # >-----------------------------[ Decent Exposure ]------------------------------<
254
+
255
+ @current_recipe = "decent_exposure"
256
+ @before_configs["decent_exposure"].call if @before_configs["decent_exposure"]
257
+ say_recipe 'Decent Exposure'
258
+
259
+ gem 'decent_exposure', '~> 2.3.2'
260
+
261
+ decent_exposure_strong_parameters = <<-TEXT
262
+ \n
263
+ decent_configuration do
264
+ strategy DecentExposure::StrongParametersStrategy
265
+ end
266
+ TEXT
267
+
268
+ after_bundler do
269
+ inject_into_file "app/controllers/application_controller.rb", decent_exposure_strong_parameters, :after => "protect_from_forgery with: :exception"
270
+ end
271
+
272
+ # >--------------------------------[ Paperclip ]---------------------------------<
273
+
274
+ @current_recipe = "paperclip"
275
+ @before_configs["paperclip"].call if @before_configs["paperclip"]
276
+ say_recipe 'Paperclip'
277
+
278
+ if config['database'] == "mongoid"
279
+ gem "mongoid-paperclip", :require => "mongoid_paperclip"
280
+ gem 'aws-sdk', '~> 1.3.4'
281
+ else
282
+ gem "paperclip", "~> 4.2"
283
+ end
284
+
285
+ # >--------------------------------[ State Machines ]---------------------------------<
286
+
287
+ @current_recipe = "state_machines"
288
+ @before_configs["state_machines"].call if @before_configs["state_machines"]
289
+ say_recipe 'State Machines'
290
+
291
+ if config['database'] == "mongoid"
292
+ gem 'state_machines-mongoid'
293
+ else
294
+ gem 'state_machines-activerecord'
295
+ end
296
+
297
+ # >--------------------------------[ Delayed Job ]---------------------------------<
298
+
299
+ @current_recipe = "delayed_job"
300
+ @before_configs["delayed_job"].call if @before_configs["delayed_job"]
301
+ say_recipe 'Delayed Job'
302
+
303
+ if config['database'] == "mongoid"
304
+ gem 'delayed_job_mongoid'
305
+ else
306
+ gem 'delayed_job_active_record'
307
+ after_bundler do
308
+ generate "delayed_job:active_record"
309
+ end
310
+ end
311
+
312
+ delayed_job_config = <<-TEXT
313
+ \n
314
+ config.active_job.queue_adapter = :delayed_job
315
+ TEXT
316
+
317
+ after_bundler do
318
+ inject_into_file "config/application.rb", delayed_job_config, :after => "# config.i18n.default_locale = :de"
319
+ end
320
+ # >---------------------------[ Application Views ]------------------------------<
321
+ @current_recipe = "application"
322
+ @before_configs["application"].call if @before_configs["application"]
323
+ say_recipe 'Application Views'
324
+
325
+ application_html_file = <<-TEXT
326
+ <!DOCTYPE html>
327
+ <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
328
+ <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
329
+ <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
330
+ <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
331
+ <html>
332
+ <head>
333
+ <meta charset="utf-8">
334
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
335
+ <meta name="viewport" content="width=device-width, initial-scale=1">
336
+ <title>Title</title>
337
+ <meta name="description" content="This is the description">
338
+ <meta content="width=device-width, initial-scale=1.0" name="viewport">
339
+
340
+ <meta property="og:title" content="Title" />
341
+ <meta property="og:type" content="article" />
342
+ <meta property="og:url" content="<%= root_url %>" />
343
+ <meta property="og:image" content="<%= root_url %>/logo.png" />
344
+ <meta property="og:description" content="This is the description" />
345
+
346
+ <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
347
+ <%= csrf_meta_tags %>
348
+ <!--[if lt IE 9]>
349
+ <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
350
+ <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
351
+ <![endif]-->
352
+ </head>
353
+ <body>
354
+ <!--[if lt IE 7]>
355
+ <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
356
+ <![endif]-->
357
+ <!-- Google Tag Manager -->
358
+ <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
359
+ height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
360
+ <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
361
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
362
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
363
+ '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
364
+ })(window,document,'script','dataLayer','GTM-XXXXXX');</script>
365
+ <!-- End Google Tag Manager -->
366
+
367
+ <%= yield %>
368
+
369
+ <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
370
+ </body>
371
+ </html>
372
+ TEXT
373
+
374
+ after_bundler do
375
+ remove_file 'app/views/layouts/application.html.erb'
376
+ create_file 'app/views/layouts/application.html.erb', application_html_file
377
+ say_wizard "--------------------------- APPLICATION VIEWS -----------------------------"
378
+ say_wizard "|Please change your GTM, title and meta settings in application.html.erb. |"
379
+ say_wizard "---------------------------------------------------------------------------"
380
+ end
381
+
382
+ # >--------------------------------[ Paranoia ]-----------------------------------<
383
+
384
+ @current_recipe = "paranoia"
385
+ @before_configs["paranoia"].call if @before_configs["paranoia"]
386
+ say_recipe 'Paranoia'
387
+
388
+ gem "paranoia", "~> 2.0"
389
+
390
+ # >------------------------[ Better Errors and Hirb ]-----------------------------<
391
+
392
+ @current_recipe = "better_errors"
393
+ @before_configs["better_errors"].call if @before_configs["better_errors"]
394
+ say_recipe 'Better Errors and Hirb'
395
+
396
+ gem_group :development do
397
+ gem "better_errors"
398
+ gem "hirb"
399
+ end
400
+
401
+ # >-------------------------------[ Setup SASS ]----------------------------------<
402
+
403
+ @current_recipe = "sass"
404
+ @before_configs["sass"].call if @before_configs["sass"]
405
+ say_recipe 'SASS'
406
+
407
+ after_bundler do
408
+ copy_file 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.scss'
409
+ remove_file 'app/assets/stylesheets/application.css'
410
+ end
411
+
412
+ # >--------------------------------[ Bootstrap ]---------------------------------<
413
+
414
+ @current_recipe = "bootstrap"
415
+ @before_configs["bootstrap"].call if @before_configs["bootstrap"]
416
+ say_recipe 'Bootstrap Front End'
417
+
418
+ config_lines = <<-TEXT
419
+ @import "bootstrap-sprockets";
420
+ @import "bootstrap";
421
+ TEXT
422
+
423
+ flash_message = <<-TEXT
424
+ <% flash.each do |name, msg| %>
425
+ <%
426
+ code = "warning"
427
+ desc = "Oh!"
428
+ case name.to_s
429
+ when "notice"
430
+ code = "success"
431
+ desc = "Done!"
432
+ when "error"
433
+ code = "danger"
434
+ desc = "Alert!"
435
+ when "info"
436
+ code = "info"
437
+ desc = "Info!"
438
+ end
439
+ %>
440
+ <div class="alert alert-<%= code %>">
441
+ <button type="button" class="close" data-dismiss="alert">x</button>
442
+ <strong><%= desc %></strong> <%= msg %>
443
+ </div>
444
+ <% end %>
445
+ TEXT
446
+
447
+ use_bootstrap = @configs[@current_recipe] = yes_wizard?("Install and configure Bootstrap?")
448
+ if use_bootstrap
449
+ gem 'bootstrap-sass', '~> 3.3.4'
450
+
451
+ after_bundler do
452
+ append_to_file 'app/assets/stylesheets/application.css.scss', config_lines
453
+ insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
454
+ "\n//= require bootstrap-sprockets"
455
+ end
456
+ create_file 'app/views/shared/_messages.html.erb', flash_message
457
+ end
458
+ end
459
+
460
+ # >--------------------------[ jQuery Validation ]-----------------------------<
461
+
462
+ @current_recipe = "jquery-validation-rails"
463
+ @before_configs["jquery-validation-rails"].call if @before_configs["jquery-validation-rails"]
464
+ say_recipe 'jQuery Validation Rails'
465
+
466
+ gem "jquery-validation-rails"
467
+
468
+ after_bundler do
469
+ insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
470
+ "\n//= require jquery.validate\n//= require jquery.validate.additional-methods"
471
+ end
472
+ end
473
+
474
+ # >--------------------------[ jQuery dataTables ]-----------------------------<
475
+
476
+ @current_recipe = "jquery-datatables-rails"
477
+ @before_configs["jquery-datatables-rails"].call if @before_configs["jquery-datatables-rails"]
478
+ say_recipe 'jQuery dataTables Rails'
479
+
480
+ gem 'jquery-datatables-rails', '~> 3.2.0'
481
+
482
+ datatable_config_lines_bootstrap = <<-TEXT
483
+ @import "dataTables/bootstrap/3/jquery.dataTables.bootstrap";
484
+ TEXT
485
+
486
+ datatable_config_lines_non_bootstrap = <<-TEXT
487
+ @import "dataTables/jquery.dataTables";
488
+ TEXT
489
+
490
+ after_bundler do
491
+ after_bundler do
492
+ if @configs["bootstrap"] # if bootstrap configuration is true
493
+ say_wizard "Generating Bootstrap 3 dataTables"
494
+ append_to_file 'app/assets/stylesheets/application.css.scss', datatable_config_lines_bootstrap
495
+ insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
496
+ "\n//= require dataTables/jquery.dataTables\n//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap"
497
+ end
498
+ else
499
+ append_to_file 'app/assets/stylesheets/application.css.scss', datatable_config_lines_non_bootstrap
500
+ insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
501
+ "\n//= require dataTables/jquery.dataTables\n//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap"
502
+ end
503
+ end
504
+ end
505
+ end
506
+
507
+ # >-----------------------------[ Kaminari ]------------------------------<
508
+
509
+ @current_recipe = "kaminari"
510
+ @before_configs["kaminari"].call if @before_configs["kaminari"]
511
+ say_recipe 'Kaminari'
512
+
513
+ gem 'kaminari'
514
+
515
+ after_bundler do
516
+ generate "kaminari:views bootstrap3" if @configs["bootstrap"]
517
+ end
518
+
519
+ # >----------------------------------[ Git ]----------------------------------<
520
+
521
+ @current_recipe = "git"
522
+ @before_configs["git"].call if @before_configs["git"]
523
+ say_recipe 'Git'
524
+
525
+ after_everything do
526
+ git :init
527
+ git :add => '.'
528
+ git :commit => '-m "Initial commit"'
529
+ end
530
+
531
+ # >-----------------------------[ Run Bundler ]-------------------------------<
532
+ @current_recipe = "bundler"
533
+
534
+ say_wizard "Running Bundler install. This will take a while."
535
+ run 'bundle install'
536
+ say_wizard "Running after Bundler callbacks."
537
+ @after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
538
+
539
+ @current_recipe = nil
540
+ say_wizard "Running after everything callbacks."
541
+ @after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
542
+
543
+ @current_recipe = nil
544
+ say_wizard "==================================FINISH PROCESS================================="
@@ -0,0 +1,3 @@
1
+ module RailsBaseline
2
+ VERSION = "0.1.3"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_baseline/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_baseline"
8
+ spec.version = RailsBaseline::VERSION
9
+ spec.authors = ["Yoon Wai Yan"]
10
+ spec.email = ["waiyan@cloudcoder.com.my"]
11
+ spec.summary = %q{Rails 4.2 template}
12
+ spec.description = %q{Create baseline rails app with ease. Based on the normal practices by Cloud Coder team.}
13
+ spec.homepage = "https://github.com/cloudcodermy/baseline"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_runtime_dependency 'thor', '~> 0.19', '>= 0.19.1'
25
+ spec.add_runtime_dependency 'rails', '~> 4.2', '>= 4.2.0'
26
+ spec.add_runtime_dependency 'rspec', '~> 3.2', '>= 3.2.0'
27
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_baseline
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Yoon Wai Yan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.19'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.19.1
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '0.19'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.19.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '4.2'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 4.2.0
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '4.2'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 4.2.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3.2'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.2.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.2'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 3.2.0
101
+ description: Create baseline rails app with ease. Based on the normal practices by
102
+ Cloud Coder team.
103
+ email:
104
+ - waiyan@cloudcoder.com.my
105
+ executables:
106
+ - rails_baseline
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - Gemfile
112
+ - LICENSE.txt
113
+ - README.md
114
+ - Rakefile
115
+ - bin/rails_baseline
116
+ - lib/rails_baseline.rb
117
+ - lib/rails_baseline/command.rb
118
+ - lib/rails_baseline/recipes.txt
119
+ - lib/rails_baseline/template.rb
120
+ - lib/rails_baseline/version.rb
121
+ - rails_baseline.gemspec
122
+ homepage: https://github.com/cloudcodermy/baseline
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.2.2
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Rails 4.2 template
146
+ test_files: []