Class: Bolts::Settings
- Inherits:
-
Object
- Object
- Bolts::Settings
- Defined in:
- lib/bolts/settings.rb
Instance Method Summary collapse
- #data ⇒ Object
- #defaults ⇒ Object
-
#ensure_default_cluster(data) ⇒ Object
When user’s .bolts/settings.yml lack the default cluster, we add it on.
-
#initialize(project_root = '.') ⇒ Settings
constructor
A new instance of Settings.
- #settings_path ⇒ Object
Constructor Details
#initialize(project_root = '.') ⇒ Settings
Returns a new instance of Settings.
5 6 7 |
# File 'lib/bolts/settings.rb', line 5 def initialize(project_root='.') @project_root = project_root end |
Instance Method Details
#data ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bolts/settings.rb', line 9 def data return @data if @data @data = defaults if File.exist?(settings_path) custom_data = YAML.load_file(settings_path) @data.merge!(custom_data) ensure_default_cluster(@data) end @data end |
#defaults ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bolts/settings.rb', line 21 def defaults { "user" => "ec2-user", "service_cluster" => {"default" => "default"} } end |
#ensure_default_cluster(data) ⇒ Object
When user’s .bolts/settings.yml lack the default cluster, we add it on. Otherwise the user get confusing and scary aws-sdk-core/param_validator errors: Example: gist.github.com/bolts/67b9a68a77363b908d1c36047bc2709a
31 32 33 34 35 |
# File 'lib/bolts/settings.rb', line 31 def ensure_default_cluster(data) unless @data["service_cluster"]["default"] @data["service_cluster"]["default"] = "default" end end |
#settings_path ⇒ Object
37 38 39 |
# File 'lib/bolts/settings.rb', line 37 def settings_path "#{ENV['HOME']}/.bolts/settings.yml" end |