class Obfusc::Config

Get/Set configurations with its default values.

Get/Set configurations with its default values.

Attributes

config_path[RW]
extension[RW]
prefix[RW]
simulate[RW]
verbose[RW]

Public Class Methods

new(options) click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 8
def initialize(options)
  @config_path = options[:config_path]
  @config_path ||= File.join(ENV['HOME'], '.obfusc.cnf')

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

Public Instance Methods

dry_run() { || ... } click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 39
def dry_run
  return unless block_given?

  yield unless simulate?
end
encryptor() click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 23
def encryptor
  @encryptor ||= Obfusc::Encryptor.new(self)
end
log(msg) click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 35
def log(msg)
  puts("DEBUG: #{msg}") if verbose?
end
secret() click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 31
def secret
  settings['secret']
end
token() click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 27
def token
  settings['token']
end

Protected Instance Methods

settings() click to toggle source
# File lib/obfusc/commands/concerns/config.rb, line 47
def settings
  @settings ||= YAML.load_file(config_path)
rescue Errno::ENOENT
  puts "No such file #{config_path}."
  puts "Use: `obfusc setup generate' to generate it"
  {}
end