class Piggly::Config

Attributes

accumulate[RW]
accumulate?[RW]
cache_root[RW]
connection_name[RW]
database_yml[RW]
dry_run[RW]
dry_run?[RW]
filters[RW]
report_root[RW]
trace_prefix[RW]

Public Class Methods

mkpath(root, file=nil) click to toggle source
# File lib/piggly/config.rb, line 16
def mkpath(root, file=nil)
  if file.nil?
    FileUtils.makedirs(root)
    root
  else
    path = path(root, file)
    FileUtils.makedirs(File.dirname(path))
    path
  end
end
new() click to toggle source
# File lib/piggly/config.rb, line 69
def initialize
  @cache_root       = File.expand_path("#{Dir.pwd}/piggly/cache")
  @report_root      = File.expand_path("#{Dir.pwd}/piggly/reports")
  @database_yml     = nil
  @connection_name  = "piggly"
  @trace_prefix     = "PIGGLY"
  @accumulate       = false
  @dry_run          = false
  @filters          = []
end
path(root, file=nil) click to toggle source
# File lib/piggly/config.rb, line 6
def path(root, file=nil)
  if file.nil?
    root
  else
    file[%r{^\.\.|^\/|^(?:[A-Z]:)?/}i] ?
      file : # ../path, /path, or D:\path that isn't relative to root
      File.join(root, file)
  end
end

Private Class Methods

config_accessor(hash) click to toggle source
# File lib/piggly/config.rb, line 29
def config_accessor(hash)
  hash = hash.clone
  hash.keys.each do |name|
    define_method(name) do
      instance_variable_get("@#{name}") || hash[name]
    end

    define_method("#{name}?") do
      instance_variable_get("@#{name}") || hash[name]
    end

    define_method("#{name}=") do |value|
      instance_variable_set("@#{name}", value)
    end
  end
end

Public Instance Methods

mkpath(*args) click to toggle source
# File lib/piggly/config.rb, line 65
def mkpath(*args)
  self.class.mkpath(*args)
end
path(*args) click to toggle source
# File lib/piggly/config.rb, line 61
def path(*args)
  self.class.path(*args)
end