Class: Argosnap::Configuration
- Inherits:
-
Object
- Object
- Argosnap::Configuration
- Defined in:
- lib/argosnap/config.rb
Overview
Handle configuration files and create ‘logger’ object
Instance Method Summary collapse
-
#data ⇒ Object
Load configuration data as a hash.
-
#files ⇒ Object
Configuration files hash.
- #gem_available?(name) ⇒ Boolean
- #log_and_abort(msg) ⇒ Object
-
#logger ⇒ Object
Create the logger object.
Instance Method Details
#data ⇒ Object
Load configuration data as a hash
25 26 27 |
# File 'lib/argosnap/config.rb', line 25 def data YAML::load_file(files[:config]) end |
#files ⇒ Object
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
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 |
#logger ⇒ Object
Create the logger object
20 21 22 |
# File 'lib/argosnap/config.rb', line 20 def logger Logger.new(files[:logfile], 10, 1024000) end |