Skip to content

Commit

Permalink
KBP-125 #time 4h - Integrate recipient_interceptor GEM
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdibayhan committed Oct 6, 2017
1 parent 5efa2dc commit e37e096
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ def remove_readme_rdoc
force: true
end

def add_gems
# Add gems
append_file('Gemfile', template_content('cybele_Gemfile.erb'))
end

def add_editor_config
copy_file 'editorconfig', '.editorconfig'
end
Expand All @@ -34,5 +39,22 @@ def use_postgres_config_template
def create_database
bundle_command 'exec rake db:create db:migrate'
end

def configure_recipient_interceptor
config = <<-RUBY
Mail.register_interceptor RecipientInterceptor.new(Settings.email.sandbox, subject_prefix: '[STAGING]')
RUBY
configure_environment 'staging', config
end

def setup_staging_environment
run 'cp config/environments/production.rb config/environments/staging.rb'
end

private

def configure_environment(rails_env, config)
inject_into_file("config/environments/#{rails_env}.rb", "\n#{config}", before: "\nend")
end
end
end
16 changes: 16 additions & 0 deletions lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def initialize(*args)
@options.freeze
end

def customize_gemfile
say 'Customize gem file', :green
build :add_gems
bundle_command 'install --binstubs=bin/stubs'
end

def setup_editor_config
say 'Add .editor_config file', :green
build :add_editor_config
Expand Down Expand Up @@ -94,6 +100,16 @@ def setup_responders
build :configure_responders
end

def setup_staging_environment
say 'Setting up the staging environment'
build :setup_staging_environment
end

def configure_recipient_interceptor
say 'Setup mail settings with recipient_interceptor in staging', :green
build :configure_recipient_interceptor
end

def goodbye
say 'Congratulations! That\'s all...', :green
end
Expand Down
3 changes: 3 additions & 0 deletions templates/cybele_Gemfile.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# For never accidentally send emails to real people from staging environment.
gem 'recipient_interceptor', '~> 0.1.2'

0 comments on commit e37e096

Please sign in to comment.