Class: Obfusc::Config
- Inherits:
-
Object
- Object
- Obfusc::Config
- Defined in:
- lib/obfusc/config.rb,
lib/obfusc/commands/concerns/config.rb
Overview
Get/Set configurations with its default values.
Instance Attribute Summary collapse
-
#config_path ⇒ Object
Returns the value of attribute config_path.
-
#extension ⇒ Object
Returns the value of attribute extension.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#simulate ⇒ Object
Returns the value of attribute simulate.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #dry_run ⇒ Object
- #encryptor ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #log(msg) ⇒ Object
- #secret ⇒ Object
- #token ⇒ Object
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 |
# File 'lib/obfusc/config.rb', line 8 def initialize() @config_path = [:config_path] @config_path ||= File.join(ENV['HOME'], '.obfusc.cnf') @extension = [:extension] || 'obfusc' @prefix = [:prefix] || 'obfusc' @verbose = [:verbose] || false @simulate = [:simulate] || false end |
Instance Attribute Details
#config_path ⇒ Object
Returns the value of attribute config_path.
6 7 8 |
# File 'lib/obfusc/config.rb', line 6 def config_path @config_path end |
#extension ⇒ Object
Returns the value of attribute extension.
6 7 8 |
# File 'lib/obfusc/config.rb', line 6 def extension @extension end |
#prefix ⇒ Object
Returns the value of attribute prefix.
6 7 8 |
# File 'lib/obfusc/config.rb', line 6 def prefix @prefix end |
#simulate ⇒ Object
Returns the value of attribute simulate.
6 7 8 |
# File 'lib/obfusc/config.rb', line 6 def simulate @simulate end |
#verbose ⇒ Object
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/obfusc/config.rb', line 6 def verbose @verbose end |
Instance Method Details
#dry_run ⇒ Object
40 41 42 43 44 |
# File 'lib/obfusc/config.rb', line 40 def dry_run return unless block_given? yield unless simulate? end |
#encryptor ⇒ Object
24 25 26 |
# File 'lib/obfusc/config.rb', line 24 def encryptor @encryptor ||= Obfusc::Encryptor.new(self) end |
#log(msg) ⇒ Object
36 37 38 |
# File 'lib/obfusc/config.rb', line 36 def log(msg) puts("DEBUG: #{msg}") if verbose? end |
#secret ⇒ Object
32 33 34 |
# File 'lib/obfusc/config.rb', line 32 def secret settings['secret'] end |
#token ⇒ Object
28 29 30 |
# File 'lib/obfusc/config.rb', line 28 def token settings['token'] end |