Class: Piggly::Config

Inherits:
Object show all
Defined in:
lib/piggly/config.rb,
lib/piggly/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



69
70
71
72
73
74
75
76
77
78
# 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

Instance Attribute Details

#accumulateObject Also known as: accumulate?

Returns the value of attribute accumulate.



48
49
50
# File 'lib/piggly/config.rb', line 48

def accumulate
  @accumulate
end

#cache_rootObject

Returns the value of attribute cache_root.



48
49
50
# File 'lib/piggly/config.rb', line 48

def cache_root
  @cache_root
end

#connection_nameObject

Returns the value of attribute connection_name.



48
49
50
# File 'lib/piggly/config.rb', line 48

def connection_name
  @connection_name
end

#database_ymlObject

Returns the value of attribute database_yml.



48
49
50
# File 'lib/piggly/config.rb', line 48

def database_yml
  @database_yml
end

#dry_runObject Also known as: dry_run?

Returns the value of attribute dry_run.



48
49
50
# File 'lib/piggly/config.rb', line 48

def dry_run
  @dry_run
end

#filtersObject

Returns the value of attribute filters.



48
49
50
# File 'lib/piggly/config.rb', line 48

def filters
  @filters
end

#report_rootObject

Returns the value of attribute report_root.



48
49
50
# File 'lib/piggly/config.rb', line 48

def report_root
  @report_root
end

#trace_prefixObject

Returns the value of attribute trace_prefix.



48
49
50
# File 'lib/piggly/config.rb', line 48

def trace_prefix
  @trace_prefix
end

Class Method Details

.mkpath(root, file = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# 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

.path(root, file = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
# 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

Instance Method Details

#mkpath(*args) ⇒ Object



65
66
67
# File 'lib/piggly/config.rb', line 65

def mkpath(*args)
  self.class.mkpath(*args)
end

#path(*args) ⇒ Object



61
62
63
# File 'lib/piggly/config.rb', line 61

def path(*args)
  self.class.path(*args)
end