yupi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +11 -0
  5. data/CONTRIBUTING.md +33 -0
  6. data/Gemfile +3 -0
  7. data/Gemfile.lock +139 -0
  8. data/LICENSE +21 -0
  9. data/NEWS.md +8 -0
  10. data/README.md +72 -0
  11. data/Rakefile +11 -0
  12. data/bin/rake +16 -0
  13. data/bin/rspec +16 -0
  14. data/bin/setup +9 -0
  15. data/bin/yupi +13 -0
  16. data/lib/yupi.rb +4 -0
  17. data/lib/yupi/actions.rb +33 -0
  18. data/lib/yupi/app_builder.rb +368 -0
  19. data/lib/yupi/generators/app_generator.rb +201 -0
  20. data/lib/yupi/version.rb +5 -0
  21. data/spec/features/new_project_spec.rb +135 -0
  22. data/spec/spec_helper.rb +24 -0
  23. data/spec/support/yupi.rb +51 -0
  24. data/templates/Gemfile.erb +52 -0
  25. data/templates/Procfile +2 -0
  26. data/templates/README.md.erb +32 -0
  27. data/templates/assets/application.css.scss +4 -0
  28. data/templates/assets/application.js +3 -0
  29. data/templates/bin/setup.erb +23 -0
  30. data/templates/config/application.yml.sample +4 -0
  31. data/templates/config/i18n_tasks.yml +13 -0
  32. data/templates/config/initializers/disable_xml_params.rb +3 -0
  33. data/templates/config/initializers/errors.rb +34 -0
  34. data/templates/config/initializers/json_encoding.rb +1 -0
  35. data/templates/config/initializers/mail_interceptor.rb +3 -0
  36. data/templates/config/initializers/rack_timeout.rb +1 -0
  37. data/templates/config/locales_en.yml.erb +19 -0
  38. data/templates/config/newrelic.yml.erb +30 -0
  39. data/templates/config/postgresql_database.yml.erb +12 -0
  40. data/templates/config/rails_secrets.yml +11 -0
  41. data/templates/config/smtp.rb +9 -0
  42. data/templates/dot_gitignore +15 -0
  43. data/templates/spec/rails_helper.rb +23 -0
  44. data/templates/spec/spec_helper.rb +17 -0
  45. data/templates/spec/support/action_mailer.rb +5 -0
  46. data/templates/spec/support/database_cleaner_rspec.rb +21 -0
  47. data/templates/spec/support/factory_girl_rspec.rb +3 -0
  48. data/templates/spec/support/i18n.rb +3 -0
  49. data/templates/tasks/bundler_audit.rake +12 -0
  50. data/templates/tasks/development_seeds.rake +12 -0
  51. data/templates/views/application/_analytics.html.erb +7 -0
  52. data/templates/views/application/_flashes.html.erb +6 -0
  53. data/templates/views/application/_footer.html.erb +17 -0
  54. data/templates/views/application/_javascript.html.erb +12 -0
  55. data/templates/views/application/_navigation.html.erb +18 -0
  56. data/templates/views/application/_navigation_links.html.erb +2 -0
  57. data/templates/views/layouts/application.html.erb.erb +43 -0
  58. data/templates/views/pages/home.html.erb +1 -0
  59. data/yupi.gemspec +36 -0
  60. metadata +187 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa20f538cce4b04f6d5f29a0b132c320e17b99c5
