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
Constant Summary collapse
- DEFAULT_FILENAME =
{ connectors: File.('./connectors.yml'), credentials: File.('./credentials.yml') }
Instance Attribute Summary collapse
-
#destination_stream ⇒ Object
Returns the value of attribute destination_stream.
Instance Method Summary collapse
- #error(options = {}) ⇒ Object
- #exception(message, exception) ⇒ Object
- #info(options = {}) ⇒ Object
- #load_config(options = {}) ⇒ Object
- #save_config(options = {}) ⇒ Object
- #success(options = {}) ⇒ Object
- #warn(options = {}) ⇒ Object
Instance Attribute Details
#destination_stream ⇒ Object
Returns the value of attribute destination_stream.
17 18 19 |
# File 'lib/commands/base.rb', line 17 def destination_stream @destination_stream end |
Instance Method Details
#error(options = {}) ⇒ Object
23 24 25 |
# File 'lib/commands/base.rb', line 23 def error( = {}) log_line :error, end |
#exception(message, exception) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/commands/base.rb', line 35 def exception(, exception) error 'message' => error 'message' => " #{exception.}" exception.backtrace.each do |line| error 'message' => " #{line}" end end |
#info(options = {}) ⇒ Object
19 20 21 |
# File 'lib/commands/base.rb', line 19 def info( = {}) log_line :info, end |
#load_config(options = {}) ⇒ Object
43 44 45 46 |
# File 'lib/commands/base.rb', line 43 def load_config( = {}) load_config_data :credentials, load_config_data :connectors, end |
#save_config(options = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/commands/base.rb', line 48 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 |
#success(options = {}) ⇒ Object
31 32 33 |
# File 'lib/commands/base.rb', line 31 def success( = {}) log_line :success, end |
#warn(options = {}) ⇒ Object
27 28 29 |
# File 'lib/commands/base.rb', line 27 def warn( = {}) log_line :warn, end |