mj-suspenders 0.0.1
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 +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +12 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +136 -0
- data/LICENSE +21 -0
- data/README.md +60 -0
- data/Rakefile +8 -0
- data/TODO.md +19 -0
- data/bin/mj-suspenders +18 -0
- data/bin/rspec +16 -0
- data/lib/suspenders/actions.rb +35 -0
- data/lib/suspenders/app_builder.rb +251 -0
- data/lib/suspenders/generators/app_generator.rb +165 -0
- data/lib/suspenders/version.rb +3 -0
- data/lib/suspenders.rb +3 -0
- data/mj-suspenders.gemspec +34 -0
- data/spec/features/new_project_spec.rb +38 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/support/suspenders.rb +50 -0
- data/templates/Gemfile.erb +43 -0
- data/templates/README.md.erb +36 -0
- data/templates/_flashes.html.erb +5 -0
- data/templates/_javascript.html.erb +10 -0
- data/templates/application.css.scss +4 -0
- data/templates/config_locales_en.yml +11 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/disable_xml_params.rb +3 -0
- data/templates/errors.rb +28 -0
- data/templates/i18n.rb +3 -0
- data/templates/ruby-version.erb +1 -0
- data/templates/secret_token.rb +10 -0
- data/templates/spec_helper.rb +29 -0
- data/templates/staging.rb +6 -0
- data/templates/suspenders_gitignore +13 -0
- data/templates/suspenders_layout.html.erb.erb +15 -0
- data/templates/travis.yml.erb +23 -0
- data/templates/unicorn.rb +29 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36abb16b2f7d6d12efcd778ca60391d43526cda2
|
4
|
+
data.tar.gz: 4c1d667fb150606373d4a0fce987411056df3957
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 491adfca8195582e0f5532a46f8410cc3d6d1a948a394a4b4efd532cc62cedbe1351ff2e278761c6f3304bd9d91434d541be9908b1672c1b27f7d54f66317bec
|
7
|
+
data.tar.gz: 4ae1e652d35af6f5ed80f1a8f7676bba8ee215d475de1ba96f10939e8f31907070f58b7785155b774a1d9781572b160a00ecd4e757bbd18e471c53120b5884dc
|
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
We love pull requests. Here's a quick guide:
|
2
|
+
|
3
|
+
1. Fork the repo.
|
4
|
+
|
5
|
+
2. Run the tests. We only take pull requests with passing tests, and it's great
|
6
|
+
to know that you have a clean slate: `bundle && rake`
|
7
|
+
|
8
|
+
3. Add a test for your change. Only refactoring and documentation changes
|
9
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
10
|
+
a test!
|
11
|
+
|
12
|
+
4. Make the test pass.
|
13
|
+
|
14
|
+
5. Push to your fork and submit a pull request.
|
15
|
+
|
16
|
+
|
17
|
+
At this point you're waiting on us. We like to at least comment on, if not
|
18
|
+
accept, pull requests within three business days (and, typically, one business
|
19
|
+
day). We may suggest some changes or improvements or alternatives.
|
20
|
+
|
21
|
+
Some things that will increase the chance that your pull request is accepted,
|
22
|
+
taken straight from the Ruby on Rails guide:
|
23
|
+
|
24
|
+
* Use Rails idioms and helpers
|
25
|
+
* Include tests that fail without your code, and pass with it
|
26
|
+
* Update the documentation, the surrounding one, examples elsewhere, guides,
|
27
|
+
whatever is affected by your contribution
|
28
|
+
|
29
|
+
Syntax:
|
30
|
+
|
31
|
+
* Two spaces, no tabs.
|
32
|
+
* No trailing whitespace. Blank lines should not have any space.
|
33
|
+
* Prefer &&/|| over and/or.
|
34
|
+
* my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
|
35
|
+
* a = b and not a=b.
|
36
|
+
* Follow the conventions you see used in the source already.
|
37
|
+
|
38
|
+
And in case we didn't emphasize it enough: we love tests!
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mj-suspenders (0.0.1)
|
5
|
+
bundler (~> 1.3)
|
6
|
+
rails (= 4.0.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.0.3)
|
12
|
+
actionpack (= 4.0.3)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (4.0.3)
|
15
|
+
activesupport (= 4.0.3)
|
16
|
+
builder (~> 3.1.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
activemodel (4.0.3)
|
21
|
+
activesupport (= 4.0.3)
|
22
|
+
builder (~> 3.1.0)
|
23
|
+
activerecord (4.0.3)
|
24
|
+
activemodel (= 4.0.3)
|
25
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
26
|
+
activesupport (= 4.0.3)
|
27
|
+
arel (~> 4.0.0)
|
28
|
+
activerecord-deprecated_finders (1.0.3)
|
29
|
+
activesupport (4.0.3)
|
30
|
+
i18n (~> 0.6, >= 0.6.4)
|
31
|
+
minitest (~> 4.2)
|
32
|
+
multi_json (~> 1.3)
|
33
|
+
thread_safe (~> 0.1)
|
34
|
+
tzinfo (~> 0.3.37)
|
35
|
+
arel (4.0.2)
|
36
|
+
aruba (0.5.3)
|
37
|
+
childprocess (>= 0.3.6)
|
38
|
+
cucumber (>= 1.1.1)
|
39
|
+
rspec-expectations (>= 2.7.0)
|
40
|
+
builder (3.1.4)
|
41
|
+
capybara (2.2.0)
|
42
|
+
mime-types (>= 1.16)
|
43
|
+
nokogiri (>= 1.3.3)
|
44
|
+
rack (>= 1.0.0)
|
45
|
+
rack-test (>= 0.5.4)
|
46
|
+
xpath (~> 2.0)
|
47
|
+
childprocess (0.3.9)
|
48
|
+
ffi (~> 1.0, >= 1.0.11)
|
49
|
+
cucumber (1.3.3)
|
50
|
+
builder (>= 2.1.2)
|
51
|
+
diff-lcs (>= 1.1.3)
|
52
|
+
gherkin (~> 2.12.0)
|
53
|
+
multi_json (~> 1.7.5)
|
54
|
+
multi_test (~> 0.0.1)
|
55
|
+
diff-lcs (1.2.4)
|
56
|
+
erubis (2.7.0)
|
57
|
+
ffi (1.9.0)
|
58
|
+
ffi (1.9.0-x86-mingw32)
|
59
|
+
gherkin (2.12.0)
|
60
|
+
multi_json (~> 1.3)
|
61
|
+
gherkin (2.12.0-x86-mingw32)
|
62
|
+
multi_json (~> 1.3)
|
63
|
+
hike (1.2.3)
|
64
|
+
i18n (0.6.9)
|
65
|
+
mail (2.5.4)
|
66
|
+
mime-types (~> 1.16)
|
67
|
+
treetop (~> 1.4.8)
|
68
|
+
mime-types (1.25.1)
|
69
|
+
mini_portile (0.5.2)
|
70
|
+
minitest (4.7.5)
|
71
|
+
multi_json (1.7.9)
|
72
|
+
multi_test (0.0.1)
|
73
|
+
nokogiri (1.6.1)
|
74
|
+
mini_portile (~> 0.5.0)
|
75
|
+
nokogiri (1.6.1-x86-mingw32)
|
76
|
+
mini_portile (~> 0.5.0)
|
77
|
+
polyglot (0.3.4)
|
78
|
+
rack (1.5.2)
|
79
|
+
rack-test (0.6.2)
|
80
|
+
rack (>= 1.0)
|
81
|
+
rails (4.0.3)
|
82
|
+
actionmailer (= 4.0.3)
|
83
|
+
actionpack (= 4.0.3)
|
84
|
+
activerecord (= 4.0.3)
|
85
|
+
activesupport (= 4.0.3)
|
86
|
+
bundler (>= 1.3.0, < 2.0)
|
87
|
+
railties (= 4.0.3)
|
88
|
+
sprockets-rails (~> 2.0.0)
|
89
|
+
railties (4.0.3)
|
90
|
+
actionpack (= 4.0.3)
|
91
|
+
activesupport (= 4.0.3)
|
92
|
+
rake (>= 0.8.7)
|
93
|
+
thor (>= 0.18.1, < 2.0)
|
94
|
+
rake (10.2.2)
|
95
|
+
rspec (2.14.1)
|
96
|
+
rspec-core (~> 2.14.0)
|
97
|
+
rspec-expectations (~> 2.14.0)
|
98
|
+
rspec-mocks (~> 2.14.0)
|
99
|
+
rspec-core (2.14.7)
|
100
|
+
rspec-expectations (2.14.0)
|
101
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
102
|
+
rspec-mocks (2.14.4)
|
103
|
+
simplecov (0.7.1)
|
104
|
+
multi_json (~> 1.0)
|
105
|
+
simplecov-html (~> 0.7.1)
|
106
|
+
simplecov-html (0.7.1)
|
107
|
+
sprockets (2.12.0)
|
108
|
+
hike (~> 1.2)
|
109
|
+
multi_json (~> 1.0)
|
110
|
+
rack (~> 1.0)
|
111
|
+
tilt (~> 1.1, != 1.3.0)
|
112
|
+
sprockets-rails (2.0.1)
|
113
|
+
actionpack (>= 3.0)
|
114
|
+
activesupport (>= 3.0)
|
115
|
+
sprockets (~> 2.8)
|
116
|
+
thor (0.19.1)
|
117
|
+
thread_safe (0.3.3)
|
118
|
+
tilt (1.4.1)
|
119
|
+
treetop (1.4.15)
|
120
|
+
polyglot
|
121
|
+
polyglot (>= 0.3.1)
|
122
|
+
tzinfo (0.3.39)
|
123
|
+
xpath (2.0.0)
|
124
|
+
nokogiri (~> 1.3)
|
125
|
+
|
126
|
+
PLATFORMS
|
127
|
+
ruby
|
128
|
+
x86-mingw32
|
129
|
+
|
130
|
+
DEPENDENCIES
|
131
|
+
aruba (~> 0.5.2)
|
132
|
+
capybara
|
133
|
+
cucumber (~> 1.2)
|
134
|
+
mj-suspenders!
|
135
|
+
rspec
|
136
|
+
simplecov (~> 0.7.1)
|
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
@@ -0,0 +1,60 @@
|
|
1
|
+
# MJ-Suspenders
|
2
|
+
|
3
|
+
Suspenders is the base Rails application used at [thoughtbot](http://thoughtbot.com/community). MJ-Suspenders is my personal fork.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/mjacobus/mj-suspenders)
|
6
|
+
[](https://coveralls.io/r/mjacobus/mj-suspenders)
|
7
|
+
[](https://codeclimate.com/github/mjacobus/mj-suspenders)
|
8
|
+
[](https://gemnasium.com/mjacobus/mj-suspenders)
|
9
|
+
[](http://badge.fury.io/rb/mj-suspenders)
|
10
|
+
|
11
|
+
Installation
|
12
|
+
------------
|
13
|
+
|
14
|
+
First install the suspenders gem:
|
15
|
+
|
16
|
+
gem install mj-suspenders
|
17
|
+
|
18
|
+
Then run:
|
19
|
+
|
20
|
+
mj-suspenders projectname
|
21
|
+
|
22
|
+
This will create a Rails 4.0 app in `projectname`.
|
23
|
+
|
24
|
+
By default this script creates a new git repository. See below if you
|
25
|
+
want to use it against an existing repo.
|
26
|
+
|
27
|
+
|
28
|
+
Dependencies
|
29
|
+
------------
|
30
|
+
|
31
|
+
Suspenders requires Ruby 1.9.2 or greater.
|
32
|
+
|
33
|
+
Issues
|
34
|
+
------
|
35
|
+
|
36
|
+
If you have problems, please create a
|
37
|
+
[Github Issue](https://github.com/mjacobus/mj-suspenders/issues).
|
38
|
+
|
39
|
+
Contributing
|
40
|
+
------------
|
41
|
+
|
42
|
+
Please see CONTRIBUTING.md for details.
|
43
|
+
|
44
|
+
Credits
|
45
|
+
-------
|
46
|
+
|
47
|
+
Big thank to thoughtbot for their great gems.
|
48
|
+
|
49
|
+

|
50
|
+
|
51
|
+
Suspenders is maintained and funded by
|
52
|
+
[thoughtbot, inc](http://thoughtbot.com/community).
|
53
|
+
|
54
|
+
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
55
|
+
|
56
|
+
License
|
57
|
+
-------
|
58
|
+
|
59
|
+
Suspenders is Copyright © 2008-2014 thoughtbot. It is free software, and may be
|
60
|
+
redistributed under the terms specified in the LICENSE file.
|
data/Rakefile
ADDED
data/TODO.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
- Install machinist
|
2
|
+
- Smtp setup
|
3
|
+
- simple coverage
|
4
|
+
- fakes
|
5
|
+
- formulaic
|
6
|
+
- devise (optional)
|
7
|
+
- oauth login (optional)
|
8
|
+
- foundation
|
9
|
+
- foundation icons
|
10
|
+
- draper (perhaps skip in generators)
|
11
|
+
- makup (optional)
|
12
|
+
- vattributes
|
13
|
+
- gossiper (optional)
|
14
|
+
- kaminary (with foundation template)
|
15
|
+
- table cloth (tbd)
|
16
|
+
- configure layout to use foundation
|
17
|
+
- default to portuguese
|
18
|
+
- Add portuguese locales yml
|
19
|
+
- Find research unicorn
|
data/bin/mj-suspenders
ADDED
@@ -0,0 +1,18 @@
|
|
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 'suspenders'
|
8
|
+
|
9
|
+
if ['create', '--create'].include? ARGV[0]
|
10
|
+
ARGV.shift
|
11
|
+
puts "[WARNING] the suspenders create argument is deprecated. Just use `suspenders #{ARGV.join}` instead"
|
12
|
+
end
|
13
|
+
|
14
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
15
|
+
Suspenders::AppGenerator.source_root templates_root
|
16
|
+
Suspenders::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
17
|
+
|
18
|
+
Suspenders::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')
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Suspenders
|
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
|
+
|
25
|
+
def download_file(uri_string, destination)
|
26
|
+
uri = URI.parse(uri_string)
|
27
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
28
|
+
http.use_ssl = true if uri_string =~ /^https/
|
29
|
+
request = Net::HTTP::Get.new(uri.path)
|
30
|
+
contents = http.request(request).body
|
31
|
+
path = File.join(destination_root, destination)
|
32
|
+
File.open(path, "w") { |file| file.write(contents) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
module Suspenders
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Suspenders::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
|
+
action_on_unpermitted_parameters = <<-RUBY
|
16
|
+
|
17
|
+
# Raise an ActionController::UnpermittedParameters exception when
|
18
|
+
# a parameter is not explcitly permitted but is passed anyway.
|
19
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
20
|
+
RUBY
|
21
|
+
inject_into_file(
|
22
|
+
"config/environments/development.rb",
|
23
|
+
action_on_unpermitted_parameters,
|
24
|
+
before: "\nend"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def configure_generators
|
29
|
+
config = <<-RUBY
|
30
|
+
config.generators do |generate|
|
31
|
+
generate.helper false
|
32
|
+
generate.javascript_engine false
|
33
|
+
generate.request_specs false
|
34
|
+
generate.routing_specs true
|
35
|
+
generate.stylesheets false
|
36
|
+
generate.test_framework :rspec
|
37
|
+
generate.view_specs false
|
38
|
+
end
|
39
|
+
|
40
|
+
RUBY
|
41
|
+
|
42
|
+
inject_into_class 'config/application.rb', 'Application', config
|
43
|
+
end
|
44
|
+
|
45
|
+
def enable_rack_deflater
|
46
|
+
config = <<-RUBY
|
47
|
+
|
48
|
+
# Enable deflate / gzip compression of controller-generated responses
|
49
|
+
config.middleware.use Rack::Deflater
|
50
|
+
RUBY
|
51
|
+
|
52
|
+
inject_into_file 'config/environments/production.rb', config,
|
53
|
+
:after => "config.serve_static_assets = false\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup_staging_environment
|
57
|
+
staging_file = 'config/environments/staging.rb'
|
58
|
+
copy_file 'staging.rb', staging_file
|
59
|
+
|
60
|
+
config = <<-RUBY
|
61
|
+
|
62
|
+
#{app_name.classify}::Application.configure do
|
63
|
+
# ...
|
64
|
+
end
|
65
|
+
RUBY
|
66
|
+
|
67
|
+
append_file staging_file, config
|
68
|
+
end
|
69
|
+
|
70
|
+
def setup_secret_token
|
71
|
+
template 'secret_token.rb',
|
72
|
+
'config/initializers/secret_token.rb',
|
73
|
+
:force => true
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_partials_directory
|
77
|
+
empty_directory 'app/views/application'
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_shared_flashes
|
81
|
+
copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_shared_javascripts
|
85
|
+
copy_file '_javascript.html.erb', 'app/views/application/_javascript.html.erb'
|
86
|
+
end
|
87
|
+
|
88
|
+
def create_application_layout
|
89
|
+
template 'suspenders_layout.html.erb.erb',
|
90
|
+
'app/views/layouts/application.html.erb',
|
91
|
+
force: true
|
92
|
+
end
|
93
|
+
|
94
|
+
def remove_turbolinks
|
95
|
+
replace_in_file 'app/assets/javascripts/application.js',
|
96
|
+
/\/\/= require turbolinks\n/,
|
97
|
+
''
|
98
|
+
end
|
99
|
+
|
100
|
+
def replace_gemfile
|
101
|
+
remove_file 'Gemfile'
|
102
|
+
template 'Gemfile.erb', 'Gemfile'
|
103
|
+
end
|
104
|
+
|
105
|
+
def set_ruby_to_version_being_used
|
106
|
+
template 'ruby-version.erb', '.ruby-version'
|
107
|
+
end
|
108
|
+
|
109
|
+
def enable_database_cleaner
|
110
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
111
|
+
end
|
112
|
+
|
113
|
+
def configure_spec_support_features
|
114
|
+
empty_directory_with_keep_file 'spec/features'
|
115
|
+
empty_directory_with_keep_file 'spec/support/features'
|
116
|
+
end
|
117
|
+
|
118
|
+
def configure_rspec
|
119
|
+
remove_file 'spec/spec_helper.rb'
|
120
|
+
copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
|
121
|
+
end
|
122
|
+
|
123
|
+
def configure_travis
|
124
|
+
template 'travis.yml.erb', '.travis.yml'
|
125
|
+
end
|
126
|
+
|
127
|
+
def configure_i18n_in_specs
|
128
|
+
copy_file 'i18n.rb', 'spec/support/i18n.rb'
|
129
|
+
end
|
130
|
+
|
131
|
+
def use_spring_binstubs
|
132
|
+
run 'bundle exec spring binstub --all'
|
133
|
+
end
|
134
|
+
|
135
|
+
def configure_time_zone
|
136
|
+
config = <<-RUBY
|
137
|
+
config.active_record.default_timezone = :utc
|
138
|
+
|
139
|
+
RUBY
|
140
|
+
inject_into_class 'config/application.rb', 'Application', config
|
141
|
+
end
|
142
|
+
|
143
|
+
def configure_time_formats
|
144
|
+
remove_file 'config/locales/en.yml'
|
145
|
+
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
|
146
|
+
end
|
147
|
+
|
148
|
+
def configure_action_mailer
|
149
|
+
action_mailer_host 'development', "#{app_name}.local"
|
150
|
+
action_mailer_host 'test', 'www.example.com'
|
151
|
+
action_mailer_host 'staging', "staging.#{app_name}.com"
|
152
|
+
action_mailer_host 'production', "#{app_name}.com"
|
153
|
+
end
|
154
|
+
|
155
|
+
def fix_i18n_deprecation_warning
|
156
|
+
config = <<-RUBY
|
157
|
+
config.i18n.enforce_available_locales = true
|
158
|
+
|
159
|
+
RUBY
|
160
|
+
inject_into_class 'config/application.rb', 'Application', config
|
161
|
+
end
|
162
|
+
|
163
|
+
def generate_rspec
|
164
|
+
generate 'rspec:install'
|
165
|
+
end
|
166
|
+
|
167
|
+
def configure_unicorn
|
168
|
+
copy_file 'unicorn.rb', 'config/unicorn.rb'
|
169
|
+
end
|
170
|
+
|
171
|
+
def setup_stylesheets
|
172
|
+
remove_file 'app/assets/stylesheets/application.css'
|
173
|
+
copy_file 'application.css.scss',
|
174
|
+
'app/assets/stylesheets/application.css.scss'
|
175
|
+
end
|
176
|
+
|
177
|
+
def gitignore_files
|
178
|
+
remove_file '.gitignore'
|
179
|
+
copy_file 'suspenders_gitignore', '.gitignore'
|
180
|
+
[
|
181
|
+
'app/views/pages',
|
182
|
+
'spec/lib',
|
183
|
+
'spec/controllers',
|
184
|
+
'spec/helpers',
|
185
|
+
'spec/support/matchers',
|
186
|
+
'spec/support/mixins',
|
187
|
+
'spec/support/shared_examples'
|
188
|
+
].each do |dir|
|
189
|
+
run "mkdir #{dir}"
|
190
|
+
run "touch #{dir}/.keep"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def init_git
|
195
|
+
run 'git init'
|
196
|
+
end
|
197
|
+
|
198
|
+
def copy_miscellaneous_files
|
199
|
+
copy_file 'errors.rb', 'config/initializers/errors.rb'
|
200
|
+
end
|
201
|
+
|
202
|
+
def customize_error_pages
|
203
|
+
meta_tags =<<-EOS
|
204
|
+
<meta charset='utf-8' />
|
205
|
+
<meta name='ROBOTS' content='NOODP' />
|
206
|
+
EOS
|
207
|
+
|
208
|
+
%w(500 404 422).each do |page|
|
209
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
210
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def remove_routes_comment_lines
|
215
|
+
replace_in_file 'config/routes.rb',
|
216
|
+
/Application\.routes\.draw do.*end/m,
|
217
|
+
"Application.routes.draw do\nend"
|
218
|
+
end
|
219
|
+
|
220
|
+
def disable_xml_params
|
221
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
222
|
+
end
|
223
|
+
|
224
|
+
def setup_default_rake_task
|
225
|
+
append_file 'Rakefile' do
|
226
|
+
"task(:default).clear\ntask :default => [:spec]\n"
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def create_database
|
231
|
+
bundle_command 'exec rake db:create db:migrate'
|
232
|
+
end
|
233
|
+
|
234
|
+
private
|
235
|
+
|
236
|
+
def override_path_for_tests
|
237
|
+
if ENV['TESTING']
|
238
|
+
support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
|
239
|
+
"PATH=#{support_bin}:$PATH"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def factories_spec_rake_task
|
244
|
+
IO.read find_in_source_paths('factories_spec_rake_task.rb')
|
245
|
+
end
|
246
|
+
|
247
|
+
def generate_secret
|
248
|
+
SecureRandom.hex(64)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|