Class: Lono::Setting
- Inherits:
-
Object
- Object
- Lono::Setting
- Defined in:
- lib/lono/setting.rb
Constant Summary collapse
- @@data =
data contains the settings.yml config. The order or precedence for settings is the project lono/settings.yml and then the ~/.lono/settings.yml.
nil
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(check_lono_project = true) ⇒ Setting
constructor
A new instance of Setting.
-
#s3_folder ⇒ Object
Special helper method to support multiple formats for s3_folder setting.
Constructor Details
#initialize(check_lono_project = true) ⇒ Setting
Returns a new instance of Setting.
5 6 7 |
# File 'lib/lono/setting.rb', line 5 def initialize(check_lono_project=true) @check_lono_project = check_lono_project end |
Instance Method Details
#data ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/lono/setting.rb', line 12 def data return @@data if @@data if @check_lono_project && !File.exist?(project_settings_path) puts "ERROR: No settings file at #{project_settings_path}. Are you sure you are in a project with lono setup?".colorize(:red) exit 1 end # project based settings files project = load_file(project_settings_path) user_file = "#{ENV['HOME']}/.lono/settings.yml" user = load_file(user_file) default_file = File.("../default/settings.yml", __FILE__) default = load_file(default_file) all_envs = default.deep_merge(user.deep_merge(project)) all_envs = merge_base(all_envs) @@data = all_envs[Lono.env] || all_envs["base"] || {} end |
#s3_folder ⇒ Object
Special helper method to support multiple formats for s3_folder setting. Format 1: Simple String
development:
s3_folder: mybucket/path/to/folder
Format 2: Hash
development:
s3_folder:
default: mybucket/path/to/folder
dev_profile1: mybucket/path/to/folder
dev_profile1: another-bucket/storage/path
48 49 50 51 52 53 54 |
# File 'lib/lono/setting.rb', line 48 def s3_folder s3_folder = data['s3_folder'] return s3_folder if s3_folder.nil? or s3_folder.is_a?(String) # If reach here then the s3_folder is a Hash s3_folder[ENV['AWS_PROFILE']] || s3_folder["default"] end |