Class: Argosnap::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/argosnap/config.rb

Overview

Handle configuration files and create ‘logger’ object

Instance Method Summary collapse

Instance Method Details

#dataObject

Load configuration data as a hash



25
26
27
# File 'lib/argosnap/config.rb', line 25

def data
  YAML::load_file(files[:config])
end

#filesObject

Configuration files hash



11
12
13
14
15
16
17
# File 'lib/argosnap/config.rb', line 11

def files
  {
    config: "#{Dir.home}/.argosnap/config.yml", 
    home: "#{Dir.home}/.argosnap/", 
    logfile: "#{Dir.home}/.argosnap/argosnap.log"
  }
end

#gem_available?(name) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/argosnap/config.rb', line 29

def gem_available?(name)
     Gem::Specification.find_by_name(name)
rescue Gem::LoadError
     false
rescue
     Gem.available?(name)
end

#log_and_abort(msg) ⇒ Object



37
38
39
40
# File 'lib/argosnap/config.rb', line 37

def log_and_abort(msg)
  logger.error(msg)
  Kernel.abort(msg)
end

#loggerObject

Create the logger object



20
21
22
# File 'lib/argosnap/config.rb', line 20

def logger
  Logger.new(files[:logfile], 10, 1024000)
end