Skip to content

Commit 08199a0

Browse files
author
hamdibayhan
committed
KBP-126 #time 40m - Integrate config GEM and fill settings.yml file
1 parent e37e096 commit 08199a0

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

lib/cybele/app_builder.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,49 @@ def setup_staging_environment
5151
run 'cp config/environments/production.rb config/environments/staging.rb'
5252
end
5353

54+
def generate_config
55+
generate 'config:install'
56+
run 'cp config/settings/development.yml config/settings/staging.yml'
57+
end
58+
59+
def fill_settings_yml
60+
config = <<-YML
61+
email:
62+
sandbox: sandbox@#{app_name}.com
63+
noreply: no-reply@#{app_name}.com
64+
admin: admin@#{app_name}.com
65+
66+
basic_auth:
67+
username: #{app_name}
68+
password: #{app_name}
69+
70+
sidekiq:
71+
username: #{app_name}
72+
password: #{app_name}
73+
74+
root_path: <%= ENV['ROOT_PATH'] %>
75+
76+
smtp:
77+
address: <%= ENV['SMTP_ADDRESS'] %>
78+
port: 587
79+
enable_starttls_auto: true
80+
user_name: <%= ENV['SMTP_USER_NAME'] %>
81+
password: <%= ENV['SMTP_PASSWORD'] %>
82+
authentication: 'plain'
83+
84+
AWS:
85+
S3:
86+
bucket: <%= ENV['S3_BUCKET_NAME'] %>
87+
access_key_id: <%= ENV['AWS_ACCESS_KEY_ID'] %>
88+
secret_access_key: <%= ENV['AWS_SECRET_ACCESS_KEY'] %>
89+
aws_url: http://<%= ENV['AWS_RAW_URL'] %>
90+
aws_raw_url: <%= ENV['AWS_RAW_URL'] %>
91+
# Bucket region should be ireland for this setting
92+
end_point: s3-eu-west-1.amazonaws.com
93+
YML
94+
prepend_file 'config/settings.yml', config
95+
end
96+
5497
private
5598

5699
def configure_environment(rails_env, config)

lib/cybele/generators/app_generator.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup_responders
101101
end
102102

103103
def setup_staging_environment
104-
say 'Setting up the staging environment'
104+
say 'Setting up the staging environment', :green
105105
build :setup_staging_environment
106106
end
107107

@@ -110,6 +110,16 @@ def configure_recipient_interceptor
110110
build :configure_recipient_interceptor
111111
end
112112

113+
def setup_config
114+
say 'Generate config', :green
115+
build :generate_config
116+
end
117+
118+
def fill_settings_yml
119+
say 'Fill to settings.yml file', :green
120+
build :fill_settings_yml
121+
end
122+
113123
def goodbye
114124
say 'Congratulations! That\'s all...', :green
115125
end

templates/cybele_Gemfile.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11

22
# For never accidentally send emails to real people from staging environment.
3-
gem 'recipient_interceptor', '~> 0.1.2'
3+
gem 'recipient_interceptor', '~> 0.1.2'
4+
5+
# RailsConfig helps you easily manage environment specific Rails settings in an easy and usable manner
6+
gem 'config', '~> 1.5'

0 commit comments

Comments
 (0)