railsqs 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +120 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/Rakefile +3 -0
- data/bin/railsqs +14 -0
- data/bin/rake +16 -0
- data/bin/setup +13 -0
- data/lib/railsqs/actions.rb +25 -0
- data/lib/railsqs/app_builder.rb +270 -0
- data/lib/railsqs/generators/app_generator.rb +177 -0
- data/lib/railsqs/version.rb +5 -0
- data/lib/railsqs.rb +4 -0
- data/railsqs.gemspec +34 -0
- data/templates/#bin_setup.erb# +34 -0
- data/templates/Gemfile.erb +64 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +35 -0
- data/templates/_flashes.html.erb +9 -0
- data/templates/_footer.html.erb +0 -0
- data/templates/_javascript.html.erb +10 -0
- data/templates/_navigation.html.erb +20 -0
- data/templates/application.css.scss +10 -0
- data/templates/bin_setup.erb +37 -0
- data/templates/bootstrap.scss +50 -0
- data/templates/config_i18n_tasks.yml +13 -0
- data/templates/config_locales_en.yml +19 -0
- data/templates/development_seeds.rb +7 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +34 -0
- data/templates/newrelic.yml.erb +34 -0
- data/templates/postgresql_database.yml.erb +12 -0
- data/templates/puma.rb +158 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/railsqs_gitignore +13 -0
- data/templates/railsqs_layout.html.erb.erb +24 -0
- data/templates/sample.env +3 -0
- data/templates/secrets.yml +14 -0
- data/templates/smtp.rb +9 -0
- data/templates/staging.rb +5 -0
- data/templates/unicorn.rb +30 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7081ede2a0efa99e1833f0dd1e329ab285fb0199
|
4
|
+
data.tar.gz: d44e00090ea78895644250d25cfa90c9c23f374d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 675976cb7f541f64ff7aa1a869149567af0f27402a0352e4126b139c5887701e75a03579a911c7cfd50471be39c978e6d8600f0d9c593605d943fb9cb40ed52b
|
7
|
+
data.tar.gz: 7c38316111e4e93933ca848c8a377ec6a36f04ef8a2b85fc24486d79c4d2c65cf3ad32b2d6cd3541390c1e9f841f388a2324b087953d80d35f7bd3469aacf995
|
data/.gitignore
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
railsqs (1.0.0)
|
5
|
+
bitters (~> 0.10.0)
|
6
|
+
bundler (~> 1.3)
|
7
|
+
rails (= 4.2.0.beta2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (4.2.0.beta2)
|
13
|
+
actionpack (= 4.2.0.beta2)
|
14
|
+
actionview (= 4.2.0.beta2)
|
15
|
+
activejob (= 4.2.0.beta2)
|
16
|
+
mail (~> 2.5, >= 2.5.4)
|
17
|
+
rails-dom-testing (~> 1.0, >= 1.0.3)
|
18
|
+
actionpack (4.2.0.beta2)
|
19
|
+
actionview (= 4.2.0.beta2)
|
20
|
+
activesupport (= 4.2.0.beta2)
|
21
|
+
rack (~> 1.6.0.beta)
|
22
|
+
rack-test (~> 0.6.2)
|
23
|
+
rails-dom-testing (~> 1.0, >= 1.0.3)
|
24
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
25
|
+
actionview (4.2.0.beta2)
|
26
|
+
activesupport (= 4.2.0.beta2)
|
27
|
+
builder (~> 3.1)
|
28
|
+
erubis (~> 2.7.0)
|
29
|
+
rails-dom-testing (~> 1.0, >= 1.0.3)
|
30
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
31
|
+
activejob (4.2.0.beta2)
|
32
|
+
activesupport (= 4.2.0.beta2)
|
33
|
+
globalid (>= 0.3.0)
|
34
|
+
activemodel (4.2.0.beta2)
|
35
|
+
activesupport (= 4.2.0.beta2)
|
36
|
+
builder (~> 3.1)
|
37
|
+
activerecord (4.2.0.beta2)
|
38
|
+
activemodel (= 4.2.0.beta2)
|
39
|
+
activesupport (= 4.2.0.beta2)
|
40
|
+
arel (>= 6.0.0.beta1, < 6.1)
|
41
|
+
activesupport (4.2.0.beta2)
|
42
|
+
i18n (>= 0.7.0.beta1, < 0.8)
|
43
|
+
json (~> 1.7, >= 1.7.7)
|
44
|
+
minitest (~> 5.1)
|
45
|
+
thread_safe (~> 0.1)
|
46
|
+
tzinfo (~> 1.1)
|
47
|
+
arel (6.0.0.beta1)
|
48
|
+
bitters (0.10.1)
|
49
|
+
bourbon (>= 3.2)
|
50
|
+
sass (>= 3.2)
|
51
|
+
thor
|
52
|
+
bourbon (4.0.2)
|
53
|
+
sass (~> 3.3)
|
54
|
+
thor
|
55
|
+
builder (3.2.2)
|
56
|
+
erubis (2.7.0)
|
57
|
+
globalid (0.3.0)
|
58
|
+
activesupport (>= 4.1.0)
|
59
|
+
hike (1.2.3)
|
60
|
+
i18n (0.7.0.beta1)
|
61
|
+
json (1.8.1)
|
62
|
+
loofah (2.0.1)
|
63
|
+
nokogiri (>= 1.5.9)
|
64
|
+
mail (2.6.1)
|
65
|
+
mime-types (>= 1.16, < 3)
|
66
|
+
mime-types (2.4.2)
|
67
|
+
mini_portile (0.6.0)
|
68
|
+
minitest (5.4.2)
|
69
|
+
multi_json (1.10.1)
|
70
|
+
nokogiri (1.6.3.1)
|
71
|
+
mini_portile (= 0.6.0)
|
72
|
+
rack (1.6.0.beta)
|
73
|
+
rack-test (0.6.2)
|
74
|
+
rack (>= 1.0)
|
75
|
+
rails (4.2.0.beta2)
|
76
|
+
actionmailer (= 4.2.0.beta2)
|
77
|
+
actionpack (= 4.2.0.beta2)
|
78
|
+
actionview (= 4.2.0.beta2)
|
79
|
+
activejob (= 4.2.0.beta2)
|
80
|
+
activemodel (= 4.2.0.beta2)
|
81
|
+
activerecord (= 4.2.0.beta2)
|
82
|
+
activesupport (= 4.2.0.beta2)
|
83
|
+
bundler (>= 1.3.0, < 2.0)
|
84
|
+
railties (= 4.2.0.beta2)
|
85
|
+
sprockets-rails (~> 3.0.0.beta1)
|
86
|
+
rails-deprecated_sanitizer (1.0.3)
|
87
|
+
activesupport (>= 4.2.0.alpha)
|
88
|
+
rails-dom-testing (1.0.4)
|
89
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
90
|
+
nokogiri (~> 1.6.0)
|
91
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
92
|
+
rails-html-sanitizer (1.0.1)
|
93
|
+
loofah (~> 2.0)
|
94
|
+
railties (4.2.0.beta2)
|
95
|
+
actionpack (= 4.2.0.beta2)
|
96
|
+
activesupport (= 4.2.0.beta2)
|
97
|
+
rake (>= 0.8.7)
|
98
|
+
thor (>= 0.18.1, < 2.0)
|
99
|
+
rake (10.3.2)
|
100
|
+
sass (3.4.5)
|
101
|
+
sprockets (2.12.2)
|
102
|
+
hike (~> 1.2)
|
103
|
+
multi_json (~> 1.0)
|
104
|
+
rack (~> 1.0)
|
105
|
+
tilt (~> 1.1, != 1.3.0)
|
106
|
+
sprockets-rails (3.0.0.beta1)
|
107
|
+
actionpack (>= 4.0)
|
108
|
+
activesupport (>= 4.0)
|
109
|
+
sprockets (~> 2.8)
|
110
|
+
thor (0.19.1)
|
111
|
+
thread_safe (0.3.4)
|
112
|
+
tilt (1.4.1)
|
113
|
+
tzinfo (1.2.2)
|
114
|
+
thread_safe (~> 0.1)
|
115
|
+
|
116
|
+
PLATFORMS
|
117
|
+
ruby
|
118
|
+
|
119
|
+
DEPENDENCIES
|
120
|
+
railsqs!
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2010-2012 Mike Burns and thoughtbot, inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/railsqs
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
source_path = (Pathname.new(__FILE__).dirname + '../lib').expand_path
|
5
|
+
$LOAD_PATH << source_path
|
6
|
+
|
7
|
+
require 'railsqs'
|
8
|
+
|
9
|
+
|
10
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
11
|
+
Railsqs::AppGenerator.source_root templates_root
|
12
|
+
Railsqs::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
13
|
+
|
14
|
+
Railsqs::AppGenerator.start
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/setup
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
# Run this script immediately after cloning the codebase.
|
4
|
+
|
5
|
+
# Exit if any subcommand fails
|
6
|
+
set -e
|
7
|
+
|
8
|
+
# Set up Ruby dependencies via Bundler
|
9
|
+
bundle install
|
10
|
+
|
11
|
+
# Add binstubs to PATH in ~/.zshenv like this:
|
12
|
+
# export PATH=".git/safe/../../bin:$PATH"
|
13
|
+
mkdir -p .git/safe
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Railsqs
|
2
|
+
module Actions
|
3
|
+
def replace_in_file(relative_path, find, replace)
|
4
|
+
path = File.join(destination_root, relative_path)
|
5
|
+
contents = IO.read(path)
|
6
|
+
unless contents.gsub!(find, replace)
|
7
|
+
raise "#{find.inspect} not found in #{relative_path}"
|
8
|
+
end
|
9
|
+
File.open(path, "w") { |file| file.write(contents) }
|
10
|
+
end
|
11
|
+
|
12
|
+
def action_mailer_host(rails_env, host)
|
13
|
+
host_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
|
14
|
+
configure_environment(rails_env, host_config)
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure_environment(rails_env, config)
|
18
|
+
inject_into_file(
|
19
|
+
"config/environments/#{rails_env}.rb",
|
20
|
+
"\n\n #{config}",
|
21
|
+
before: "\nend"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,270 @@
|
|
1
|
+
module Railsqs
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Railsqs::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def raise_on_delivery_errors
|
10
|
+
replace_in_file 'config/environments/development.rb',
|
11
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
12
|
+
end
|
13
|
+
|
14
|
+
def raise_on_unpermitted_parameters
|
15
|
+
config = <<-RUBY
|
16
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
17
|
+
RUBY
|
18
|
+
|
19
|
+
inject_into_class "config/application.rb", "Application", config
|
20
|
+
end
|
21
|
+
|
22
|
+
def provide_setup_script
|
23
|
+
template 'bin_setup.erb', 'bin/setup', port_number: port_number, force: true
|
24
|
+
run 'chmod a+x bin/setup'
|
25
|
+
end
|
26
|
+
|
27
|
+
def provide_dev_prime_task
|
28
|
+
copy_file 'development_seeds.rb', 'lib/tasks/development_seeds.rake'
|
29
|
+
end
|
30
|
+
|
31
|
+
def configure_generators
|
32
|
+
config = <<-RUBY
|
33
|
+
|
34
|
+
config.generators do |generate|
|
35
|
+
generate.helper false
|
36
|
+
generate.javascript_engine false
|
37
|
+
generate.stylesheets false
|
38
|
+
end
|
39
|
+
|
40
|
+
RUBY
|
41
|
+
|
42
|
+
inject_into_class 'config/application.rb', 'Application', config
|
43
|
+
end
|
44
|
+
|
45
|
+
def configure_smtp
|
46
|
+
copy_file 'smtp.rb', 'config/smtp.rb'
|
47
|
+
|
48
|
+
prepend_file 'config/environments/production.rb',
|
49
|
+
%{require Rails.root.join("config/smtp")\n}
|
50
|
+
|
51
|
+
config = <<-RUBY
|
52
|
+
|
53
|
+
config.action_mailer.delivery_method = :smtp
|
54
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
55
|
+
RUBY
|
56
|
+
|
57
|
+
inject_into_file 'config/environments/production.rb', config,
|
58
|
+
:after => 'config.action_mailer.raise_delivery_errors = false'
|
59
|
+
end
|
60
|
+
|
61
|
+
def enable_rack_deflater
|
62
|
+
config = <<-RUBY
|
63
|
+
|
64
|
+
# Enable deflate / gzip compression of controller-generated responses
|
65
|
+
config.middleware.use Rack::Deflater
|
66
|
+
RUBY
|
67
|
+
|
68
|
+
inject_into_file 'config/environments/production.rb', config,
|
69
|
+
:after => "config.serve_static_assets = false\n"
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def setup_staging_environment
|
74
|
+
staging_file = 'config/environments/staging.rb'
|
75
|
+
copy_file 'staging.rb', staging_file
|
76
|
+
|
77
|
+
config = <<-RUBY
|
78
|
+
|
79
|
+
Rails.application.configure do
|
80
|
+
# ...
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
|
84
|
+
append_file staging_file, config
|
85
|
+
end
|
86
|
+
|
87
|
+
def setup_secret_token
|
88
|
+
template 'secrets.yml', 'config/secrets.yml', force: true
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_partials_directory
|
92
|
+
empty_directory 'app/views/application'
|
93
|
+
end
|
94
|
+
|
95
|
+
def create_shared_nav
|
96
|
+
copy_file '_navigation.html.erb', 'app/views/application/_navigation.html.erb'
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_shared_footer
|
100
|
+
copy_file '_footer.html.erb', 'app/views/application/_footer.html.erb'
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_shared_flashes
|
104
|
+
copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_shared_javascripts
|
108
|
+
copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
|
109
|
+
end
|
110
|
+
|
111
|
+
def create_application_layout
|
112
|
+
template 'railsqs_layout.html.erb.erb',
|
113
|
+
'app/views/layouts/application.html.erb',
|
114
|
+
force: true
|
115
|
+
end
|
116
|
+
|
117
|
+
def remove_turbolinks
|
118
|
+
replace_in_file 'app/assets/javascripts/application.js',
|
119
|
+
/\/\/= require turbolinks\n/,
|
120
|
+
''
|
121
|
+
inject_into_file 'app/assets/javascripts/application.js',
|
122
|
+
"//= require bootstrap-sprockets\n", after: "jquery_ujs\n"
|
123
|
+
end
|
124
|
+
|
125
|
+
def use_postgres_config_template
|
126
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
127
|
+
force: true
|
128
|
+
end
|
129
|
+
|
130
|
+
def create_database
|
131
|
+
bundle_command 'exec rake db:create db:migrate'
|
132
|
+
end
|
133
|
+
|
134
|
+
def replace_gemfile
|
135
|
+
remove_file 'Gemfile'
|
136
|
+
template 'Gemfile.erb', 'Gemfile'
|
137
|
+
end
|
138
|
+
|
139
|
+
def enable_database_cleaner
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
def configure_spec_support_features
|
144
|
+
empty_directory_with_keep_file 'spec/features'
|
145
|
+
empty_directory_with_keep_file 'spec/support/features'
|
146
|
+
end
|
147
|
+
|
148
|
+
def configure_minitest_spinach
|
149
|
+
# TODO
|
150
|
+
#remove_file "spec/rails_helper.rb"
|
151
|
+
#remove_file "spec/spec_helper.rb"
|
152
|
+
#copy_file "rails_helper.rb", "spec/rails_helper.rb"
|
153
|
+
#copy_file "spec_helper.rb", "spec/spec_helper.rb"
|
154
|
+
end
|
155
|
+
|
156
|
+
|
157
|
+
def configure_time_zone
|
158
|
+
config = <<-RUBY
|
159
|
+
config.active_record.default_timezone = :utc
|
160
|
+
RUBY
|
161
|
+
|
162
|
+
inject_into_class 'config/application.rb', 'Application', config
|
163
|
+
end
|
164
|
+
|
165
|
+
def configure_time_formats
|
166
|
+
remove_file 'config/locales/en.yml'
|
167
|
+
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
|
168
|
+
end
|
169
|
+
|
170
|
+
def configure_rack_timeout
|
171
|
+
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
172
|
+
end
|
173
|
+
|
174
|
+
def configure_action_mailer
|
175
|
+
action_mailer_host 'development', "localhost:#{port_number}"
|
176
|
+
action_mailer_host 'test', 'www.example.com'
|
177
|
+
action_mailer_host 'staging', "staging.#{app_name}.com"
|
178
|
+
action_mailer_host 'production', "#{app_name}.com"
|
179
|
+
end
|
180
|
+
|
181
|
+
def fix_i18n_deprecation_warning
|
182
|
+
config = <<-RUBY
|
183
|
+
config.i18n.enforce_available_locales = true
|
184
|
+
RUBY
|
185
|
+
|
186
|
+
inject_into_class 'config/application.rb', 'Application', config
|
187
|
+
end
|
188
|
+
|
189
|
+
def generate_spinach
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
def setup_puma
|
194
|
+
copy_file 'puma.rb', 'config/puma.rb'
|
195
|
+
end
|
196
|
+
|
197
|
+
def setup_foreman
|
198
|
+
copy_file 'sample.env', '.sample.env'
|
199
|
+
copy_file 'Procfile', 'Procfile'
|
200
|
+
end
|
201
|
+
|
202
|
+
def setup_stylesheets
|
203
|
+
remove_file 'app/assets/stylesheets/application.css'
|
204
|
+
copy_file 'application.css.scss',
|
205
|
+
'app/assets/stylesheets/application.css.scss'
|
206
|
+
copy_file 'bootstrap.scss', 'app/assets/stylesheets/bootstrap.css.scss'
|
207
|
+
end
|
208
|
+
|
209
|
+
def install_bitters
|
210
|
+
run "bitters install --path app/assets/stylesheets"
|
211
|
+
end
|
212
|
+
|
213
|
+
def gitignore_files
|
214
|
+
remove_file '.gitignore'
|
215
|
+
copy_file 'railsqs_gitignore', '.gitignore'
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
def setup_homepage
|
220
|
+
bundle_command 'exec rails g controller Homepages show'
|
221
|
+
replace_in_file 'config/routes.rb', "get 'homepages/show'", "root 'homepages#show'"
|
222
|
+
end
|
223
|
+
|
224
|
+
def init_git
|
225
|
+
run 'git init'
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
def copy_miscellaneous_files
|
230
|
+
copy_file 'errors.rb', 'config/initializers/errors.rb'
|
231
|
+
end
|
232
|
+
|
233
|
+
def customize_error_pages
|
234
|
+
meta_tags =<<-EOS
|
235
|
+
<meta charset="utf-8" />
|
236
|
+
<meta name="ROBOTS" content="NOODP" />
|
237
|
+
<meta name="viewport" content="initial-scale=1" />
|
238
|
+
EOS
|
239
|
+
|
240
|
+
%w(500 404 422).each do |page|
|
241
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
242
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def remove_routes_comment_lines
|
247
|
+
replace_in_file 'config/routes.rb',
|
248
|
+
/Rails\.application\.routes\.draw do.*end/m,
|
249
|
+
"Rails.application.routes.draw do\nend"
|
250
|
+
end
|
251
|
+
|
252
|
+
def setup_default_rake_task
|
253
|
+
|
254
|
+
end
|
255
|
+
|
256
|
+
def run_initial_setup
|
257
|
+
run 'bin/setup'
|
258
|
+
end
|
259
|
+
|
260
|
+
private
|
261
|
+
|
262
|
+
def generate_secret
|
263
|
+
SecureRandom.hex(64)
|
264
|
+
end
|
265
|
+
|
266
|
+
def port_number
|
267
|
+
@port_number ||= [3000, 4000, 5000, 7000, 8000, 9000].sample
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
|
4
|
+
module Railsqs
|
5
|
+
class AppGenerator < Rails::Generators::AppGenerator
|
6
|
+
class_option :database, :type => :string, :aliases => '-d', :default => 'postgresql',
|
7
|
+
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
8
|
+
|
9
|
+
class_option :github, :type => :string, :aliases => '-G', :default => nil,
|
10
|
+
:desc => 'Create Github repository and add remote origin pointed to repo'
|
11
|
+
|
12
|
+
def finish_template
|
13
|
+
invoke :railsqs_customization
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def railsqs_customization
|
18
|
+
invoke :customize_gemfile
|
19
|
+
invoke :setup_development_environment
|
20
|
+
invoke :setup_test_environment
|
21
|
+
invoke :setup_production_environment
|
22
|
+
invoke :setup_staging_environment
|
23
|
+
invoke :setup_secret_token
|
24
|
+
invoke :create_railsqs_views
|
25
|
+
invoke :setup_coffeescript
|
26
|
+
invoke :configure_app
|
27
|
+
invoke :setup_stylesheets
|
28
|
+
invoke :install_bitters
|
29
|
+
invoke :copy_miscellaneous_files
|
30
|
+
invoke :customize_error_pages
|
31
|
+
invoke :remove_routes_comment_lines
|
32
|
+
invoke :setup_homepage
|
33
|
+
invoke :setup_git
|
34
|
+
invoke :setup_database
|
35
|
+
invoke :outro
|
36
|
+
end
|
37
|
+
|
38
|
+
def customize_gemfile
|
39
|
+
build :replace_gemfile
|
40
|
+
build :set_ruby_to_version_being_used
|
41
|
+
bundle_command 'install'
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_database
|
45
|
+
say 'Setting up database'
|
46
|
+
|
47
|
+
if 'postgresql' == options[:database]
|
48
|
+
build :use_postgres_config_template
|
49
|
+
end
|
50
|
+
|
51
|
+
build :create_database
|
52
|
+
end
|
53
|
+
|
54
|
+
def setup_development_environment
|
55
|
+
say 'Setting up the development environment'
|
56
|
+
build :raise_on_delivery_errors
|
57
|
+
build :raise_on_unpermitted_parameters
|
58
|
+
build :provide_setup_script
|
59
|
+
build :provide_dev_prime_task
|
60
|
+
build :configure_generators
|
61
|
+
build :configure_i18n_for_missing_translations
|
62
|
+
end
|
63
|
+
|
64
|
+
def setup_test_environment
|
65
|
+
say 'Setting up the test environment'
|
66
|
+
build :enable_database_cleaner
|
67
|
+
end
|
68
|
+
|
69
|
+
def setup_production_environment
|
70
|
+
say 'Setting up the production environment'
|
71
|
+
build :configure_newrelic
|
72
|
+
build :configure_smtp
|
73
|
+
build :enable_rack_deflater
|
74
|
+
end
|
75
|
+
|
76
|
+
def setup_staging_environment
|
77
|
+
say 'Setting up the staging environment'
|
78
|
+
build :setup_staging_environment
|
79
|
+
end
|
80
|
+
|
81
|
+
def setup_secret_token
|
82
|
+
say 'Moving secret token out of version control'
|
83
|
+
build :setup_secret_token
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_railsqs_views
|
87
|
+
say 'Creating railsqs views'
|
88
|
+
build :create_partials_directory
|
89
|
+
build :create_shared_flashes
|
90
|
+
build :create_shared_javascripts
|
91
|
+
build :create_shared_nav
|
92
|
+
build :create_shared_footer
|
93
|
+
build :create_application_layout
|
94
|
+
end
|
95
|
+
|
96
|
+
def setup_coffeescript
|
97
|
+
say 'Setting up CoffeeScript defaults'
|
98
|
+
build :remove_turbolinks
|
99
|
+
end
|
100
|
+
|
101
|
+
def configure_app
|
102
|
+
say 'Configuring app'
|
103
|
+
build :configure_action_mailer
|
104
|
+
build :configure_time_zone
|
105
|
+
build :configure_time_formats
|
106
|
+
build :configure_rack_timeout
|
107
|
+
build :disable_xml_params
|
108
|
+
build :fix_i18n_deprecation_warning
|
109
|
+
build :setup_default_rake_task
|
110
|
+
build :setup_puma
|
111
|
+
build :setup_foreman
|
112
|
+
end
|
113
|
+
|
114
|
+
def setup_stylesheets
|
115
|
+
say 'Set up stylesheets'
|
116
|
+
build :setup_stylesheets
|
117
|
+
end
|
118
|
+
|
119
|
+
def install_bitters
|
120
|
+
say 'Install Bitters'
|
121
|
+
build :install_bitters
|
122
|
+
end
|
123
|
+
|
124
|
+
def setup_homepage
|
125
|
+
build :setup_homepage
|
126
|
+
end
|
127
|
+
|
128
|
+
def setup_git
|
129
|
+
if !options[:skip_git]
|
130
|
+
say 'Initializing git'
|
131
|
+
invoke :setup_gitignore
|
132
|
+
invoke :init_git
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def setup_gitignore
|
137
|
+
build :gitignore_files
|
138
|
+
end
|
139
|
+
|
140
|
+
def init_git
|
141
|
+
build :init_git
|
142
|
+
end
|
143
|
+
|
144
|
+
def copy_miscellaneous_files
|
145
|
+
say 'Copying miscellaneous support files'
|
146
|
+
build :copy_miscellaneous_files
|
147
|
+
end
|
148
|
+
|
149
|
+
def customize_error_pages
|
150
|
+
say 'Customizing the 500/404/422 pages'
|
151
|
+
build :customize_error_pages
|
152
|
+
end
|
153
|
+
|
154
|
+
def remove_routes_comment_lines
|
155
|
+
build :remove_routes_comment_lines
|
156
|
+
end
|
157
|
+
|
158
|
+
def outro
|
159
|
+
build :run_initial_setup
|
160
|
+
say 'Congratulations! You just pulled our railsqs.'
|
161
|
+
end
|
162
|
+
|
163
|
+
def run_bundle
|
164
|
+
# Let's not: We'll bundle manually at the right spot
|
165
|
+
end
|
166
|
+
|
167
|
+
protected
|
168
|
+
|
169
|
+
def get_builder_class
|
170
|
+
Railsqs::AppBuilder
|
171
|
+
end
|
172
|
+
|
173
|
+
def using_active_record?
|
174
|
+
!options[:skip_active_record]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|