4
+ data.tar.gz: 96bd38a26e3cd8bf00d7bc2ad8ccc9ecaba64c1e
5
+ SHA512:
6
+ metadata.gz: 5590e79e6bf315f120b98d6d100e4da96a07d370cde2f0b5471f62013ee6ca8e6289390ce85f3b9642c91cafde1682f9cae253989508010d46b4dd4f56108e62
7
+ data.tar.gz: e6b59df1afa4f9497f4848657f98a719c01b1399141e0e3db3efe4be8c3a65bfe6f8b670cbc1b912ac4f9f614e3b12c151e154f26074c95b7f5254a1d9516163
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ *.swp
3
+ /.bundle
4
+ /tmp
@@ -0,0 +1 @@
1
+ 2.2.1
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm: 2.2.1
3
+ cache: bundler
4
+ sudo: false
5
+ before_install:
6
+ - "echo '--colour' > ~/.rspec"
7
+ - git config --global user.name 'Travis CI'
8
+ - git config --global user.email 'travis-ci@example.com'
9
+ install: bundle install
10
+ notifications:
11
+ email: false
@@ -0,0 +1,33 @@
1
+ # Contributing
2
+
3
+ Fork the repo.
4
+
5
+ Set up your machine:
6
+
7
+ ./bin/setup
8
+
9
+ Make sure the tests pass:
10
+
11
+ rake
12
+
13
+ Make your change.
14
+ Write tests.
15
+ Make the tests pass:
16
+
17
+ rake
18
+
19
+ Write a [good commit message][commit].
20
+ Push to your fork.
21
+ [Submit a pull request][pr].
22
+
23
+ [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
24
+ [pr]: https://github.com/Anadea/yupi/compare/
25
+
26
+ Wait for us.
27
+ We try to at least comment on pull requests within one business day.
28
+ We may suggest changes.
29
+
30
+ ## Versions
31
+
32
+ To update the Ruby version,
33
+ change `.ruby-version` and `.travis.yml`.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yupi (0.1.0)
5
+ bitters (~> 1.0.0)
6
+ bundler (~> 1.3)
7
+ rails (= 4.2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (4.2.1)
13
+ actionpack (= 4.2.1)
14
+ actionview (= 4.2.1)
15
+ activejob (= 4.2.1)
16
+ mail (~> 2.5, >= 2.5.4)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ actionpack (4.2.1)
19
+ actionview (= 4.2.1)
20
+ activesupport (= 4.2.1)
21
+ rack (~> 1.6)
22
+ rack-test (~> 0.6.2)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
25
+ actionview (4.2.1)
26
+ activesupport (= 4.2.1)
27
+ builder (~> 3.1)
28
+ erubis (~> 2.7.0)
29
+ rails-dom-testing (~> 1.0, >= 1.0.5)
30
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
31
+ activejob (4.2.1)
32
+ activesupport (= 4.2.1)
33
+ globalid (>= 0.3.0)
34
+ activemodel (4.2.1)
35
+ activesupport (= 4.2.1)
36
+ builder (~> 3.1)
37
+ activerecord (4.2.1)
38
+ activemodel (= 4.2.1)
39
+ activesupport (= 4.2.1)
40
+ arel (~> 6.0)
41
+ activesupport (4.2.1)
42
+ i18n (~> 0.7)
43
+ json (~> 1.7, >= 1.7.7)
44
+ minitest (~> 5.1)
45
+ thread_safe (~> 0.3, >= 0.3.4)
46
+ tzinfo (~> 1.1)
47
+ arel (6.0.0)
48
+ bitters (1.0.0)
49
+ bourbon (>= 3.2)
50
+ sass (>= 3.2)
51
+ thor
52
+ bourbon (4.2.1)
53
+ sass (~> 3.4)
54
+ thor
55
+ builder (3.2.2)
56
+ capybara (2.3.0)
57
+ mime-types (>= 1.16)
58
+ nokogiri (>= 1.3.3)
59
+ rack (>= 1.0.0)
60
+ rack-test (>= 0.5.4)
61
+ xpath (~> 2.0)
62
+ diff-lcs (1.2.5)
63
+ erubis (2.7.0)
64
+ globalid (0.3.3)
65
+ activesupport (>= 4.1.0)
66
+ hike (1.2.3)
67
+ i18n (0.7.0)
68
+ json (1.8.2)
69
+ loofah (2.0.1)
70
+ nokogiri (>= 1.5.9)
71
+ mail (2.6.3)
72
+ mime-types (>= 1.16, < 3)
73
+ mime-types (2.4.3)
74
+ mini_portile (0.6.0)
75
+ minitest (5.5.1)
76
+ multi_json (1.11.0)
77
+ nokogiri (1.6.2.1)
78
+ mini_portile (= 0.6.0)
79
+ rack (1.6.0)
80
+ rack-test (0.6.2)
81
+ rack (>= 1.0)
82
+ rails (4.2.1)
83
+ actionmailer (= 4.2.1)
84
+ actionpack (= 4.2.1)
85
+ actionview (= 4.2.1)
86
+ activejob (= 4.2.1)
87
+ activemodel (= 4.2.1)
88
+ activerecord (= 4.2.1)
89
+ activesupport (= 4.2.1)
90
+ bundler (>= 1.3.0, < 2.0)
91
+ railties (= 4.2.1)
92
+ sprockets-rails
93
+ rails-deprecated_sanitizer (1.0.3)
94
+ activesupport (>= 4.2.0.alpha)
95
+ rails-dom-testing (1.0.6)
96
+ activesupport (>= 4.2.0.beta, < 5.0)
97
+ nokogiri (~> 1.6.0)
98
+ rails-deprecated_sanitizer (>= 1.0.1)
99
+ rails-html-sanitizer (1.0.2)
100
+ loofah (~> 2.0)
101
+ railties (4.2.1)
102
+ actionpack (= 4.2.1)
103
+ activesupport (= 4.2.1)
104
+ rake (>= 0.8.7)
105
+ thor (>= 0.18.1, < 2.0)
106
+ rake (10.4.2)
107
+ rspec (2.99.0)
108
+ rspec-core (~> 2.99.0)
109
+ rspec-expectations (~> 2.99.0)
110
+ rspec-mocks (~> 2.99.0)
111
+ rspec-core (2.99.0)
112
+ rspec-expectations (2.99.0)
113
+ diff-lcs (>= 1.1.3, < 2.0)
114
+ rspec-mocks (2.99.0)
115
+ sass (3.4.13)
116
+ sprockets (2.12.3)
117
+ hike (~> 1.2)
118
+ multi_json (~> 1.0)
119
+ rack (~> 1.0)
120
+ tilt (~> 1.1, != 1.3.0)
121
+ sprockets-rails (2.2.4)
122
+ actionpack (>= 3.0)
123
+ activesupport (>= 3.0)
124
+ sprockets (>= 2.8, < 4.0)
125
+ thor (0.19.1)
126
+ thread_safe (0.3.5)
127
+ tilt (1.4.1)
128
+ tzinfo (1.2.2)
129
+ thread_safe (~> 0.1)
130
+ xpath (2.0.0)
131
+ nokogiri (~> 1.3)
132
+
133
+ PLATFORMS
134
+ ruby
135
+
136
+ DEPENDENCIES
137
+ capybara (~> 2.2, >= 2.2.0)
138
+ rspec (~> 2.0)
139
+ yupi!
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2015 Dmitriy Kiriyenko and Anadea 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/NEWS.md ADDED
@@ -0,0 +1,8 @@
1
+ 0.1.0 (March 27, 2015)
2
+
3
+ * We're clean and ready to become powerful!
4
+
5
+
6
+ 0.0.1 (March 26, 2015)
7
+
8
+ * We're out!
@@ -0,0 +1,72 @@
1
+ # Yupi [![Build Status](https://secure.travis-ci.org/Anadea/yupi.svg?branch=master)](http://travis-ci.org/Anadea/yupi)
2
+
3
+ Yupi is the base Rails application used at
4
+ [anadea](http://anadea.info).
5
+
6
+ ![Yupi juice](http://www.dismarex.com.ec/pro/img/YUPI.jpg)
7
+
8
+ ## Installation
9
+
10
+ First install the yupi gem:
11
+
12
+ gem install yupi
13
+
14
+ Then run:
15
+
16
+ yupi projectname
17
+
18
+ This will create a Rails app in `projectname` using the latest version of Rails.
19
+
20
+ ## Gemfile
21
+
22
+ To see the latest and greatest gems, look at Yupi'
23
+ [Gemfile](templates/Gemfile.erb), which will be appended to the default
24
+ generated projectname/Gemfile.
25
+
26
+ ## Dependencies
27
+
28
+ Yupi requires the latest version of Ruby.
29
+
30
+ Some gems included in Yupi have native extensions. You should have GCC
31
+ installed on your machine before generating an app with Yupi.
32
+
33
+ Use [OS X GCC Installer](https://github.com/kennethreitz/osx-gcc-installer/) for
34
+ Snow Leopard (OS X 10.6).
35
+
36
+ Use [Command Line Tools for XCode](https://developer.apple.com/downloads/index.action)
37
+ for Lion (OS X 10.7) or Mountain Lion (OS X 10.8).
38
+
39
+ We use [Poltergeist](https://github.com/teampoltergeist/poltergeist) for
40
+ full-stack JavaScript integration testing. It requires PhantomJS. Instructions for
41
+ installing it are
42
+ [here](https://github.com/teampoltergeist/poltergeist#installing-phantomjs).
43
+
44
+ PostgreSQL needs to be installed and running for the `db:create` rake task.
45
+
46
+ ## Issues
47
+
48
+ If you have problems, please create a
49
+ [GitHub Issue](https://github.com/Anadea/yupi/issues).
50
+
51
+ ## License
52
+
53
+ Yupi is Copyright © 2008-2015 Anadea.
54
+ It is free software,
55
+ and may be redistributed under the terms specified in the [LICENSE] file.
56
+
57
+ [LICENSE]: LICENSE
58
+
59
+ ## Thanks
60
+
61
+ To [suspenders](https://github.com/thoughtbot/suspenders).
62
+
63
+ ## About Anadea
64
+
65
+ ![anadea](https://avatars2.githubusercontent.com/u/4539766?v=3&s=200)
66
+
67
+ Yupi is maintained and funded by Anadea, inc.
68
+ The names and logos for Anadea are trademarks of Anadea, inc.
69
+
70
+ We are [available for hire][hire].
71
+
72
+ [hire]: https://anadea.info/en?utm_source=github
@@ -0,0 +1,11 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:rspec)
6
+ RSpec::Core::RakeTask.new(:smoke) do |t|
7
+ t.rspec_opts = "--tag smoke"
8
+ end
9
+
10
+ desc 'Run the test suite'
11
+ task :default => :rspec
@@ -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')
@@ -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,9 @@
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
@@ -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 'yupi'
8
+
9
+ templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
10
+ Yupi::AppGenerator.source_root templates_root
11
+ Yupi::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root << templates_root
12
+
13
+ Yupi::AppGenerator.start
@@ -0,0 +1,4 @@
1
+ require 'yupi/version'
2
+ require 'yupi/generators/app_generator'
3
+ require 'yupi/actions'
4
+ require 'yupi/app_builder'
@@ -0,0 +1,33 @@
1
+ module Yupi
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
+ config = "config.action_mailer.default_url_options = { host: #{host} }"
14
+ configure_environment(rails_env, config)
15
+ end
16
+
17
+ def configure_application_file(config)
18
+ inject_into_file(
19
+ "config/application.rb",
20
+ "\n\n #{config}",
21
+ before: "\n end"
22
+ )
23
+ end
24
+
25
+ def configure_environment(rails_env, config)
26
+ inject_into_file(
27
+ "config/environments/#{rails_env}.rb",
28
+ "\n\n #{config}",
29
+ before: "\nend"
30
+ )
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,368 @@
1
+ module Yupi
2
+ class AppBuilder < Rails::AppBuilder
3
+ include Yupi::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 set_test_delivery_method
15
+ inject_into_file(
16
+ "config/environments/development.rb",
17
+ "\n config.action_mailer.delivery_method = :test",
18
+ after: "config.action_mailer.raise_delivery_errors = true",
19
+ )
20
+ end
21
+
22
+ def raise_on_unpermitted_parameters
23
+ config = <<-RUBY
24
+ config.action_controller.action_on_unpermitted_parameters = :raise
25
+ RUBY
26
+
27
+ inject_into_class "config/application.rb", "Application", config
28
+ end
29
+
30
+ def provide_setup_script
31
+ template "bin/setup.erb", "bin/setup", force: true
32
+ run "chmod a+x bin/setup"
33
+ end
34
+
35
+ def provide_dev_prime_task
36
+ copy_file 'tasks/development_seeds.rake', 'lib/tasks/development_seeds.rake'
37
+ end
38
+
39
+ def configure_generators
40
+ config = <<-RUBY
41
+
42
+ config.generators do |generate|
43
+ generate.helper false
44
+ generate.javascript_engine false
45
+ generate.request_specs false
46
+ generate.routing_specs false
47
+ generate.stylesheets false
48
+ generate.test_framework :rspec
49
+ generate.view_specs false
50
+ end
51
+
52
+ RUBY
53
+
54
+ inject_into_class 'config/application.rb', 'Application', config
55
+ end
56
+
57
+ def set_up_factory_girl_for_rspec
58
+ copy_file 'spec/support/factory_girl_rspec.rb', 'spec/support/factory_girl.rb'
59
+ end
60
+
61
+ def configure_newrelic
62
+ template 'config/newrelic.yml.erb', 'config/newrelic.yml'
63
+ end
64
+
65
+ def configure_smtp
66
+ copy_file 'config/smtp.rb', 'config/smtp.rb'
67
+
68
+ prepend_file 'config/environments/production.rb',
69
+ %{require Rails.root.join("config/smtp")\n}
70
+
71
+ config = <<-RUBY
72
+
73
+ config.action_mailer.delivery_method = :smtp
74
+ config.action_mailer.smtp_settings = SMTP_SETTINGS
75
+ RUBY
76
+
77
+ inject_into_file 'config/environments/production.rb', config,
78
+ :after => 'config.action_mailer.raise_delivery_errors = false'
79
+ end
80
+
81
+ def enable_rack_deflater
82
+ config = <<-RUBY
83
+
84
+ # Enable deflate / gzip compression of controller-generated responses
85
+ config.middleware.use Rack::Deflater
86
+ RUBY
87
+
88
+ inject_into_file(
89
+ "config/environments/production.rb",
90
+ config,
91
+ after: serve_static_files_line
92
+ )
93
+ end
94
+
95
+ def setup_asset_host
96
+ replace_in_file 'config/environments/production.rb',
97
+ "# config.action_controller.asset_host = 'http://assets.example.com'",
98
+ 'config.action_controller.asset_host = ENV.fetch("ASSET_HOST", ENV.fetch("HOST"))'
99
+
100
+ replace_in_file 'config/initializers/assets.rb',
101
+ "config.assets.version = '1.0'",
102
+ 'config.assets.version = ENV.fetch("ASSETS_VERSION", "1.0")'
103
+
104
+ inject_into_file(
105
+ "config/environments/production.rb",
106
+ ' config.static_cache_control = "public, max-age=#{1.year.to_i}"',
107
+ after: serve_static_files_line
108
+ )
109
+ end
110
+
111
+ def setup_secret_token
112
+ template 'config/rails_secrets.yml', 'config/secrets.yml', force: true
113
+ end
114
+
115
+ def disallow_wrapping_parameters
116
+ remove_file "config/initializers/wrap_parameters.rb"
117
+ end
118
+
119
+ def create_partials
120
+ empty_directory 'app/views/application'
121
+
122
+ copy_file 'views/application/_flashes.html.erb',
123
+ 'app/views/application/_flashes.html.erb'
124
+ copy_file 'views/application/_javascript.html.erb',
125
+ 'app/views/application/_javascript.html.erb'
126
+ copy_file 'views/application/_navigation.html.erb',
127
+ 'app/views/application/_navigation.html.erb'
128
+ copy_file 'views/application/_navigation_links.html.erb',
129
+ 'app/views/application/_navigation_links.html.erb'
130
+ copy_file 'views/application/_analytics.html.erb',
131
+ 'app/views/application/_analytics.html.erb'
132
+ copy_file 'views/application/_footer.html.erb',
133
+ 'app/views/application/_footer.html.erb'
134
+ end
135
+
136
+ def create_home_page
137
+ copy_file 'views/pages/home.html.erb',
138
+ 'app/views/pages/home.html.erb'
139
+ end
140
+
141
+ def create_application_layout
142
+ template 'views/layouts/application.html.erb.erb',
143
+ 'app/views/layouts/application.html.erb',
144
+ force: true
145
+ end
146
+
147
+ def use_postgres_config_template
148
+ template 'config/postgresql_database.yml.erb', 'config/database.yml',
149
+ force: true
150
+ end
151
+
152
+ def create_database
153
+ bundle_command 'exec rake db:create db:migrate'
154
+ end
155
+
156
+ def replace_gemfile
157
+ remove_file 'Gemfile'
158
+ template 'Gemfile.erb', 'Gemfile'
159
+ end
160
+
161
+ def set_ruby_to_version_being_used
162
+ create_file '.ruby-version', "#{Yupi::RUBY_VERSION}\n"
163
+ end
164
+
165
+ def enable_database_cleaner
166
+ copy_file 'spec/support/database_cleaner_rspec.rb', 'spec/support/database_cleaner.rb'
167
+ end
168
+
169
+ def configure_spec_support_features
170
+ empty_directory_with_keep_file 'spec/lib'
171
+ empty_directory_with_keep_file 'spec/features'
172
+
173
+ empty_directory_with_keep_file 'spec/support/matchers'
174
+ empty_directory_with_keep_file 'spec/support/mixins'
175
+ empty_directory_with_keep_file 'spec/support/shared_examples'
176
+ empty_directory_with_keep_file 'spec/support/features'
177
+ end
178
+
179
+ def configure_rspec
180
+ remove_file "spec/rails_helper.rb"
181
+ remove_file "spec/spec_helper.rb"
182
+ copy_file "spec/rails_helper.rb", "spec/rails_helper.rb"
183
+ copy_file "spec/spec_helper.rb", "spec/spec_helper.rb"
184
+ end
185
+
186
+ def configure_i18n_for_test_environment
187
+ copy_file "spec/support/i18n.rb", "spec/support/i18n.rb"
188
+ end
189
+
190
+ def configure_i18n_for_missing_translations
191
+ raise_on_missing_translations_in("development")
192
+ raise_on_missing_translations_in("test")
193
+ end
194
+
195
+ def configure_i18n_tasks
196
+ run "cp $(i18n-tasks gem-path)/templates/rspec/i18n_spec.rb spec/"
197
+ copy_file "config/i18n_tasks.yml", "config/i18n-tasks.yml"
198
+ end
199
+
200
+ def configure_background_jobs_for_rspec
201
+ run 'rails g delayed_job:active_record'
202
+ end
203
+
204
+ def configure_action_mailer_in_specs
205
+ copy_file 'spec/support/action_mailer.rb', 'spec/support/action_mailer.rb'
206
+ end
207
+
208
+ def configure_time_formats
209
+ remove_file "config/locales/en.yml"
210
+ template "config/locales_en.yml.erb", "config/locales/en.yml"
211
+ end
212
+
213
+ def configure_rack_timeout
214
+ copy_file 'config/initializers/rack_timeout.rb',
215
+ 'config/initializers/rack_timeout.rb'
216
+ end
217
+
218
+ def configure_mail_interceptor
219
+ copy_file 'config/initializers/mail_interceptor.rb',
220
+ 'config/initializers/mail_interceptor.rb'
221
+ end
222
+
223
+ def configure_simple_form
224
+ # Here we suppress simple_form warning that simple_form hasn't been configured
225
+ bundle_command "exec rails generate simple_form:install --bootstrap > /dev/null 2>&1"
226
+ end
227
+
228
+ def configure_action_mailer
229
+ action_mailer_host "development", %{"localhost:3000"}
230
+ action_mailer_host "test", %{"www.example.com"}
231
+ action_mailer_host "production", %{ENV.fetch("HOST")}
232
+ end
233
+
234
+ def configure_active_job
235
+ configure_application_file(
236
+ "config.active_job.queue_adapter = :delayed_job"
237
+ )
238
+ configure_environment "test", "config.active_job.queue_adapter = :inline"
239
+ end
240
+
241
+ def fix_i18n_deprecation_warning
242
+ config = <<-RUBY
243
+ config.i18n.enforce_available_locales = true
244
+ RUBY
245
+
246
+ inject_into_class 'config/application.rb', 'Application', config
247
+ end
248
+
249
+ def generate_rspec
250
+ generate 'rspec:install'
251
+ end
252
+
253
+ def configure_puma
254
+ bundle_command 'binstub puma'
255
+ remove_file 'bin/pumactl'
256
+ end
257
+
258
+ def setup_foreman
259
+ copy_file 'Procfile', 'Procfile'
260
+ end
261
+
262
+ def setup_figaro
263
+ copy_file 'config/application.yml.sample', 'config/application.yml.sample'
264
+ end
265
+
266
+ def setup_stylesheets
267
+ remove_file 'app/assets/stylesheets/application.css'
268
+ copy_file 'assets/application.css.scss',
269
+ 'app/assets/stylesheets/application.css.scss'
270
+ end
271
+
272
+ def setup_javascripts
273
+ remove_file 'app/assets/javascripts/application.js'
274
+ copy_file 'assets/application.js',
275
+ 'app/assets/javascripts/application.js'
276
+ end
277
+
278
+ def gitignore_files
279
+ remove_file '.gitignore'
280
+ copy_file 'dot_gitignore', '.gitignore'
281
+ end
282
+
283
+ def init_git
284
+ run 'git init'
285
+ end
286
+
287
+ def setup_bundler_audit
288
+ copy_file "tasks/bundler_audit.rake", "lib/tasks/bundler_audit.rake"
289
+ append_file "Rakefile", %{\ntask default: "bundler:audit"\n}
290
+ end
291
+
292
+ def copy_miscellaneous_files
293
+ copy_file "config/initializers/errors.rb", "config/initializers/errors.rb"
294
+ copy_file "config/initializers/json_encoding.rb", "config/initializers/json_encoding.rb"
295
+ end
296
+
297
+ def customize_error_pages
298
+ meta_tags =<<-EOS
299
+ <meta charset="utf-8" />
300
+ <meta name="ROBOTS" content="NOODP" />
301
+ <meta name="viewport" content="initial-scale=1" />
302
+ EOS
303
+
304
+ %w(500 404 422).each do |page|
305
+ inject_into_file "public/#{page}.html", meta_tags, :after => "<head>\n"
306
+ replace_in_file "public/#{page}.html", /<!--.+-->\n/, ''
307
+ end
308
+ end
309
+
310
+ def remove_routes_comment_lines
311
+ replace_in_file 'config/routes.rb',
312
+ /Rails\.application\.routes\.draw do.*end/m,
313
+ "Rails.application.routes.draw do\nend"
314
+ end
315
+
316
+ def add_root_route
317
+ route "root 'high_voltage/pages#show', id: 'home'"
318
+ end
319
+
320
+ def disable_xml_params
321
+ copy_file 'config/initializers/disable_xml_params.rb',
322
+ 'config/initializers/disable_xml_params.rb'
323
+ end
324
+
325
+ def setup_default_rake_task
326
+ append_file 'Rakefile' do
327
+ <<-EOS
328
+ task(:default).clear
329
+ task default: [:spec]
330
+
331
+ if defined? RSpec
332
+ task(:spec).clear
333
+ RSpec::Core::RakeTask.new(:spec) do |t|
334
+ t.verbose = false
335
+ end
336
+ end
337
+ EOS
338
+ end
339
+ end
340
+
341
+ def run_bin_setup
342
+ bundle_command "exec ./bin/setup"
343
+ end
344
+
345
+ private
346
+
347
+ def raise_on_missing_translations_in(environment)
348
+ config = 'config.action_view.raise_on_missing_translations = true'
349
+
350
+ uncomment_lines("config/environments/#{environment}.rb", config)
351
+ end
352
+
353
+ def override_path_for_tests
354
+ if ENV['TESTING']
355
+ support_bin = File.expand_path(File.join('..', '..', 'spec', 'fakes', 'bin'))
356
+ "PATH=#{support_bin}:$PATH"
357
+ end
358
+ end
359
+
360
+ def generate_secret
361
+ SecureRandom.hex(64)
362
+ end
363
+
364
+ def serve_static_files_line
365
+ "config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?\n"
366
+ end
367
+ end
368
+ end