re-rails 0.1.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/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +133 -0
- data/LICENSE +21 -0
- data/README.md +181 -0
- data/Rakefile +13 -0
- data/bin/suspenders +18 -0
- data/lib/suspenders.rb +3 -0
- data/lib/suspenders/actions.rb +35 -0
- data/lib/suspenders/app_builder.rb +323 -0
- data/lib/suspenders/generators/app_generator.rb +199 -0
- data/lib/suspenders/version.rb +3 -0
- data/re-rails.gemspec +32 -0
- data/spec/fakes/bin/heroku +5 -0
- data/spec/fakes/bin/hub +5 -0
- data/spec/features/github_spec.rb +10 -0
- data/spec/features/heroku_spec.rb +12 -0
- data/spec/features/new_project_spec.rb +23 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/fake_github.rb +21 -0
- data/spec/support/fake_heroku.rb +30 -0
- data/spec/support/suspenders.rb +50 -0
- data/templates/Gemfile_clean +49 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +25 -0
- data/templates/_flashes.html.erb +5 -0
- data/templates/_javascript.html.erb +10 -0
- data/templates/application.css.scss +8 -0
- data/templates/background_jobs_rspec.rb +19 -0
- data/templates/bin_setup +29 -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/factories_spec.rb +13 -0
- data/templates/factories_spec_rake_task.rb +9 -0
- data/templates/factory_girl_syntax_rspec.rb +3 -0
- data/templates/postgresql_database.yml.erb +11 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/sample.env +3 -0
- data/templates/secret_token.rb +10 -0
- data/templates/smtp.rb +10 -0
- data/templates/spec_helper.rb +30 -0
- data/templates/staging.rb +3 -0
- data/templates/suspenders_gitignore +13 -0
- data/templates/suspenders_layout.html.erb.erb +15 -0
- data/templates/unicorn.rb +29 -0
- metadata +190 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53239a141976bda37e896d53d22c1639799db73e
|
4
|
+
data.tar.gz: 062c449e1aa6e9e2687c82465db42d1a91efe48c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 07a57ed4e907b685485c2a5967b2ba71e0d1b43d10f2a96fcd257c73d2bb27e7cfd87c3129f2bcfbae7e897bfd761fc9f19e4c2684f682c030553f823ce51d0c
|
7
|
+
data.tar.gz: c7dc4ce8bb01dce1ff60cca5ba994f0969db2e9e7c457abcb5ec73fbc5ca4b70a18080d4bba4127b1d307d65cf298b55c9449ce7444fd7aa1168081aaada304e
|
data/.gitignore
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,133 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
re-rails (0.1.0)
|
5
|
+
bundler (~> 1.3)
|
6
|
+
rails (= 4.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.0.0)
|
12
|
+
actionpack (= 4.0.0)
|
13
|
+
mail (~> 2.5.3)
|
14
|
+
actionpack (4.0.0)
|
15
|
+
activesupport (= 4.0.0)
|
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.0)
|
21
|
+
activesupport (= 4.0.0)
|
22
|
+
builder (~> 3.1.0)
|
23
|
+
activerecord (4.0.0)
|
24
|
+
activemodel (= 4.0.0)
|
25
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
26
|
+
activesupport (= 4.0.0)
|
27
|
+
arel (~> 4.0.0)
|
28
|
+
activerecord-deprecated_finders (1.0.3)
|
29
|
+
activesupport (4.0.0)
|
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
|
+
atomic (1.1.14)
|
41
|
+
builder (3.1.4)
|
42
|
+
capybara (2.2.0)
|
43
|
+
mime-types (>= 1.16)
|
44
|
+
nokogiri (>= 1.3.3)
|
45
|
+
rack (>= 1.0.0)
|
46
|
+
rack-test (>= 0.5.4)
|
47
|
+
xpath (~> 2.0)
|
48
|
+
childprocess (0.3.9)
|
49
|
+
ffi (~> 1.0, >= 1.0.11)
|
50
|
+
cucumber (1.3.3)
|
51
|
+
builder (>= 2.1.2)
|
52
|
+
diff-lcs (>= 1.1.3)
|
53
|
+
gherkin (~> 2.12.0)
|
54
|
+
multi_json (~> 1.7.5)
|
55
|
+
multi_test (~> 0.0.1)
|
56
|
+
diff-lcs (1.2.4)
|
57
|
+
erubis (2.7.0)
|
58
|
+
ffi (1.9.0)
|
59
|
+
ffi (1.9.0-x86-mingw32)
|
60
|
+
gherkin (2.12.0)
|
61
|
+
multi_json (~> 1.3)
|
62
|
+
gherkin (2.12.0-x86-mingw32)
|
63
|
+
multi_json (~> 1.3)
|
64
|
+
hike (1.2.3)
|
65
|
+
i18n (0.6.9)
|
66
|
+
mail (2.5.4)
|
67
|
+
mime-types (~> 1.16)
|
68
|
+
treetop (~> 1.4.8)
|
69
|
+
mime-types (1.25.1)
|
70
|
+
mini_portile (0.5.2)
|
71
|
+
minitest (4.7.5)
|
72
|
+
multi_json (1.7.7)
|
73
|
+
multi_test (0.0.1)
|
74
|
+
nokogiri (1.6.1)
|
75
|
+
mini_portile (~> 0.5.0)
|
76
|
+
nokogiri (1.6.1-x86-mingw32)
|
77
|
+
mini_portile (~> 0.5.0)
|
78
|
+
polyglot (0.3.3)
|
79
|
+
rack (1.5.2)
|
80
|
+
rack-test (0.6.2)
|
81
|
+
rack (>= 1.0)
|
82
|
+
rails (4.0.0)
|
83
|
+
actionmailer (= 4.0.0)
|
84
|
+
actionpack (= 4.0.0)
|
85
|
+
activerecord (= 4.0.0)
|
86
|
+
activesupport (= 4.0.0)
|
87
|
+
bundler (>= 1.3.0, < 2.0)
|
88
|
+
railties (= 4.0.0)
|
89
|
+
sprockets-rails (~> 2.0.0)
|
90
|
+
railties (4.0.0)
|
91
|
+
actionpack (= 4.0.0)
|
92
|
+
activesupport (= 4.0.0)
|
93
|
+
rake (>= 0.8.7)
|
94
|
+
thor (>= 0.18.1, < 2.0)
|
95
|
+
rake (10.1.1)
|
96
|
+
rspec (2.14.1)
|
97
|
+
rspec-core (~> 2.14.0)
|
98
|
+
rspec-expectations (~> 2.14.0)
|
99
|
+
rspec-mocks (~> 2.14.0)
|
100
|
+
rspec-core (2.14.7)
|
101
|
+
rspec-expectations (2.14.0)
|
102
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
103
|
+
rspec-mocks (2.14.4)
|
104
|
+
sprockets (2.10.1)
|
105
|
+
hike (~> 1.2)
|
106
|
+
multi_json (~> 1.0)
|
107
|
+
rack (~> 1.0)
|
108
|
+
tilt (~> 1.1, != 1.3.0)
|
109
|
+
sprockets-rails (2.0.1)
|
110
|
+
actionpack (>= 3.0)
|
111
|
+
activesupport (>= 3.0)
|
112
|
+
sprockets (~> 2.8)
|
113
|
+
thor (0.18.1)
|
114
|
+
thread_safe (0.1.3)
|
115
|
+
atomic
|
116
|
+
tilt (1.4.1)
|
117
|
+
treetop (1.4.15)
|
118
|
+
polyglot
|
119
|
+
polyglot (>= 0.3.1)
|
120
|
+
tzinfo (0.3.38)
|
121
|
+
xpath (2.0.0)
|
122
|
+
nokogiri (~> 1.3)
|
123
|
+
|
124
|
+
PLATFORMS
|
125
|
+
ruby
|
126
|
+
x86-mingw32
|
127
|
+
|
128
|
+
DEPENDENCIES
|
129
|
+
aruba (~> 0.5.2)
|
130
|
+
capybara
|
131
|
+
cucumber (~> 1.2)
|
132
|
+
re-rails!
|
133
|
+
rspec
|
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,181 @@
|
|
1
|
+
# re-rails
|
2
|
+
re-rails is a customized version of [Suspenders](https://github.com/thoughtbot/suspenders)the base Rails application used at [thoughtbot](http://thoughtbot.com/community).
|
3
|
+
|
4
|
+
Installation
|
5
|
+
------------
|
6
|
+
### From Ruby-Gems
|
7
|
+
First install the re-rails gem:
|
8
|
+
|
9
|
+
gem install re-rails
|
10
|
+
|
11
|
+
Then run:
|
12
|
+
|
13
|
+
re-rails projectname
|
14
|
+
|
15
|
+
This will create a Rails 4.0 app in `projectname`.
|
16
|
+
|
17
|
+
By default this script creates a new git repository. See below if you
|
18
|
+
want to use it against an existing repo.
|
19
|
+
|
20
|
+
### From Source
|
21
|
+
|
22
|
+
First Clone the repo
|
23
|
+
|
24
|
+
git clone git@github.com:re-analytics/re-rails.git
|
25
|
+
|
26
|
+
_or_
|
27
|
+
|
28
|
+
hub clone re-analytics/re-rails
|
29
|
+
|
30
|
+
then cd into the directory and run `rake build`
|
31
|
+
|
32
|
+
Gemfile
|
33
|
+
-------
|
34
|
+
|
35
|
+
To see the latest and greatest gems, look at re-rails'
|
36
|
+
[templates/Gemfile_clean](templates/Gemfile_clean),
|
37
|
+
which will be appended to the default generated projectname/Gemfile.
|
38
|
+
|
39
|
+
It includes application gems like:
|
40
|
+
|
41
|
+
* [Bourbon](https://github.com/thoughtbot/bourbon) for Sass mixins
|
42
|
+
* [Delayed Job](https://github.com/collectiveidea/delayed_job) for background
|
43
|
+
processing
|
44
|
+
* [Email Validator](https://github.com/balexand/email_validator) for email
|
45
|
+
validation
|
46
|
+
* [Flutie](https://github.com/thoughtbot/flutie) for `page_title` and
|
47
|
+
`body_class` view helpers
|
48
|
+
* [High Voltage](https://github.com/thoughtbot/high_voltage) for static pages
|
49
|
+
* [jQuery Rails](https://github.com/rails/jquery-rails) for jQuery
|
50
|
+
* [Neat](https://github.com/thoughtbot/neat) for semantic grids
|
51
|
+
* [Postgres](https://github.com/ged/ruby-pg) for access to the Postgres database
|
52
|
+
* [Rack Timeout](https://github.com/kch/rack-timeout) to abort requests that are
|
53
|
+
taking too long
|
54
|
+
* [Recipient Interceptor](https://github.com/croaky/recipient_interceptor) to
|
55
|
+
avoid accidentally sending emails to real people from staging
|
56
|
+
* [Simple Form](https://github.com/plataformatec/simple_form) for form markup
|
57
|
+
and style
|
58
|
+
* [Unicorn](https://github.com/defunkt/unicorn) to serve HTTP requests
|
59
|
+
* [Cancan](https://github.com/ryanb/cancan) for authorization
|
60
|
+
* [Devise](https://github.com/plataformatec/devise) for authentication
|
61
|
+
And gems only for staging and production like:
|
62
|
+
|
63
|
+
* [New Relic RPM](https://github.com/newrelic/rpm) for monitoring performance
|
64
|
+
* [Rails 12 Factor](https://github.com/heroku/rails_12factor) to make running
|
65
|
+
Rails 4 apps easier on Heroku
|
66
|
+
|
67
|
+
And testing gems like:
|
68
|
+
|
69
|
+
* [Capybara](https://github.com/jnicklas/capybara) and
|
70
|
+
[Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
|
71
|
+
integration testing
|
72
|
+
* [Factory Girl](https://github.com/thoughtbot/factory_girl) for test data
|
73
|
+
* [RSpec](https://github.com/rspec/rspec) for unit testing
|
74
|
+
* [RSpec Mocks](https://github.com/rspec/rspec-mocks) for stubbing and spying
|
75
|
+
* [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) for common
|
76
|
+
RSpec matchers
|
77
|
+
* [Timecop](https://github.com/jtrupiano/timecop-console) for testing time
|
78
|
+
|
79
|
+
Other goodies
|
80
|
+
-------------
|
81
|
+
|
82
|
+
re-rails also comes with:
|
83
|
+
|
84
|
+
* The [`./bin/setup`][bin] convention for new developer setup
|
85
|
+
* Rails' flashes set up and in application layout
|
86
|
+
* A few nice time formats set up for localization
|
87
|
+
* `Rack::Deflater` to [compress responses with Gzip][compress]
|
88
|
+
* [Fast-failing factories][fast]
|
89
|
+
|
90
|
+
[bin]: http://robots.thoughtbot.com/bin-setup
|
91
|
+
[compress]: http://robots.thoughtbot.com/content-compression-with-rack-deflater/
|
92
|
+
[fast]: http://robots.thoughtbot.com/testing-your-factories-first
|
93
|
+
|
94
|
+
re-rails fixes several of Rails' [insecure defaults]:
|
95
|
+
|
96
|
+
* re-rails uses Unicorn instead of WEBrick, allowing less verbose Server
|
97
|
+
headers.
|
98
|
+
* re-rails is configured to pull your application secret key base from an
|
99
|
+
environment variable, which means you won't need to risk placing it in version
|
100
|
+
control.
|
101
|
+
|
102
|
+
[insecure defaults]: http://blog.codeclimate.com/blog/2013/03/27/rails-insecure-defaults/
|
103
|
+
|
104
|
+
Heroku
|
105
|
+
------
|
106
|
+
|
107
|
+
You can optionally create Heroku staging and production apps:
|
108
|
+
|
109
|
+
re-rails app --heroku true
|
110
|
+
|
111
|
+
This:
|
112
|
+
|
113
|
+
* Creates a staging and production Heroku app
|
114
|
+
* Sets them as `staging` and `production` Git remotes
|
115
|
+
* Configures staging with `RACK_ENV` and `RAILS_ENV` environment variables set
|
116
|
+
to `staging`
|
117
|
+
|
118
|
+
Git
|
119
|
+
---
|
120
|
+
|
121
|
+
This will initialize a new git repository for your Rails app. You can
|
122
|
+
bypass this with the `--skip-git` option:
|
123
|
+
|
124
|
+
re-rails app --skip-git true
|
125
|
+
|
126
|
+
GitHub
|
127
|
+
------
|
128
|
+
|
129
|
+
You can optionally create a GitHub repository for the suspended Rails app. It
|
130
|
+
requires that you have [Hub](https://github.com/github/hub) on your system:
|
131
|
+
|
132
|
+
curl http://hub.github.com/standalone -sLo ~/bin/hub && chmod +x ~/bin/hub
|
133
|
+
re-rails app --github organization/project
|
134
|
+
|
135
|
+
This has the same effect as running:
|
136
|
+
|
137
|
+
hub create organization/project
|
138
|
+
|
139
|
+
Dependencies
|
140
|
+
------------
|
141
|
+
|
142
|
+
re-rails requires Ruby 1.9.2 or greater.
|
143
|
+
|
144
|
+
Some gems included in re-rails have native extensions. You should have GCC
|
145
|
+
installed on your machine before generating an app with re-rails.
|
146
|
+
|
147
|
+
Use [OS X GCC Installer](https://github.com/kennethreitz/osx-gcc-installer/) for
|
148
|
+
Snow Leopard (OS X 10.6).
|
149
|
+
|
150
|
+
Use [Command Line Tools for XCode](https://developer.apple.com/downloads/index.action)
|
151
|
+
for Lion (OS X 10.7) or Mountain Lion (OS X 10.8).
|
152
|
+
|
153
|
+
We use [Capybara Webkit](https://github.com/thoughtbot/capybara-webkit) for
|
154
|
+
full-stack Javascript integration testing. It requires QT. Instructions for
|
155
|
+
installing QT are
|
156
|
+
[here](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit).
|
157
|
+
|
158
|
+
PostgreSQL needs to be installed and running for the `db:create` rake task.
|
159
|
+
|
160
|
+
Issues
|
161
|
+
------
|
162
|
+
|
163
|
+
If you have problems, please create a
|
164
|
+
[Github Issue](https://github.com/re-analytics/re-rails/issues).
|
165
|
+
|
166
|
+
Contributing
|
167
|
+
------------
|
168
|
+
|
169
|
+
Please see CONTRIBUTING.md for details.
|
170
|
+
|
171
|
+
Credits
|
172
|
+
-------
|
173
|
+
|
174
|
+
![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
|
175
|
+
re-rails is based off [Suspenders](https://github.com/thoughtbot/suspenders) which is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community).
|
176
|
+
|
177
|
+
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
|
178
|
+
|
179
|
+
License
|
180
|
+
-------
|
181
|
+
Licensed Under MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:rspec)
|
6
|
+
|
7
|
+
desc 'Run the test suite'
|
8
|
+
task :default => :rspec
|
9
|
+
|
10
|
+
desc 'Update Ruby gems'
|
11
|
+
task :update_gem do
|
12
|
+
exec 'gem update --system'
|
13
|
+
end
|
data/bin/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/lib/suspenders.rb
ADDED
@@ -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
|