rails_baseline 0.1.9 → 0.2.9
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 +4 -4
- data/README.md +5 -7
- data/lib/rails_baseline/helper_functions.rb +50 -0
- data/lib/rails_baseline/old_template.rb +708 -0
- data/lib/rails_baseline/recipes.yml +0 -0
- data/lib/rails_baseline/template.rb +39 -692
- data/lib/rails_baseline/template_configurations.rb +1 -0
- data/lib/rails_baseline/template_configurations/active_admin.rb +21 -0
- data/lib/rails_baseline/template_configurations/assets.rb +67 -0
- data/lib/rails_baseline/template_configurations/backrground_processor.rb +19 -0
- data/lib/rails_baseline/template_configurations/commands.rb +21 -0
- data/lib/rails_baseline/template_configurations/database.rb +32 -0
- data/lib/rails_baseline/template_configurations/deployment.rb +60 -0
- data/lib/rails_baseline/template_configurations/devise.rb +18 -0
- data/lib/rails_baseline/template_configurations/email.rb +26 -0
- data/lib/rails_baseline/template_configurations/environment.rb +8 -0
- data/lib/rails_baseline/template_configurations/file_upload.rb +8 -0
- data/lib/rails_baseline/template_configurations/jquery_plugins.rb +97 -0
- data/lib/rails_baseline/template_configurations/rails_config.rb +7 -0
- data/lib/rails_baseline/template_configurations/rails_plugins.rb +38 -0
- data/lib/rails_baseline/template_configurations/test_suite.rb +41 -0
- data/lib/rails_baseline/template_configurations/views.rb +65 -0
- data/lib/rails_baseline/version.rb +1 -1
- metadata +22 -3
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/template_configurations/*.rb'].each {|file| require file }
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def active_admin
|
2
|
+
# Disable activeadmin for mongoid at the moment
|
3
|
+
if @configs['database'] != "mongoid"
|
4
|
+
gem 'activeadmin', github: 'activeadmin'
|
5
|
+
|
6
|
+
if yes_wizard?("Active Admin with Users?(no to skip users)")
|
7
|
+
model_name = ask_wizard("Enter the model name of ActiveAdmin. Leave it blank to default as AdminUser.")
|
8
|
+
after_bundler do
|
9
|
+
if model_name.present?
|
10
|
+
generate "active_admin:install #{model_name}"
|
11
|
+
else
|
12
|
+
generate "active_admin:install"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
else
|
16
|
+
after_bundler do
|
17
|
+
generate "active_admin:install --skip-users"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
def quiet_assets
|
2
|
+
gem 'quiet_assets', group: :development
|
3
|
+
end
|
4
|
+
|
5
|
+
def sass
|
6
|
+
after_bundler do
|
7
|
+
copy_file 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.scss'
|
8
|
+
remove_file 'app/assets/stylesheets/application.css'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def bootstrap
|
13
|
+
config_lines = <<-TEXT
|
14
|
+
@import "bootstrap-sprockets";
|
15
|
+
@import "bootstrap";
|
16
|
+
TEXT
|
17
|
+
|
18
|
+
flash_message = <<-TEXT
|
19
|
+
<% flash.each do |name, msg| %>
|
20
|
+
<%
|
21
|
+
code = "warning"
|
22
|
+
desc = "Oh!"
|
23
|
+
case name.to_s
|
24
|
+
when "notice"
|
25
|
+
code = "success"
|
26
|
+
desc = "Done!"
|
27
|
+
when "error"
|
28
|
+
code = "danger"
|
29
|
+
desc = "Alert!"
|
30
|
+
when "info"
|
31
|
+
code = "info"
|
32
|
+
desc = "Info!"
|
33
|
+
end
|
34
|
+
%>
|
35
|
+
<div class="alert alert-<%= code %>">
|
36
|
+
<button type="button" class="close" data-dismiss="alert">x</button>
|
37
|
+
<strong><%= desc %></strong> <%= msg %>
|
38
|
+
</div>
|
39
|
+
<% end %>
|
40
|
+
TEXT
|
41
|
+
|
42
|
+
use_bootstrap = @configs[@current_recipe] = yes_wizard?("Install and configure Bootstrap?")
|
43
|
+
if use_bootstrap
|
44
|
+
gem 'bootstrap-sass', '~> 3.3.4'
|
45
|
+
|
46
|
+
after_bundler do
|
47
|
+
append_to_file 'app/assets/stylesheets/application.css.scss', config_lines
|
48
|
+
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
|
49
|
+
"\n//= require bootstrap-sprockets"
|
50
|
+
end
|
51
|
+
create_file 'app/views/shared/_messages.html.erb', flash_message
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def font_awesome
|
57
|
+
font_awesome_configs = <<-TEXT
|
58
|
+
@import "font-awesome-sprockets";
|
59
|
+
@import "font-awesome";
|
60
|
+
TEXT
|
61
|
+
|
62
|
+
gem 'font-awesome-sass', '~> 4.3.0'
|
63
|
+
|
64
|
+
after_bundler do
|
65
|
+
append_to_file 'app/assets/stylesheets/application.css.scss', font_awesome_configs
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
def background_processor
|
2
|
+
if @configs['database'] == "mongoid"
|
3
|
+
gem 'delayed_job_mongoid'
|
4
|
+
else
|
5
|
+
gem 'delayed_job_active_record'
|
6
|
+
after_bundler do
|
7
|
+
generate "delayed_job:active_record"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
delayed_job_config = <<-TEXT
|
12
|
+
\n
|
13
|
+
config.active_job.queue_adapter = :delayed_job
|
14
|
+
TEXT
|
15
|
+
|
16
|
+
after_bundler do
|
17
|
+
inject_into_file "config/application.rb", delayed_job_config, :after => "# config.i18n.default_locale = :de"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
def git
|
2
|
+
after_everything do
|
3
|
+
git :init
|
4
|
+
git :add => '.'
|
5
|
+
git :commit => '-m "Initial commit"'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def bundler
|
10
|
+
say_wizard "Running Bundler install. This will take a while."
|
11
|
+
run 'bundle install'
|
12
|
+
say_wizard "Running after Bundler callbacks."
|
13
|
+
@after_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
|
14
|
+
|
15
|
+
@current_recipe = nil
|
16
|
+
say_wizard "Running after everything callbacks."
|
17
|
+
@after_everything_blocks.each{|b| config = @configs[b[0]] || {}; @current_recipe = b[0]; b[1].call}
|
18
|
+
|
19
|
+
@current_recipe = nil
|
20
|
+
say_wizard "==================================FINISH PROCESS================================="
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
def database
|
2
|
+
database_option = "activerecord"
|
3
|
+
|
4
|
+
config = {}
|
5
|
+
config['database'] = multiple_choice("Which database are you using?", [["MongoDB", "mongoid"], ["MySQL", "mysql"], ["PostgreSQL", "postgresql"], ["SQLite", "sqlite3"]]) if true && true unless config.key?('database')
|
6
|
+
database_option = config['database']
|
7
|
+
@configs[@current_recipe] = database_option
|
8
|
+
|
9
|
+
|
10
|
+
if config['database']
|
11
|
+
say_wizard "Configuring '#{config['database']}' database settings..."
|
12
|
+
@options = @options.dup.merge(:database => config['database'])
|
13
|
+
say_recipe "Currently selected as #{database_option}"
|
14
|
+
if database_option != "mongoid"
|
15
|
+
config['auto_create'] = yes_wizard?("Automatically create database with default configuration?") if true && true unless config.key?('auto_create')
|
16
|
+
gem gem_for_database[0]
|
17
|
+
template "config/databases/#{@options[:database]}.yml", "config/database.yml.new"
|
18
|
+
run 'mv config/database.yml.new config/database.yml'
|
19
|
+
else
|
20
|
+
database_option = "mongoid"
|
21
|
+
gem 'mongoid'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
after_bundler do
|
26
|
+
if database_option == "activerecord"
|
27
|
+
rake "db:create" if config['auto_create']
|
28
|
+
elsif database_option == "mongoid"
|
29
|
+
generate 'mongoid:config'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
def deployment
|
2
|
+
@configs['deployment'] = multiple_choice("Which deployment method are you using?", [["Heroku", "heroku"], ["Capistrano", "capistrano"], ["Engine Yard", "engineyard"], ["No Recipe", "none"]])
|
3
|
+
|
4
|
+
unicorn_config =<<-TEXT
|
5
|
+
# config/unicorn.rb
|
6
|
+
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
|
7
|
+
timeout 15
|
8
|
+
preload_app true
|
9
|
+
|
10
|
+
before_fork do |server, worker|
|
11
|
+
Signal.trap 'TERM' do
|
12
|
+
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
|
13
|
+
Process.kill 'QUIT', Process.pid
|
14
|
+
end
|
15
|
+
|
16
|
+
defined?(ActiveRecord::Base) and
|
17
|
+
ActiveRecord::Base.connection.disconnect!
|
18
|
+
end
|
19
|
+
|
20
|
+
after_fork do |server, worker|
|
21
|
+
Signal.trap 'TERM' do
|
22
|
+
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
|
23
|
+
end
|
24
|
+
|
25
|
+
defined?(ActiveRecord::Base) and
|
26
|
+
ActiveRecord::Base.establish_connection
|
27
|
+
end
|
28
|
+
TEXT
|
29
|
+
|
30
|
+
ey_config = <<-TEXT
|
31
|
+
---
|
32
|
+
# This is all you need for a typical rails application.
|
33
|
+
defaults:
|
34
|
+
migrate: true
|
35
|
+
migration_command: rake db:migrate
|
36
|
+
precompile_assets: true
|
37
|
+
TEXT
|
38
|
+
|
39
|
+
case @configs['deployment']
|
40
|
+
when "heroku"
|
41
|
+
gem 'unicorn'
|
42
|
+
gem 'rails_12factor', group: :production
|
43
|
+
|
44
|
+
after_bundler do
|
45
|
+
create_file "config/unicorn.rb", unicorn_config
|
46
|
+
create_file "Procfile", "web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb"
|
47
|
+
end
|
48
|
+
when "capistrano"
|
49
|
+
gem 'capistrano'
|
50
|
+
|
51
|
+
after_bundler do
|
52
|
+
run "bundle exec cap install"
|
53
|
+
end
|
54
|
+
|
55
|
+
when "engineyard"
|
56
|
+
after_bundler do
|
57
|
+
create_file "config/ey.yml", ey_config
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
def devise
|
2
|
+
gem 'devise'
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
generate 'devise:install'
|
6
|
+
end
|
7
|
+
|
8
|
+
if yes_wizard?("Generate Devise model?")
|
9
|
+
model_name = ask_wizard("Enter the model name for Devise. Leave it blank to default as User.")
|
10
|
+
after_bundler do
|
11
|
+
if model_name.present?
|
12
|
+
generate "devise #{model_name}"
|
13
|
+
else
|
14
|
+
generate "devise user"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
def smtp
|
2
|
+
email_configuration_text = <<-TEXT
|
3
|
+
\n
|
4
|
+
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
5
|
+
|
6
|
+
config.action_mailer.delivery_method = :smtp
|
7
|
+
config.action_mailer.smtp_settings = {
|
8
|
+
:enable_starttls_auto => true,
|
9
|
+
:address => "smtp.mandrillapp.com",
|
10
|
+
:port => 587,
|
11
|
+
:domain => 'YOUR_DOMAIN',
|
12
|
+
:user_name => "USERNAME",
|
13
|
+
:password => "PASSWORD",
|
14
|
+
:authentication => :plain
|
15
|
+
}
|
16
|
+
TEXT
|
17
|
+
|
18
|
+
after_bundler do
|
19
|
+
inject_into_file 'config/environments/development.rb', email_configuration_text, :after => "config.assets.debug = true"
|
20
|
+
inject_into_file 'config/environments/production.rb', email_configuration_text, :after => "config.active_support.deprecation = :notify"
|
21
|
+
say_wizard "------------------------ EMAIL SETTINGS --------------------------"
|
22
|
+
say_wizard "| Please change your email settings in development.rb |"
|
23
|
+
say_wizard "| and production.rb |"
|
24
|
+
say_wizard "------------------------------------------------------------------"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
def jquery_validation
|
2
|
+
gem "jquery-validation-rails"
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
|
6
|
+
"\n//= require jquery.validate\n//= require jquery.validate.additional-methods"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def jquery_datatable
|
12
|
+
gem 'jquery-datatables-rails', '~> 3.2.0'
|
13
|
+
|
14
|
+
datatable_config_lines_bootstrap = <<-TEXT
|
15
|
+
@import "dataTables/bootstrap/3/jquery.dataTables.bootstrap";
|
16
|
+
TEXT
|
17
|
+
|
18
|
+
datatable_config_lines_non_bootstrap = <<-TEXT
|
19
|
+
@import "dataTables/jquery.dataTables";
|
20
|
+
TEXT
|
21
|
+
|
22
|
+
datatable_model = <<-TEXT
|
23
|
+
class Datatable
|
24
|
+
include ApplicationHelper
|
25
|
+
delegate :params, :t, :h, :current_user, :link_to, to: :@view
|
26
|
+
|
27
|
+
def initialize(view)
|
28
|
+
@view = view
|
29
|
+
end
|
30
|
+
|
31
|
+
def as_json(options = {})
|
32
|
+
{
|
33
|
+
sEcho: params[:sEcho].to_i,
|
34
|
+
iTotalRecords: rows ? rows.count : 0,
|
35
|
+
iTotalDisplayRecords: rows ? rows.total_entries : 0,
|
36
|
+
aaData: data
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def rows
|
42
|
+
@rows ||= fetch_datas
|
43
|
+
end
|
44
|
+
|
45
|
+
def fetch_datas
|
46
|
+
end
|
47
|
+
|
48
|
+
def page
|
49
|
+
params[:iDisplayStart].to_i/per_page + 1
|
50
|
+
end
|
51
|
+
|
52
|
+
def per_page
|
53
|
+
params[:iDisplayLength].to_i > 0 ? params[:iDisplayLength].to_i : 10
|
54
|
+
end
|
55
|
+
|
56
|
+
def columns
|
57
|
+
%w[]
|
58
|
+
end
|
59
|
+
|
60
|
+
def sort_column
|
61
|
+
if params["iSortCol_0"].blank?
|
62
|
+
columns[params[:order]["0"]["column"].to_i]
|
63
|
+
else
|
64
|
+
columns[params["iSortCol_0"].to_i]
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def sort_direction
|
70
|
+
if params["iSortCol_0"].blank?
|
71
|
+
params[:order]["0"]["dir"] == "desc" ? "desc" : "asc"
|
72
|
+
else
|
73
|
+
params["sSortDir_0"] == "desc" ? "desc" : "asc"
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
TEXT
|
79
|
+
|
80
|
+
after_bundler do
|
81
|
+
after_bundler do
|
82
|
+
if @configs["bootstrap"] # if bootstrap configuration is true
|
83
|
+
say_wizard "Generating Bootstrap 3 dataTables"
|
84
|
+
append_to_file 'app/assets/stylesheets/application.css.scss', datatable_config_lines_bootstrap
|
85
|
+
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
|
86
|
+
"\n//= require dataTables/jquery.dataTables\n//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap"
|
87
|
+
end
|
88
|
+
else
|
89
|
+
append_to_file 'app/assets/stylesheets/application.css.scss', datatable_config_lines_non_bootstrap
|
90
|
+
insert_into_file "app/assets/javascripts/application.js", :after => %r{//= require +['"]?jquery_ujs['"]?} do
|
91
|
+
"\n//= require dataTables/jquery.dataTables\n//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
create_file "app/models/datatable.rb", datatable_model
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
def cancancan
|
2
|
+
gem 'cancancan'
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
generate "cancan:ability"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def state_machines
|
10
|
+
if @configs['database'] == "mongoid"
|
11
|
+
gem 'state_machines-mongoid'
|
12
|
+
else
|
13
|
+
gem 'state_machines-activerecord'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def paranoia
|
18
|
+
if @configs['database'] != "mongoid"
|
19
|
+
gem "paranoia"
|
20
|
+
else
|
21
|
+
gem 'mongoid_paranoia'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def debugger
|
26
|
+
gem_group :development do
|
27
|
+
gem "better_errors"
|
28
|
+
gem "hirb"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def kaminari
|
33
|
+
gem 'kaminari'
|
34
|
+
|
35
|
+
after_bundler do
|
36
|
+
generate "kaminari:views bootstrap3" if @configs["bootstrap"]
|
37
|
+
end
|
38
|
+
end
|