rails-replicator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +85 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +87 -0
- data/LICENSE +21 -0
- data/README.md +41 -0
- data/bin/replicator +16 -0
- data/lib/replicator/actions.rb +40 -0
- data/lib/replicator/app_builder.rb +337 -0
- data/lib/replicator/generators/app_generator.rb +207 -0
- data/lib/replicator/version.rb +3 -0
- data/replicator.gemspec +29 -0
- data/templates/Gemfile_clean +68 -0
- data/templates/Procfile +2 -0
- data/templates/README.md.erb +5 -0
- data/templates/_flashes.html.slim.erb +13 -0
- data/templates/_javascript.html.slim.erb +7 -0
- data/templates/ability.rb +15 -0
- data/templates/admin_base_controller.rb +14 -0
- data/templates/admin_dashboard_controller.rb +4 -0
- data/templates/application.css.sass +12 -0
- data/templates/application.html.slim.erb +24 -0
- data/templates/application.js +8 -0
- data/templates/application_helper.rb +5 -0
- data/templates/background_jobs_rspec.rb +19 -0
- data/templates/bin_setup +26 -0
- data/templates/config_locales_en.yml +11 -0
- data/templates/database.yml.erb +12 -0
- data/templates/database_cleaner_rspec.rb +21 -0
- data/templates/devise/confirmations/new.html.slim +12 -0
- data/templates/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/templates/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/templates/devise/mailer/unlock_instructions.html.erb +7 -0
- data/templates/devise/passwords/edit.html.slim +19 -0
- data/templates/devise/passwords/new.html.slim +14 -0
- data/templates/devise/registrations/edit.html.slim +36 -0
- data/templates/devise/registrations/new.html.slim +22 -0
- data/templates/devise/sessions/new.html.slim +20 -0
- data/templates/devise/shared/_links.html.slim +24 -0
- data/templates/devise/unlocks/new.html.slim +13 -0
- data/templates/devise_login.html.slim +20 -0
- data/templates/devise_shared_links.html.slim +24 -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/gitignore +85 -0
- data/templates/rack_timeout.rb +1 -0
- data/templates/routes.rb.erb +15 -0
- data/templates/sample.env +2 -0
- data/templates/smtp.rb +10 -0
- data/templates/spec_helper.rb +25 -0
- data/templates/stylesheets/layout/.keep +0 -0
- data/templates/stylesheets/typography/.keep +0 -0
- data/templates/stylesheets/typography/_forms.css.sass +2 -0
- data/templates/stylesheets/widgets/.keep +0 -0
- data/templates/unicorn.rb +26 -0
- metadata +140 -0
data/.gitignore
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*.log
|
16
|
+
/tmp
|
17
|
+
[12:00 PM]: ~/Dropbox/Code/apps/foobar : cat ../chimera/.gitignore
|
18
|
+
# bundler state
|
19
|
+
/.bundle
|
20
|
+
/vendor/bundle/
|
21
|
+
/vendor/ruby/
|
22
|
+
|
23
|
+
# minimal Rails specific artifacts
|
24
|
+
db/*.sqlite3
|
25
|
+
/log/*
|
26
|
+
/tmp/*
|
27
|
+
|
28
|
+
# various artifacts
|
29
|
+
**.war
|
30
|
+
*.rbc
|
31
|
+
*.sassc
|
32
|
+
.rspec
|
33
|
+
.redcar/
|
34
|
+
.sass-cache
|
35
|
+
/config/config.yml
|
36
|
+
/config/database.yml
|
37
|
+
/coverage.data
|
38
|
+
/coverage/
|
39
|
+
/db/*.javadb/
|
40
|
+
/db/*.sqlite3
|
41
|
+
/doc/api/
|
42
|
+
/doc/app/
|
43
|
+
/doc/features.html
|
44
|
+
/doc/specs.html
|
45
|
+
/public/cache
|
46
|
+
/public/stylesheets/compiled
|
47
|
+
/public/system/*
|
48
|
+
/spec/tmp/*
|
49
|
+
/cache
|
50
|
+
/capybara*
|
51
|
+
/capybara-*.html
|
52
|
+
/gems
|
53
|
+
/specifications
|
54
|
+
rerun.txt
|
55
|
+
pickle-email-*.html
|
56
|
+
|
57
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
58
|
+
# or operating system, you probably want to add a global ignore instead:
|
59
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
60
|
+
#
|
61
|
+
# Here are some files you may want to ignore globally:
|
62
|
+
|
63
|
+
# scm revert files
|
64
|
+
**.orig
|
65
|
+
|
66
|
+
# Mac finder artifacts
|
67
|
+
.DS_Store
|
68
|
+
|
69
|
+
# Netbeans project directory
|
70
|
+
/nbproject/
|
71
|
+
|
72
|
+
# RubyMine project files
|
73
|
+
.idea
|
74
|
+
|
75
|
+
# Textmate project files
|
76
|
+
/*.tmproj
|
77
|
+
|
78
|
+
# vim artifacts
|
79
|
+
**.swp
|
80
|
+
|
81
|
+
# Ignore application configuration
|
82
|
+
/config/application.yml
|
83
|
+
|
84
|
+
# Ignore Heroku environment file
|
85
|
+
.env
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
replicator (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.0)
|
36
|
+
atomic (1.1.14)
|
37
|
+
builder (3.1.4)
|
38
|
+
erubis (2.7.0)
|
39
|
+
hike (1.2.3)
|
40
|
+
i18n (0.6.5)
|
41
|
+
mail (2.5.4)
|
42
|
+
mime-types (~> 1.16)
|
43
|
+
treetop (~> 1.4.8)
|
44
|
+
mime-types (1.25)
|
45
|
+
minitest (4.7.5)
|
46
|
+
multi_json (1.8.0)
|
47
|
+
polyglot (0.3.3)
|
48
|
+
rack (1.5.2)
|
49
|
+
rack-test (0.6.2)
|
50
|
+
rack (>= 1.0)
|
51
|
+
rails (4.0.0)
|
52
|
+
actionmailer (= 4.0.0)
|
53
|
+
actionpack (= 4.0.0)
|
54
|
+
activerecord (= 4.0.0)
|
55
|
+
activesupport (= 4.0.0)
|
56
|
+
bundler (>= 1.3.0, < 2.0)
|
57
|
+
railties (= 4.0.0)
|
58
|
+
sprockets-rails (~> 2.0.0)
|
59
|
+
railties (4.0.0)
|
60
|
+
actionpack (= 4.0.0)
|
61
|
+
activesupport (= 4.0.0)
|
62
|
+
rake (>= 0.8.7)
|
63
|
+
thor (>= 0.18.1, < 2.0)
|
64
|
+
rake (10.1.0)
|
65
|
+
sprockets (2.10.0)
|
66
|
+
hike (~> 1.2)
|
67
|
+
multi_json (~> 1.0)
|
68
|
+
rack (~> 1.0)
|
69
|
+
tilt (~> 1.1, != 1.3.0)
|
70
|
+
sprockets-rails (2.0.0)
|
71
|
+
actionpack (>= 3.0)
|
72
|
+
activesupport (>= 3.0)
|
73
|
+
sprockets (~> 2.8)
|
74
|
+
thor (0.18.1)
|
75
|
+
thread_safe (0.1.3)
|
76
|
+
atomic
|
77
|
+
tilt (1.4.1)
|
78
|
+
treetop (1.4.15)
|
79
|
+
polyglot
|
80
|
+
polyglot (>= 0.3.1)
|
81
|
+
tzinfo (0.3.37)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
replicator!
|
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,41 @@
|
|
1
|
+
# Replicator
|
2
|
+
|
3
|
+
Ruby on Rails application generator used by the [Teleporter](http://teleporter.io) team, based on [thoughtbot/suspenders](https://github.com/thoughtbot/suspenders)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Installation is simple, just install the `replicator` gem:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install replicator
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```bash
|
16
|
+
replicator appname
|
17
|
+
```
|
18
|
+
|
19
|
+
To get a list of options, type `replicator -h`
|
20
|
+
|
21
|
+
## Dependencies
|
22
|
+
|
23
|
+
Depends on:
|
24
|
+
|
25
|
+
- Ruby 2.0.0 or greater
|
26
|
+
|
27
|
+
## Issues
|
28
|
+
|
29
|
+
If you have issues using Replicator, please create an [issue on Github](https://github.com/teleporter/replicator/issues).
|
30
|
+
|
31
|
+
## Credits
|
32
|
+
|
33
|
+
Based heavily on [Thoughtbot's](http://thoughtbot.com) [suspenders gem](https://github.com/thoughtbot/suspenders).
|
34
|
+
|
35
|
+
Modified to fit within [Teleporter](http://teleporter.io)'s workflow.
|
36
|
+
|
37
|
+
![Teleporter](http://f.cl.ly/items/2c0j3A311n1T3b201e0V/teleporter-400px-padded.png)
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
Licensed under the MIT license (see the `LICENSE` file).
|
data/bin/replicator
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(File.join('..', 'lib', 'replicator', 'generators', 'app_generator'), File.dirname(__FILE__))
|
4
|
+
require File.expand_path(File.join('..', 'lib', 'replicator', 'actions'), File.dirname(__FILE__))
|
5
|
+
require File.expand_path(File.join('..', 'lib', 'replicator', 'app_builder'), File.dirname(__FILE__))
|
6
|
+
|
7
|
+
if ['create', '--create'].include? ARGV[0]
|
8
|
+
ARGV.shift
|
9
|
+
puts "[WARNING] the replicator create argument is deprecated. Just use `replicator #{ARGV.join}` instead"
|
10
|
+
end
|
11
|
+
|
12
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
13
|
+
Replicator::AppGenerator.source_root templates_root
|
14
|
+
Replicator::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
|
15
|
+
|
16
|
+
Replicator::AppGenerator.start
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Replicator
|
2
|
+
module Actions
|
3
|
+
def concat_file(source, destination)
|
4
|
+
contents = IO.read(find_in_source_paths(source))
|
5
|
+
append_file destination, contents
|
6
|
+
end
|
7
|
+
|
8
|
+
def replace_in_file(relative_path, find, replace)
|
9
|
+
path = File.join(destination_root, relative_path)
|
10
|
+
contents = IO.read(path)
|
11
|
+
unless contents.gsub!(find, replace)
|
12
|
+
raise "#{find.inspect} not found in #{relative_path}"
|
13
|
+
end
|
14
|
+
File.open(path, "w") { |file| file.write(contents) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def action_mailer_host(rails_env, host)
|
18
|
+
host_config = "config.action_mailer.default_url_options = { host: '#{host}' }"
|
19
|
+
configure_environment(rails_env, host_config)
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure_environment(rails_env, config)
|
23
|
+
inject_into_file(
|
24
|
+
"config/environments/#{rails_env}.rb",
|
25
|
+
"\n\n #{config}",
|
26
|
+
before: "\nend"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def download_file(uri_string, destination)
|
31
|
+
uri = URI.parse(uri_string)
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = true if uri_string =~ /^https/
|
34
|
+
request = Net::HTTP::Get.new(uri.path)
|
35
|
+
contents = http.request(request).body
|
36
|
+
path = File.join(destination_root, destination)
|
37
|
+
File.open(path, "w") { |file| file.write(contents) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,337 @@
|
|
1
|
+
module Replicator
|
2
|
+
class AppBuilder < Rails::AppBuilder
|
3
|
+
include Replicator::Actions
|
4
|
+
|
5
|
+
def readme
|
6
|
+
template 'README.md.erb', 'README.md'
|
7
|
+
end
|
8
|
+
|
9
|
+
def remove_public_index
|
10
|
+
remove_file 'public/index.html'
|
11
|
+
end
|
12
|
+
|
13
|
+
def remove_rails_logo_image
|
14
|
+
remove_file 'app/assets/images/rails.png'
|
15
|
+
end
|
16
|
+
|
17
|
+
def raise_on_delivery_errors
|
18
|
+
replace_in_file 'config/environments/development.rb',
|
19
|
+
'raise_delivery_errors = false', 'raise_delivery_errors = true'
|
20
|
+
end
|
21
|
+
|
22
|
+
def raise_on_unpermitted_parameters
|
23
|
+
configure_environment 'development',
|
24
|
+
'config.action_controller.action_on_unpermitted_parameters = :raise'
|
25
|
+
end
|
26
|
+
|
27
|
+
def provide_setup_script
|
28
|
+
copy_file 'bin_setup', 'bin/setup'
|
29
|
+
run 'chmod a+x bin/setup'
|
30
|
+
end
|
31
|
+
|
32
|
+
def configure_generators
|
33
|
+
config = <<-RUBY
|
34
|
+
config.generators do |generate|
|
35
|
+
generate.helper false
|
36
|
+
generate.javascript_engine false
|
37
|
+
generate.request_specs false
|
38
|
+
generate.routing_specs false
|
39
|
+
generate.stylesheets false
|
40
|
+
generate.test_framework :rspec
|
41
|
+
generate.view_specs false
|
42
|
+
end
|
43
|
+
|
44
|
+
RUBY
|
45
|
+
|
46
|
+
inject_into_class 'config/application.rb', 'Application', config
|
47
|
+
end
|
48
|
+
|
49
|
+
def enable_factory_girl_syntax
|
50
|
+
copy_file 'factory_girl_syntax_rspec.rb', 'spec/support/factory_girl.rb'
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_factories_first
|
54
|
+
copy_file 'factories_spec.rb', 'spec/models/factories_spec.rb'
|
55
|
+
append_file 'Rakefile', factories_spec_rake_task
|
56
|
+
end
|
57
|
+
|
58
|
+
def configure_smtp
|
59
|
+
copy_file 'smtp.rb', 'config/initializers/smtp.rb'
|
60
|
+
|
61
|
+
prepend_file 'config/environments/production.rb',
|
62
|
+
"require Rails.root.join('config/initializers/smtp')\n"
|
63
|
+
|
64
|
+
config = <<-RUBY
|
65
|
+
|
66
|
+
config.action_mailer.delivery_method = :smtp
|
67
|
+
config.action_mailer.smtp_settings = SMTP_SETTINGS
|
68
|
+
RUBY
|
69
|
+
|
70
|
+
inject_into_file 'config/environments/production.rb', config,
|
71
|
+
:after => 'config.action_mailer.raise_delivery_errors = false'
|
72
|
+
end
|
73
|
+
|
74
|
+
def setup_staging_environment
|
75
|
+
run 'cp config/environments/production.rb config/environments/staging.rb'
|
76
|
+
|
77
|
+
prepend_file 'config/environments/staging.rb',
|
78
|
+
"Mail.register_interceptor RecipientInterceptor.new(ENV['EMAIL_RECIPIENTS'])\n"
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_partials_directory
|
82
|
+
empty_directory 'app/views/application'
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_shared_flashes
|
86
|
+
copy_file '_flashes.html.slim.erb', 'app/views/application/_flashes.html.slim'
|
87
|
+
end
|
88
|
+
|
89
|
+
def create_shared_javascripts
|
90
|
+
copy_file '_javascript.html.slim.erb', 'app/views/application/_javascript.html.slim'
|
91
|
+
end
|
92
|
+
|
93
|
+
def create_application_layout
|
94
|
+
remove_file 'app/views/layouts/application.html.erb'
|
95
|
+
template 'application.html.slim.erb',
|
96
|
+
'app/views/layouts/application.html.slim',
|
97
|
+
force: true
|
98
|
+
end
|
99
|
+
|
100
|
+
# def remove_turbolinks
|
101
|
+
# replace_in_file 'app/assets/javascripts/application.js',
|
102
|
+
# /\/\/= require turbolinks\n/,
|
103
|
+
# ''
|
104
|
+
# end
|
105
|
+
|
106
|
+
def create_common_javascripts
|
107
|
+
directory 'javascripts', 'app/assets/javascripts'
|
108
|
+
template 'application.js',
|
109
|
+
'app/assets/javascripts/application.js',
|
110
|
+
force: true
|
111
|
+
end
|
112
|
+
|
113
|
+
def use_postgres_config_template
|
114
|
+
template 'database.yml.erb', 'config/database.yml',
|
115
|
+
force: true
|
116
|
+
end
|
117
|
+
|
118
|
+
def create_database
|
119
|
+
bundle_command 'exec rake db:create'
|
120
|
+
end
|
121
|
+
|
122
|
+
def replace_gemfile
|
123
|
+
remove_file 'Gemfile'
|
124
|
+
copy_file 'Gemfile_clean', 'Gemfile'
|
125
|
+
end
|
126
|
+
|
127
|
+
def set_ruby_to_version_being_used
|
128
|
+
inject_into_file 'Gemfile', "\n\nruby '#{RUBY_VERSION}'",
|
129
|
+
after: /source 'https:\/\/rubygems.org'/
|
130
|
+
end
|
131
|
+
|
132
|
+
def setup_rvmrc
|
133
|
+
run "rvm use ruby-#{RUBY_VERSION}@#{app_name} --ruby-version --create"
|
134
|
+
end
|
135
|
+
|
136
|
+
def enable_database_cleaner
|
137
|
+
copy_file 'database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
|
138
|
+
end
|
139
|
+
|
140
|
+
def configure_rspec
|
141
|
+
remove_file 'spec/spec_helper.rb'
|
142
|
+
copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
|
143
|
+
end
|
144
|
+
|
145
|
+
def use_rspec_binstub
|
146
|
+
run 'bundle binstub rspec-core'
|
147
|
+
run 'rm bin/autospec'
|
148
|
+
end
|
149
|
+
|
150
|
+
def configure_background_jobs_for_rspec
|
151
|
+
copy_file 'background_jobs_rspec.rb', 'spec/support/background_jobs.rb'
|
152
|
+
run 'rails g delayed_job:active_record'
|
153
|
+
end
|
154
|
+
|
155
|
+
def configure_time_zone
|
156
|
+
config = <<-RUBY
|
157
|
+
config.active_record.default_timezone = :utc
|
158
|
+
|
159
|
+
RUBY
|
160
|
+
inject_into_class 'config/application.rb', 'Application', config
|
161
|
+
end
|
162
|
+
|
163
|
+
def configure_time_formats
|
164
|
+
remove_file 'config/locales/en.yml'
|
165
|
+
copy_file 'config_locales_en.yml', 'config/locales/en.yml'
|
166
|
+
end
|
167
|
+
|
168
|
+
def configure_rack_timeout
|
169
|
+
copy_file 'rack_timeout.rb', 'config/initializers/rack_timeout.rb'
|
170
|
+
end
|
171
|
+
|
172
|
+
def configure_action_mailer
|
173
|
+
action_mailer_host 'development', "#{app_name}.local"
|
174
|
+
action_mailer_host 'test', 'www.example.com'
|
175
|
+
action_mailer_host 'staging', "staging.#{app_name}.com"
|
176
|
+
action_mailer_host 'production', "#{app_name}.com"
|
177
|
+
end
|
178
|
+
|
179
|
+
def generate_rspec
|
180
|
+
generate 'rspec:install'
|
181
|
+
end
|
182
|
+
|
183
|
+
# def generate_clearance
|
184
|
+
# generate 'clearance:install'
|
185
|
+
# end
|
186
|
+
|
187
|
+
def configure_unicorn
|
188
|
+
copy_file 'unicorn.rb', 'config/unicorn.rb'
|
189
|
+
end
|
190
|
+
|
191
|
+
def setup_foreman
|
192
|
+
copy_file 'sample.env', '.ample.env'
|
193
|
+
copy_file 'Procfile', 'Procfile'
|
194
|
+
end
|
195
|
+
|
196
|
+
def setup_stylesheets
|
197
|
+
remove_file 'app/assets/stylesheets/application.css'
|
198
|
+
copy_file 'application.css.sass',
|
199
|
+
'app/assets/stylesheets/application.css.sass'
|
200
|
+
directory 'stylesheets', 'app/assets/stylesheets'
|
201
|
+
end
|
202
|
+
|
203
|
+
def gitignore_files
|
204
|
+
remove_file '.gitignore'
|
205
|
+
copy_file 'gitignore', '.gitignore'
|
206
|
+
[
|
207
|
+
'spec/lib',
|
208
|
+
'spec/controllers',
|
209
|
+
'spec/helpers',
|
210
|
+
'spec/support/matchers',
|
211
|
+
'spec/support/mixins',
|
212
|
+
# 'spec/support/shared_examples'
|
213
|
+
].each do |dir|
|
214
|
+
run "mkdir #{dir}"
|
215
|
+
run "touch #{dir}/.keep"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def init_git
|
220
|
+
run 'git init'
|
221
|
+
end
|
222
|
+
|
223
|
+
def create_heroku_apps
|
224
|
+
path_addition = override_path_for_tests
|
225
|
+
run "#{path_addition} heroku create #{app_name}-production --remote=production"
|
226
|
+
run "#{path_addition} heroku create #{app_name}-staging --remote=staging"
|
227
|
+
run "#{path_addition} heroku config:add RACK_ENV=staging RAILS_ENV=staging --remote=staging"
|
228
|
+
end
|
229
|
+
|
230
|
+
def set_heroku_remotes
|
231
|
+
concat_file(
|
232
|
+
'templates/bin_setup',
|
233
|
+
"# Set up staging and production git remotes\r
|
234
|
+
git remote add staging git@heroku.com: #{app_name}-staging.git\r
|
235
|
+
git remote add production git@heroku.com: #{app_name}-production.git"
|
236
|
+
)
|
237
|
+
end
|
238
|
+
|
239
|
+
def create_github_repo(repo_name)
|
240
|
+
path_addition = override_path_for_tests
|
241
|
+
run "#{path_addition} hub create #{repo_name}"
|
242
|
+
end
|
243
|
+
|
244
|
+
def copy_miscellaneous_files
|
245
|
+
copy_file 'errors.rb', 'config/initializers/errors.rb'
|
246
|
+
end
|
247
|
+
|
248
|
+
def customize_error_pages
|
249
|
+
meta_tags =<<-EOS
|
250
|
+
<meta charset='utf-8' />
|
251
|
+
<meta name='ROBOTS' content='NOODP' />
|
252
|
+
EOS
|
253
|
+
style_tags =<<-EOS
|
254
|
+
<link href='/assets/application.css' media='all' rel='stylesheet' type='text/css' />
|
255
|
+
EOS
|
256
|
+
|
257
|
+
%w(500 404 422).each do |page|
|
258
|
+
inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
|
259
|
+
replace_in_file "public/#{page}.html", /<style.+>.+<\/style>/mi, style_tags.strip
|
260
|
+
replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def setup_application_helper
|
265
|
+
template 'application_helper.rb',
|
266
|
+
'app/helpers/application_helper.rb',
|
267
|
+
force: true
|
268
|
+
end
|
269
|
+
|
270
|
+
def update_routes
|
271
|
+
template 'routes.rb.erb',
|
272
|
+
'config/routes.rb',
|
273
|
+
force: true
|
274
|
+
end
|
275
|
+
|
276
|
+
def generate_pages_controller
|
277
|
+
generate 'controller pages index'
|
278
|
+
end
|
279
|
+
|
280
|
+
def setup_admin_section
|
281
|
+
run 'mkdir app/controllers/admin'
|
282
|
+
template 'admin_base_controller.rb',
|
283
|
+
'app/controllers/admin/base_controller.rb'
|
284
|
+
template 'admin_dashboard_controller.rb',
|
285
|
+
'app/controllers/admin/dashboard_controller.rb'
|
286
|
+
run 'mkdir app/views/admin'
|
287
|
+
run 'touvh app/views/admin/dashboard.html.slim'
|
288
|
+
end
|
289
|
+
|
290
|
+
def setup_ability_file
|
291
|
+
template 'ability.rb',
|
292
|
+
'app/models/ability.rb'
|
293
|
+
end
|
294
|
+
|
295
|
+
def disable_xml_params
|
296
|
+
copy_file 'disable_xml_params.rb', 'config/initializers/disable_xml_params.rb'
|
297
|
+
end
|
298
|
+
|
299
|
+
def setup_guard
|
300
|
+
run 'bundle exec guard init'
|
301
|
+
end
|
302
|
+
|
303
|
+
def setup_devise_and_cancan
|
304
|
+
# setup devise/cancan/rolify
|
305
|
+
generate 'devise:install'
|
306
|
+
generate 'devise user'
|
307
|
+
directory 'devise', 'app/views/devise'
|
308
|
+
|
309
|
+
# TODO: convert devise views to slim/bootstrap
|
310
|
+
generate 'rolify:role'
|
311
|
+
end
|
312
|
+
|
313
|
+
def setup_default_rake_task
|
314
|
+
append_file 'Rakefile' do
|
315
|
+
"task(:default).clear\ntask :default => [:spec]\n"
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def migrate_database
|
320
|
+
run 'rake db:migrate'
|
321
|
+
run 'rake db:test:prepare'
|
322
|
+
end
|
323
|
+
|
324
|
+
private
|
325
|
+
|
326
|
+
def override_path_for_tests
|
327
|
+
if ENV['TESTING']
|
328
|
+
support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
|
329
|
+
"PATH=#{support_bin}:$PATH"
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
def factories_spec_rake_task
|
334
|
+
IO.read find_in_source_paths('factories_spec_rake_task.rb')
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|