class Backto::Config
Constants
- DEFAULT
- EXCLUDE_PATTERNS
Public Class Methods
create(config)
click to toggle source
# File lib/backto/config.rb, line 23 def self.create(config) config.is_a?(self) ? config : new(config) end
new(config = {})
click to toggle source
# File lib/backto/config.rb, line 27 def initialize(config = {}) if config.is_a? String @config = JSON.parse(File.read(config), symbolize_names: true) @base_path = File.expand_path(File.dirname(config)) else @config = config @base_path = Dir.pwd end end
Public Instance Methods
[](name)
click to toggle source
# File lib/backto/config.rb, line 45 def [](name) method = name.to_sym if respond_to? method send method elsif @config.key? method @config[method] else DEFAULT[method] end end
from()
click to toggle source
# File lib/backto/config.rb, line 37 def from @from ||= expand_path fetch(:from) end
to()
click to toggle source
# File lib/backto/config.rb, line 41 def to @to ||= expand_path fetch(:to) end
Private Instance Methods
expand_path(path)
click to toggle source
# File lib/backto/config.rb, line 58 def expand_path(path) File.expand_path path, @base_path end
fetch(name)
click to toggle source
# File lib/backto/config.rb, line 62 def fetch(name) @config.fetch(name) end