Class: Uvcli::Settings
- Inherits:
-
Object
- Object
- Uvcli::Settings
- Defined in:
- lib/uvcli/settings.rb
Constant Summary collapse
- SETTINGS_FOLDER =
File.("~/.uvcli")
- SETTINGS_PATH =
"#{SETTINGS_FOLDER}/uvcli.yml"
Instance Method Summary collapse
- #add_site?(domain, key, secret) ⇒ Boolean
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #sites ⇒ Object
- #store? ⇒ Boolean
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
10 11 12 |
# File 'lib/uvcli/settings.rb', line 10 def initialize load_values end |
Instance Method Details
#add_site?(domain, key, secret) ⇒ Boolean
18 19 20 21 |
# File 'lib/uvcli/settings.rb', line 18 def add_site?(domain, key, secret) @values['sites'] << { "domain" => domain, "key" => key, "secret" => secret } store? end |
#sites ⇒ Object
14 15 16 |
# File 'lib/uvcli/settings.rb', line 14 def sites @values['sites'] end |
#store? ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/uvcli/settings.rb', line 23 def store? file, settings = nil if has_stored_settings? settings = @values file = File.open(SETTINGS_PATH, 'w') else FileUtils.mkdir_p(SETTINGS_FOLDER) file = File.new(SETTINGS_PATH, 'w') settings = { "version" => Uvcli::VERSION, "sites" => [] } end if file file.puts(settings.to_yaml) file.close return true end false end |