class Popper::Config

Attributes

accounts[R]
default[R]
interval[R]

Public Class Methods

new(config_path) click to toggle source
# File lib/popper/config.rb, line 7
def initialize(config_path)
  raise "configure not fond #{config_path}" unless File.exist?(config_path)
  config = read_file(config_path)

  @interval = config.key?("interval") ? config["interval"].to_i : 60
  @default = config["default"] if config["default"]
  @accounts = config.select {|k,v| v.is_a?(Hash) && v.key?("login") }.map do |account|
    _account = AccountAttributes.new(account[1])
    _account.name = account[0]
    _account
  end
end

Public Instance Methods

read_file(file) click to toggle source
# File lib/popper/config.rb, line 20
def read_file(file)
  config = TOML.load_file(file)
  if config.key?("include")
    content = config["include"].map {|p| Dir.glob(p).map {|f|File.read(f)}}.join("\n")
    config.deep_merge!(TOML::Parser.new(content).parsed)
  end
  config
end