class Leg::Config
Attributes
options[R]
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/leg/config.rb, line 5 def initialize(path) @path = path end
Public Instance Methods
last_synced_at()
click to toggle source
# File lib/leg/config.rb, line 15 def last_synced_at File.mtime(last_synced_path) if File.exist?(last_synced_path) end
load!()
click to toggle source
# File lib/leg/config.rb, line 9 def load! @options = YAML.load_file(File.join(@path, "leg.yml")) @options = {} unless @options.is_a? Hash @options = symbolize_keys(@options) end
synced!()
click to toggle source
# File lib/leg/config.rb, line 19 def synced! FileUtils.touch(last_synced_path) end
Private Instance Methods
last_synced_path()
click to toggle source
# File lib/leg/config.rb, line 25 def last_synced_path File.join(@path, ".leg/last_synced") end
symbolize_keys(value)
click to toggle source
# File lib/leg/config.rb, line 29 def symbolize_keys(value) case value when Hash value.map do |k, v| [k.to_sym, symbolize_keys(v)] end.to_h when Array value.map { |v| symbolize_keys(v) } else value end end