Skip to content

Commit

Permalink
KBP-126 #time 40m - Integrate config GEM and fill settings.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdibayhan committed Oct 6, 2017
1 parent e37e096 commit 08199a0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
43 changes: 43 additions & 0 deletions lib/cybele/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,49 @@ def setup_staging_environment
run 'cp config/environments/production.rb config/environments/staging.rb'
end

def generate_config
generate 'config:install'
run 'cp config/settings/development.yml config/settings/staging.yml'
end

def fill_settings_yml
config = <<-YML
email:
sandbox: sandbox@#{app_name}.com
noreply: no-reply@#{app_name}.com
admin: admin@#{app_name}.com
basic_auth:
username: #{app_name}
password: #{app_name}
sidekiq:
username: #{app_name}
password: #{app_name}
root_path: <%= ENV['ROOT_PATH'] %>
smtp:
address: <%= ENV['SMTP_ADDRESS'] %>
port: 587
enable_starttls_auto: true
user_name: <%= ENV['SMTP_USER_NAME'] %>
password: <%= ENV['SMTP_PASSWORD'] %>
authentication: 'plain'
AWS:
S3:
bucket: <%= ENV['S3_BUCKET_NAME'] %>
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
aws_url: http://<%= ENV['AWS_RAW_URL'] %>
aws_raw_url: <%= ENV['AWS_RAW_URL'] %>
# Bucket region should be ireland for this setting
end_point: s3-eu-west-1.amazonaws.com
YML
prepend_file 'config/settings.yml', config
end

private

def configure_environment(rails_env, config)
Expand Down
12 changes: 11 additions & 1 deletion lib/cybele/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def setup_responders
end

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

Expand All @@ -110,6 +110,16 @@ def configure_recipient_interceptor
build :configure_recipient_interceptor
end

def setup_config
say 'Generate config', :green
build :generate_config
end

def fill_settings_yml
say 'Fill to settings.yml file', :green
build :fill_settings_yml
end

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

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

# RailsConfig helps you easily manage environment specific Rails settings in an easy and usable manner
gem 'config', '~> 1.5'

0 comments on commit 08199a0

Please sign in to comment.