Class: Factor::Commands::Command
- Inherits:
-
Object
- Object
- Factor::Commands::Command
- Defined in:
- lib/commands/base.rb
Overview
Base command with common methods used by all commands
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_FILENAME =
{ connectors: File.('./connectors.yml'), credentials: File.('./credentials.yml') }
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize ⇒ Command
constructor
A new instance of Command.
- #load_config(options = {}) ⇒ Object
- #save_config(options = {}) ⇒ Object
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
20 21 22 |
# File 'lib/commands/base.rb', line 20 def initialize @logger = Factor::Log::BasicLogger.new end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/commands/base.rb', line 13 def logger @logger end |
Instance Method Details
#load_config(options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/commands/base.rb', line 24 def load_config( = {}) load_config_data :credentials, load_config_data :connectors, end |
#save_config(options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/commands/base.rb', line 29 def save_config(={}) credentials_relative_path = [:credentials] || DEFAULT_FILENAME[:credentials] credentials_absolute_path = File.(credentials_relative_path) connectors_relative_path = [:connectors] || DEFAULT_FILENAME[:connectors] connectors_absolute_path = File.(connectors_relative_path) connectors = Hash[stringify(configatron.connectors.to_h).sort] credentials = Hash[stringify(configatron.credentials.to_h).sort] File.write(connectors_absolute_path,YAML.dump(connectors)) File.write(credentials_absolute_path,YAML.dump(credentials)) end |