Class: Obfusc::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/obfusc/config.rb,
lib/obfusc/commands/concerns/config.rb

Overview

Get/Set configurations with its default values.

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options)
  @config_path = options[:config_path]
  @config_path ||= File.join(ENV['HOME'], '.obfusc.cnf')

  @extension = options[:extension] || 'obfusc'
  @prefix = options[:prefix] || 'obfusc'
  @verbose = options[:verbose] || false
  @simulate = options[:simulate] || false
end

Instance Attribute Details

#config_pathObject

Returns the value of attribute config_path.



6
7
8
# File 'lib/obfusc/config.rb', line 6

def config_path
  @config_path
end

#extensionObject

Returns the value of attribute extension.



6
7
8
# File 'lib/obfusc/config.rb', line 6

def extension
  @extension
end

#prefixObject

Returns the value of attribute prefix.



6
7
8
# File 'lib/obfusc/config.rb', line 6

def prefix
  @prefix
end

#simulateObject

Returns the value of attribute simulate.



6
7
8
# File 'lib/obfusc/config.rb', line 6

def simulate
  @simulate
end

#verboseObject

Returns the value of attribute verbose.



6
7
8
# File 'lib/obfusc/config.rb', line 6

def verbose
  @verbose
end

Instance Method Details

#dry_runObject



40
41
42
43
44
# File 'lib/obfusc/config.rb', line 40

def dry_run
  return unless block_given?

  yield unless simulate?
end

#encryptorObject



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

#secretObject



32
33
34
# File 'lib/obfusc/config.rb', line 32

def secret
  settings['secret']
end

#tokenObject



28
29
30
# File 'lib/obfusc/config.rb', line 28

def token
  settings['token']
end