module FakeFlorence::Config

Constants

DEFAULT_CONFIG
SEVERITY

Attributes

log[RW]

Public Class Methods

home_dir() click to toggle source
# File lib/fake_florence/config.rb, line 34
def home_dir
  Pathname.new('~/.flo').expand_path.tap do |home|
    home.mkpath
  end
end
logfile() click to toggle source
# File lib/fake_florence/config.rb, line 52
def logfile
  home_dir.join('flo.log')
end
method_missing(m) click to toggle source
# File lib/fake_florence/config.rb, line 56
def method_missing(m)
  read_config(m)
end
pidfile() click to toggle source
# File lib/fake_florence/config.rb, line 48
def pidfile
  home_dir.join('flo.pid')
end
store_file() click to toggle source
# File lib/fake_florence/config.rb, line 30
def store_file
  home_dir.join('config.yaml')
end
url_for(feature) click to toggle source
# File lib/fake_florence/config.rb, line 20
def url_for(feature)
  URI.join(
    read_config(:base_url),
    File.join(
      mount_path,
      feature.id
    )
  )
end

Private Class Methods

read_config(key) click to toggle source
# File lib/fake_florence/config.rb, line 62
def read_config(key)
  @config_data ||= begin
    if store_file.exist?
      YAML.load_file(store_file)
    else
      YAML.load_file(DEFAULT_CONFIG).tap do |data|
        File.open(store_file, 'w') do |f|
          YAML.dump(data, f)
        end
      end
    end
  end
  @config_data[key.to_s]
end