Class: Proviso::Command::Config
- Defined in:
- lib/proviso/commands/config.rb
Constant Summary
Constants included from Helpers
Helpers::CONFIG_FILE, Helpers::PROVISO_PATH
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#display, #error, #extract_option, #initialize
Methods included from PluginInterface
#applications, #base_command, #command, included, #selected_application
Methods included from Helpers
#home_directory, #running_on_a_mac?, #running_on_windows?, #yaml_file
Constructor Details
This class inherits a constructor from Proviso::Command::Base
Instance Method Details
#add ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/proviso/commands/config.rb', line 16 def add if @args.length == 3 modify_config_file display "successfully added config setting" else error "section, key and value pair required. eg. config:add [section] [key] [value]" end end |
#create ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/proviso/commands/config.rb', line 34 def create data = { "config" => { "hello" => 'world'}} if @args.length == 1 data = YAML.load_file(yaml_file) if File.exists?(yaml_file) data.merge!(@args.first => {}) else FileUtils.mkdir_p(File.join(home_directory, PROVISO_PATH)) end open(yaml_file, 'w') { |f| f.write data.to_yaml } display "created config file" end |
#list ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/proviso/commands/config.rb', line 6 def list display "List Config" if File.exists?(yaml_file) display open(yaml_file, 'r').read else error "config does not exists run config:create" end end |
#update ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/proviso/commands/config.rb', line 25 def update if @args.length == 3 modify_config_file display "successfully updated config setting" else error "section, key and value pair required. eg. config:update [section] [key] [value]" end end |