Class: BackupRepos::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = Hashie::Mash.new({})) ⇒ Config

Returns a new instance of Config.



8
9
10
# File 'lib/backup_repos/config.rb', line 8

def initialize(options = Hashie::Mash.new({}))
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *_args) ⇒ Object



30
31
32
# File 'lib/backup_repos/config.rb', line 30

def method_missing(name, *_args)
  options.send(name) || config[name.to_s]
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#backup_rootObject



18
19
20
21
# File 'lib/backup_repos/config.rb', line 18

def backup_root
  return if backup_root_dir.blank?
  File.expand_path(backup_root_dir)
end

#config_fileObject



34
35
36
# File 'lib/backup_repos/config.rb', line 34

def config_file
  File.join(Dir.home, '.backup-repos')
end

#debugObject

OPTIONS



14
15
16
# File 'lib/backup_repos/config.rb', line 14

def debug
  options.debug || config['debug']
end

#github_access_tokenObject



23
24
25
26
# File 'lib/backup_repos/config.rb', line 23

def github_access_token
  config_token = config['github']['access_token'] if config['github']
  options.github_access_token || config_token
end