Class: Onotole::Adapters::Heroku
- Inherits:
-
Object
- Object
- Onotole::Adapters::Heroku
- Defined in:
- lib/onotole/adapters/heroku.rb
Instance Method Summary collapse
- #create_heroku_pipeline ⇒ Object
- #create_heroku_pipelines_config_file ⇒ Object
- #create_production_heroku_app(flags) ⇒ Object
- #create_staging_heroku_app(flags) ⇒ Object
-
#initialize(app_builder) ⇒ Heroku
constructor
A new instance of Heroku.
- #provide_review_apps_setup_script ⇒ Object
- #set_heroku_rails_secrets ⇒ Object
- #set_heroku_remotes ⇒ Object
- #set_heroku_serve_static_files ⇒ Object
- #set_up_heroku_specific_gems ⇒ Object
Constructor Details
#initialize(app_builder) ⇒ Heroku
Returns a new instance of Heroku.
5 6 7 |
# File 'lib/onotole/adapters/heroku.rb', line 5 def initialize(app_builder) @app_builder = app_builder end |
Instance Method Details
#create_heroku_pipeline ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/onotole/adapters/heroku.rb', line 64 def create_heroku_pipeline pipelines_plugin = `heroku plugins | grep pipelines` if pipelines_plugin.empty? puts 'You need heroku pipelines plugin. Run: heroku plugins:install heroku-pipelines' exit 1 end heroku_app_name = app_builder.app_name.dasherize run_toolbelt_command( "pipelines:create #{heroku_app_name} \ -a #{heroku_app_name}-staging --stage staging", 'staging' ) run_toolbelt_command( "pipelines:add #{heroku_app_name} \ -a #{heroku_app_name}-production --stage production", 'production' ) end |
#create_heroku_pipelines_config_file ⇒ Object
60 61 62 |
# File 'lib/onotole/adapters/heroku.rb', line 60 def create_heroku_pipelines_config_file app_builder.template 'app.json.erb', 'app.json' end |
#create_production_heroku_app(flags) ⇒ Object
36 37 38 39 40 |
# File 'lib/onotole/adapters/heroku.rb', line 36 def create_production_heroku_app(flags) app_name = heroku_app_name_for('production') run_toolbelt_command "create #{app_name} #{flags}", 'production' end |
#create_staging_heroku_app(flags) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/onotole/adapters/heroku.rb', line 28 def create_staging_heroku_app(flags) rack_env = 'RACK_ENV=staging' app_name = heroku_app_name_for('staging') run_toolbelt_command "create #{app_name} #{flags}", 'staging' run_toolbelt_command "config:add #{rack_env}", 'staging' end |
#provide_review_apps_setup_script ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/onotole/adapters/heroku.rb', line 51 def provide_review_apps_setup_script app_builder.template( 'bin_setup_review_app.erb', 'bin/setup_review_app', force: true ) app_builder.run 'chmod a+x bin/setup_review_app' end |
#set_heroku_rails_secrets ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/onotole/adapters/heroku.rb', line 42 def set_heroku_rails_secrets %w(staging production).each do |environment| run_toolbelt_command( "config:add #{app_builder.app_name.dasherize.upcase}_SECRET_KEY_BASE=#{generate_secret}", environment ) end end |
#set_heroku_remotes ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/onotole/adapters/heroku.rb', line 9 def set_heroku_remotes remotes = <<-SHELL.strip_heredoc #{command_to_join_heroku_app('staging')} #{command_to_join_heroku_app('production')} git config heroku.remote staging SHELL app_builder.append_file 'bin/setup', remotes end |
#set_heroku_serve_static_files ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/onotole/adapters/heroku.rb', line 85 def set_heroku_serve_static_files %w(staging production).each do |environment| run_toolbelt_command( "config:add #{app_name.upcase}_RAILS_SERVE_STATIC_FILES=true", environment ) end end |
#set_up_heroku_specific_gems ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/onotole/adapters/heroku.rb', line 20 def set_up_heroku_specific_gems app_builder.inject_into_file( 'Gemfile', %(\n\s\sgem "rails_stdout_logging"), after: /group :staging, :production do/ ) end |