roboparts 0.0.1 → 0.5.2
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/.DS_Store +0 -0
- data/.ruby-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +108 -0
- data/LICENSE.md +21 -0
- data/README.md +74 -0
- data/bin/rake +16 -0
- data/bin/roboparts +13 -0
- data/bin/rspec +16 -0
- data/bin/setup +13 -0
- data/lib/roboparts.rb +4 -0
- data/lib/roboparts/actions.rb +25 -0
- data/lib/roboparts/app_builder.rb +352 -0
- data/lib/roboparts/generators/app_generator.rb +179 -0
- data/lib/roboparts/version.rb +5 -0
- data/roboparts.gemspec +29 -0
- data/templates/Gemfile.erb +38 -0
- data/templates/_analytics.html.erb +12 -0
- data/templates/_flashes.html.erb +7 -0
- data/templates/_javascript.html.erb +12 -0
- data/templates/action_mailer.rb +5 -0
- data/templates/application.css.scss +7 -0
- data/templates/background_jobs_rspec.rb +19 -0
- data/templates/bin_setup.erb +31 -0
- data/templates/bundler_audit.rake +12 -0
- data/templates/config_i18n_tasks.yml +13 -0
- data/templates/config_locales_en.yml.erb +17 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/development_seeds.rb +12 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +34 -0
- data/templates/factory_girl_rspec.rb +3 -0
- data/templates/i18n.rb +3 -0
- data/templates/json_encoding.rb +1 -0
- data/templates/postgresql_database.yml.erb +12 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/rails_helper.rb +23 -0
- data/templates/roboparts_gitignore +13 -0
- data/templates/roboparts_layout.html.erb.erb +16 -0
- data/templates/secrets.yml +14 -0
- data/templates/smtp.rb +9 -0
- data/templates/spec_helper.rb +15 -0
- data/templates/staging.rb +5 -0
- data/templates/unicorn.rb +28 -0
- metadata +49 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9626d5c60dd4ca7a6dffa53e6079e3f1400996ff
|
4
|
+
data.tar.gz: 7f8bd33c1444e438bd29a5dfb2dd35c2900e8867
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6c0bdb5d6f0b4dad64fc4a27a54e5465ba65e9495f4195c1843e43c1a299884e0d16429cd9e5f093dcd15ce15f7c0f2bc3c2fa7c65c5468ab956c2a6dddd2fc
|
7
|
+
data.tar.gz: 1bc1dce9ba9cdcbff483fe8179e40ab6d3e317a07c72ee1c9f20ad9a64202804749fae215a65465c53c921903610d5ea58dd3dbf3af750dfaa3d44add6e8def0
|
data/.DS_Store
ADDED
Binary file
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
roboparts (0.0.1)
|
5
|
+
bundler (~> 1.3)
|
6
|
+
rails (= 4.1.8)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.1.8)
|
12
|
+
actionpack (= 4.1.8)
|
13
|
+
actionview (= 4.1.8)
|
14
|
+
mail (~> 2.5, >= 2.5.4)
|
15
|
+
actionpack (4.1.8)
|
16
|
+
actionview (= 4.1.8)
|
17
|
+
activesupport (= 4.1.8)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
actionview (4.1.8)
|
21
|
+
activesupport (= 4.1.8)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubis (~> 2.7.0)
|
24
|
+
activemodel (4.1.8)
|
25
|
+
activesupport (= 4.1.8)
|
26
|
+
builder (~> 3.1)
|
27
|
+
activerecord (4.1.8)
|
28
|
+
activemodel (= 4.1.8)
|
29
|
+
activesupport (= 4.1.8)
|
30
|
+
arel (~> 5.0.0)
|
31
|
+
activesupport (4.1.8)
|
32
|
+
i18n (~> 0.6, >= 0.6.9)
|
33
|
+
json (~> 1.7, >= 1.7.7)
|
34
|
+
minitest (~> 5.1)
|
35
|
+
thread_safe (~> 0.1)
|
36
|
+
tzinfo (~> 1.1)
|
37
|
+
arel (5.0.1.20140414130214)
|
38
|
+
builder (3.2.2)
|
39
|
+
capybara (2.4.4)
|
40
|
+
mime-types (>= 1.16)
|
41
|
+
nokogiri (>= 1.3.3)
|
42
|
+
rack (>= 1.0.0)
|
43
|
+
rack-test (>= 0.5.4)
|
44
|
+
xpath (~> 2.0)
|
45
|
+
diff-lcs (1.2.5)
|
46
|
+
erubis (2.7.0)
|
47
|
+
hike (1.2.3)
|
48
|
+
i18n (0.6.11)
|
49
|
+
json (1.8.1)
|
50
|
+
mail (2.6.3)
|
51
|
+
mime-types (>= 1.16, < 3)
|
52
|
+
mime-types (2.4.3)
|
53
|
+
mini_portile (0.6.1)
|
54
|
+
minitest (5.4.3)
|
55
|
+
multi_json (1.10.1)
|
56
|
+
nokogiri (1.6.5)
|
57
|
+
mini_portile (~> 0.6.0)
|
58
|
+
rack (1.5.2)
|
59
|
+
rack-test (0.6.2)
|
60
|
+
rack (>= 1.0)
|
61
|
+
rails (4.1.8)
|
62
|
+
actionmailer (= 4.1.8)
|
63
|
+
actionpack (= 4.1.8)
|
64
|
+
actionview (= 4.1.8)
|
65
|
+
activemodel (= 4.1.8)
|
66
|
+
activerecord (= 4.1.8)
|
67
|
+
activesupport (= 4.1.8)
|
68
|
+
bundler (>= 1.3.0, < 2.0)
|
69
|
+
railties (= 4.1.8)
|
70
|
+
sprockets-rails (~> 2.0)
|
71
|
+
railties (4.1.8)
|
72
|
+
actionpack (= 4.1.8)
|
73
|
+
activesupport (= 4.1.8)
|
74
|
+
rake (>= 0.8.7)
|
75
|
+
thor (>= 0.18.1, < 2.0)
|
76
|
+
rake (10.4.2)
|
77
|
+
rspec (2.99.0)
|
78
|
+
rspec-core (~> 2.99.0)
|
79
|
+
rspec-expectations (~> 2.99.0)
|
80
|
+
rspec-mocks (~> 2.99.0)
|
81
|
+
rspec-core (2.99.2)
|
82
|
+
rspec-expectations (2.99.2)
|
83
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
84
|
+
rspec-mocks (2.99.2)
|
85
|
+
sprockets (2.12.3)
|
86
|
+
hike (~> 1.2)
|
87
|
+
multi_json (~> 1.0)
|
88
|
+
rack (~> 1.0)
|
89
|
+
tilt (~> 1.1, != 1.3.0)
|
90
|
+
sprockets-rails (2.2.2)
|
91
|
+
actionpack (>= 3.0)
|
92
|
+
activesupport (>= 3.0)
|
93
|
+
sprockets (>= 2.8, < 4.0)
|
94
|
+
thor (0.19.1)
|
95
|
+
thread_safe (0.3.4)
|
96
|
+
tilt (1.4.1)
|
97
|
+
tzinfo (1.2.2)
|
98
|
+
thread_safe (~> 0.1)
|
99
|
+
xpath (2.0.0)
|
100
|
+
nokogiri (~> 1.3)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
capybara (~> 2.2, >= 2.2.0)
|
107
|
+
roboparts!
|
108
|
+
rspec (~> 2.0)
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Daniel Strunk
|
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
@@ -0,0 +1,74 @@
|
|
1
|
+
Roboparts
|
2
|
+
===
|
3
|
+
|
4
|
+
Roboparts is the base Rails application used at [silentpost](http://silentpost.co). It comes configured with boilerplate code past the typical Rails install, so developers can instead focus on creating great apps.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
---
|
8
|
+
|
9
|
+
First install the roboparts gem:
|
10
|
+
|
11
|
+
```
|
12
|
+
gem install roboparts
|
13
|
+
```
|
14
|
+
|
15
|
+
Then run:
|
16
|
+
|
17
|
+
```
|
18
|
+
roboparts projectname
|
19
|
+
```
|
20
|
+
|
21
|
+
This will create a Rails app in `projectname` using the latest version of Rails.
|
22
|
+
|
23
|
+
Gemfile
|
24
|
+
---
|
25
|
+
|
26
|
+
One of the biggest reasons roboparts was created was the custom Gemfile, which includes:
|
27
|
+
|
28
|
+
* [Normalize] for resetting browser styles
|
29
|
+
* [Bourbon] for Sass mixins
|
30
|
+
* [Neat] for semantic grids
|
31
|
+
* [Delayed Job] for background processes
|
32
|
+
* [Simple Form] for form markup and style
|
33
|
+
* [Unicorn] for serving HTTP requests
|
34
|
+
* [Devise] for authentication
|
35
|
+
|
36
|
+
For development:
|
37
|
+
|
38
|
+
* [Spring ]
|
39
|
+
* [RSpec] for tests instead of Test::Unit
|
40
|
+
* [Factory Girl] instead of fixtures
|
41
|
+
|
42
|
+
For tests:
|
43
|
+
|
44
|
+
* [Shoulda matchers] for common RSpec matchers
|
45
|
+
* [Timecop] for testing time
|
46
|
+
|
47
|
+
Other defaults
|
48
|
+
---
|
49
|
+
|
50
|
+
Roboparts also comes configured with the following:
|
51
|
+
|
52
|
+
* PostgreSQL as the default database
|
53
|
+
* `./bin/setup` for new developer setup
|
54
|
+
* Rails flashes set up and in the application layout
|
55
|
+
* An automatically-created `SECRET_KEY_BASE` environment variable in all environments
|
56
|
+
|
57
|
+
GitHub
|
58
|
+
---
|
59
|
+
|
60
|
+
You can optionally create a GitHub repository for the Rails app. This requires you to have [Hub] on your system:
|
61
|
+
|
62
|
+
```
|
63
|
+
roboparts app --github organization/project
|
64
|
+
```
|
65
|
+
|
66
|
+
Dependencies
|
67
|
+
===
|
68
|
+
|
69
|
+
Roboparts requires the latest version of Ruby.
|
70
|
+
|
71
|
+
License
|
72
|
+
===
|
73
|
+
|
74
|
+
Roboparts is Copyright © 2014 SILENTPOST. It is free software, and may be redistributed under terms specified in the LICENSE.
|
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/roboparts
ADDED
@@ -0,0 +1,13 @@
|
|
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 'roboparts'
|
8
|
+
|
9
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
10
|
+
Roboparts::AppGenerator.source_root templates_root
|
11
|
+
Roboparts::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
12
|
+
|
13
|
+
Roboparts::AppGenerator.start
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' 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('rspec-core', 'rspec')
|
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
|
data/lib/roboparts.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Roboparts
|
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,352 @@
|
|
1
|
+
module Roboparts
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Roboparts::Actions
|
4
|
+
|
5
|
+
# Customize gemfile
|
6
|
+
def replace_gemfile
|
7
|
+
remove_file 'Gemfile'
|
8
|
+
template 'Gemfile.erb', 'Gemfile'
|
9
|
+
end
|
10
|
+
|
11
|
+
def set_ruby_to_version_being_used
|
12
|
+
create_file '.ruby-version', "#{Roboparts::RUBY_VERSION}\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Setup development environment
|
16
|
+
def raise_on_delivery_errors
|
17
|
+
replace_in_file 'config/environments/development.rb',
|
18
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
19
|
+
end
|
20
|
+
|
21
|
+
def raise_on_unpermitted_parameters
|
22
|
+
config = <<-RUBY
|
23
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
24
|
+
RUBY
|
25
|
+
|
26
|
+
inject_into_class "config/application.rb", "Application", config
|
27
|
+
end
|
28
|
+
|
29
|
+
def provide_setup_script
|
30
|
+
template 'bin_setup.erb', 'bin/setup', port_number: port_number
|
31
|
+
run 'chmod a+x bin/setup'
|
32
|
+
end
|
33
|
+
|
34
|
+
def provide_dev_prime_task
|
35
|
+
copy_file 'development_seeds.rb', 'lib/tasks/development_seeds.rake'
|
36
|
+
end
|
37
|
+
|
38
|
+
def configure_generators
|
39
|
+
config = <<-RUBY
|
40
|
+
|
41
|
+
config.generators do |generate|
|
42
|
+
generate.helper false
|
43
|
+
generate.javascript_engine false
|
44
|
+
generate.request_specs false
|
45
|
+
generate.routing_specs false
|
46
|
+
generate.stylesheets false
|
47
|
+
generate.test_framework :rspec
|
48
|
+
generate.view_specs false
|
49
|
+
end
|
50
|
+
|
51
|
+
RUBY
|
52
|
+
|
53
|
+
inject_into_class 'config/application.rb', 'Application', config
|
54
|
+
end
|
55
|
+
|
56
|
+
def use_postgres_config_template
|
57
|
+
template 'postgresql_database.yml.erb', 'config/database.yml',
|
58
|
+
force: true
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_database
|
62
|
+
bundle_command 'exec rake db:create db:migrate'
|
63
|
+
end
|
64
|
+
|
65
|
+
def raise_on_delivery_errors
|
66
|
+
replace_in_file 'config/environments/development.rb',
|
67
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
68
|
+
end
|
69
|
+
|
70
|
+
def raise_on_unpermitted_parameters
|
71
|
+
config = <<-RUBY
|
72
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
73
|
+
RUBY
|
74
|
+
|
75
|
+
inject_into_class "config/application.rb", "Application", config
|
76
|
+
end
|
77
|
+
|
78
|
+
def provide_setup_script
|
79
|
+
template "bin_setup.erb", "bin/setup", port_number: port, force: true
|
80
|
+
run "chmod a+x bin/setup"
|
81
|
+
end
|
82
|
+
|
83
|
+
def provide_dev_prime_task
|
84
|
+
copy_file 'development_seeds.rb', 'lib/tasks/development_seeds.rake'
|
85
|
+
end
|
86
|
+
|
87
|
+
def configure_generators
|
88
|
+
config = <<-RUBY
|
89
|
+
config.generators do |generate|
|
90
|
+
generate.helper false
|
91
|
+
generate.javascript_engine false
|
92
|
+
generate.request_specs false
|
93
|
+
generate.routing_specs false
|
94
|
+
generate.stylesheets false
|
95
|
+
generate.test_framework :rspec
|
96
|
+
generate.view_specs false
|
97
|
+
end
|
98
|
+
|
99
|
+
RUBY
|
100
|
+
|
101
|
+
inject_into_class 'config/application.rb', 'Application', config
|
102
|
+
end
|
103
|
+
|
104
|
+
def configure_i18n_for_missing_translations
|
105
|
+
raise_on_missing_translations_in("development")
|
106
|
+
raise_on_missing_translations_in("test")
|
107
|
+
end
|
108
|
+
|
109
|
+
def setup_factory_girl_for_rspec
|
110
|
+
copy_file 'factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
|
111
|
+
end
|
112
|
+
|
113
|
+
def generate_rspec
|
114
|
+
generate 'rspec:install'
|
115
|
+
end
|
116
|
+
|
117
|
+
def configure_rspec
|
118
|
+
remove_file "spec/rails_helper.rb"
|
119
|
+
remove_file "spec/spec_helper.rb"
|
120
|
+
copy_file "rails_helper.rb", "spec/rails_helper.rb"
|
121
|
+
copy_file "spec_helper.rb", "spec/spec_helper.rb"
|
122
|
+
end
|
123
|
+
|
124
|
+
def configure_background_jobs_for_rspec
|
125
|
+
copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
|
126
|
+
run 'rails g delayed_job:active_record'
|
127
|
+
end
|
128
|
+
|
129
|
+
def enable_database_cleaner
|
130
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
131
|
+
end
|
132
|
+
|
133
|
+
def configure_spec_support_features
|
134
|
+
empty_directory_with_keep_file 'spec/features'
|
135
|
+
empty_directory_with_keep_file 'spec/support/features'
|
136
|
+
end
|
137
|
+
|
138
|
+
def configure_i18n_for_test_environment
|
139
|
+
copy_file "i18n.rb", "spec/support/i18n.rb"
|
140
|
+
end
|
141
|
+
|
142
|
+
def configure_18n_tasks
|
143
|
+
run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
|
144
|
+
copy_file "config_i18n_tasks.yml", "config/i18n-tasks.yml"
|
145
|
+
end
|
146
|
+
|
147
|
+
def configure_action_mailer_in_specs
|
148
|
+
copy_file 'action_mailer.rb', 'spec/support/action_mailer.rb'
|
149
|
+
end
|
150
|
+
|
151
|
+
def configure_smtp
|
152
|
+
copy_file 'smtp.rb', 'config/smtp.rb'
|
153
|
+
|
154
|
+
prepend_file 'config/environments/production.rb',
|
155
|
+
%{require Rails.root.join("config/smtp")\n}
|
156
|
+
|
157
|
+
config = <<-RUBY
|
158
|
+
config.action_mailer.delivery_method = :smtp
|
159
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
160
|
+
RUBY
|
161
|
+
|
162
|
+
inject_into_file 'config/environments/production.rb', config,
|
163
|
+
:after => 'config.action_mailer.raise_delivery_errors = false'
|
164
|
+
end
|
165
|
+
|
166
|
+
def enable_rack_deflater
|
167
|
+
config = <<-RUBY
|
168
|
+
# Enable deflate / gzip compression of controller-generated responses
|
169
|
+
config.middleware.use Rack::Deflater
|
170
|
+
RUBY
|
171
|
+
|
172
|
+
inject_into_file 'config/environments/production.rb', config,
|
173
|
+
:after => "config.serve_static_assets = false\n"
|
174
|
+
end
|
175
|
+
|
176
|
+
def setup_asset_host
|
177
|
+
replace_in_file 'config/environments/production.rb',
|
178
|
+
"# config.action_controller.asset_host = 'http://assets.example.com'",
|
179
|
+
'config.action_controller.asset_host = ENV.fetch("ASSET_HOST")'
|
180
|
+
|
181
|
+
replace_in_file 'config/initializers/assets.rb',
|
182
|
+
"config.assets.version = '1.0'",
|
183
|
+
'config.assets.version = (ENV["ASSETS_VERSION"] || "1.0")'
|
184
|
+
|
185
|
+
replace_in_file 'config/environments/production.rb',
|
186
|
+
"config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?",
|
187
|
+
'config.static_cache_control = "public, max-age=#{1.year.to_i}"'
|
188
|
+
end
|
189
|
+
|
190
|
+
def setup_stagin_environment
|
191
|
+
staging_file = 'config/environments/staging.rb'
|
192
|
+
copy_file 'staging.rb', staging_file
|
193
|
+
|
194
|
+
config = <<-RUBY
|
195
|
+
Rails.application.configure do
|
196
|
+
# ...
|
197
|
+
end
|
198
|
+
RUBY
|
199
|
+
|
200
|
+
append_file staging_file, config
|
201
|
+
end
|
202
|
+
|
203
|
+
def setup_secret_token
|
204
|
+
template 'secrets.yml', 'config/secrets.yml', force: true
|
205
|
+
end
|
206
|
+
|
207
|
+
def create_partials_directory
|
208
|
+
empty_directory 'app/views/application'
|
209
|
+
end
|
210
|
+
|
211
|
+
def create_shared_flashes
|
212
|
+
copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
|
213
|
+
end
|
214
|
+
|
215
|
+
def create_shared_javascripts
|
216
|
+
copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
|
217
|
+
end
|
218
|
+
|
219
|
+
def create_application_layout
|
220
|
+
template 'roboparts_layout.html.erb.erb',
|
221
|
+
'app/views/layouts/application.html.erb', force: true
|
222
|
+
end
|
223
|
+
|
224
|
+
def remove_turbolinks
|
225
|
+
replace_in_file 'app/assets/javascripts/application.js',
|
226
|
+
/\/\/= require turbolinks\n/,
|
227
|
+
''
|
228
|
+
end
|
229
|
+
|
230
|
+
def configure_action_mailer
|
231
|
+
action_mailer_host 'development', "localhost:#{port}"
|
232
|
+
action_mailer_host 'test', 'www.example.com'
|
233
|
+
action_mailer_host 'staging', "staging.#{app_name}.com"
|
234
|
+
action_mailer_host 'production', "#{app_name}.com"
|
235
|
+
end
|
236
|
+
|
237
|
+
def configure_time_zone
|
238
|
+
config = <<-RUBY
|
239
|
+
config.active_record.default_timezone = :utc
|
240
|
+
RUBY
|
241
|
+
|
242
|
+
inject_into_class 'config/application.rb', 'Application', config
|
243
|
+
end
|
244
|
+
|
245
|
+
def configure_time_formats
|
246
|
+
remove_file "config/locales/en.yml"
|
247
|
+
template "config_locales_en.yml.erb", "config/locales/en.yml"
|
248
|
+
end
|
249
|
+
|
250
|
+
def configure_rack_timeout
|
251
|
+
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
252
|
+
end
|
253
|
+
|
254
|
+
def disable_xml_params
|
255
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
256
|
+
end
|
257
|
+
|
258
|
+
def fix_i18n_deprecation_warning
|
259
|
+
config = <<-RUBY
|
260
|
+
config.i18n.enforce_available_locales = true
|
261
|
+
RUBY
|
262
|
+
|
263
|
+
inject_into_class 'config/application.rb', 'Application', config
|
264
|
+
end
|
265
|
+
|
266
|
+
def setup_default_rake_task
|
267
|
+
append_file 'Rakefile' do
|
268
|
+
<<-RUBY
|
269
|
+
task(:default).clear
|
270
|
+
task default: [:spec]
|
271
|
+
|
272
|
+
if defined? RSpec
|
273
|
+
task(:spec).clear
|
274
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
275
|
+
t.verbose = false
|
276
|
+
end
|
277
|
+
end
|
278
|
+
RUBY
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
def configure_unicorn
|
283
|
+
copy_file 'unicorn.rb', 'config/unicorn.rb'
|
284
|
+
end
|
285
|
+
|
286
|
+
def setup_stylesheets
|
287
|
+
remove_file 'app/assets/stylesheets/application.css'
|
288
|
+
copy_file 'application.css.scss',
|
289
|
+
'app/assets/stylesheets/application.css.scss'
|
290
|
+
end
|
291
|
+
|
292
|
+
def gitignore_files
|
293
|
+
remove_file '.gitignore'
|
294
|
+
copy_file 'roboparts_gitignore', '.gitignore'
|
295
|
+
[
|
296
|
+
'app/views/pages',
|
297
|
+
'spec/lib',
|
298
|
+
'spec/controllers',
|
299
|
+
'spec/helpers',
|
300
|
+
'spec/support/matchers',
|
301
|
+
'spec/support/mixins',
|
302
|
+
'spec/support/shared_examples'
|
303
|
+
].each do |dir|
|
304
|
+
run "mkdir #{dir}"
|
305
|
+
run "touch #{dir}/.keep"
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def init_git
|
310
|
+
run 'git init'
|
311
|
+
end
|
312
|
+
|
313
|
+
def create_github_repo(repo_name)
|
314
|
+
path_addition = override_path_for_tests
|
315
|
+
run "#{path_addition} hub create #{repo_name}"
|
316
|
+
end
|
317
|
+
|
318
|
+
def setup_google_analytics
|
319
|
+
copy_file '_analytics.html.erb',
|
320
|
+
'app/views/application/_analytics.html.erb'
|
321
|
+
end
|
322
|
+
|
323
|
+
def setup_bundler_audit
|
324
|
+
copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake"
|
325
|
+
append_file "Rakefile", %{\ntask default: "bundler:audit"\n}
|
326
|
+
end
|
327
|
+
|
328
|
+
def copy_miscellaneous_files
|
329
|
+
copy_file "errors.rb", "config/initializers/errors.rb"
|
330
|
+
copy_file "json_encoding.rb", "config/initializers/json_encoding.rb"
|
331
|
+
end
|
332
|
+
|
333
|
+
def customize_error_pages
|
334
|
+
meta_tags = <<-RUBY
|
335
|
+
<meta charset="utf-8" />
|
336
|
+
<meta name="ROBOTS" content="NOODP" />
|
337
|
+
<meta name="viewport" content="initial-scale=1" />
|
338
|
+
RUBY
|
339
|
+
|
340
|
+
%w(500 404 422).each do |page|
|
341
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
342
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
346
|
+
def remove_routes_comment_lines
|
347
|
+
replace_in_file 'config/routes.rb',
|
348
|
+
/Rails\.application\.routes\.draw do.*end/m,
|
349
|
+
"Rails.application.routes.draw do\nend"
|
350
|
+
end
|
351
|
+
end
|
352
|
+
end
|