Class: Rearview::Configuration

Inherits:
Struct
  • Object
show all
Defined in:
lib/rearview/configuration.rb

Constant Summary collapse

DEFAULTS =
{
  default_from: "rearview@localhost",
  graphite_url: nil,
  pagerduty_url: "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
  sandbox_timeout: 5,
  enable_alerts: true,
  preload_jobs: true,
  verify: false,
  enable_monitor: true
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



18
19
20
21
# File 'lib/rearview/configuration.rb', line 18

def initialize
  super
  set_defaults
end

Instance Attribute Details

#default_fromObject

Returns the value of attribute default_from

Returns:

  • (Object)

    the current value of default_from



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def default_from
  @default_from
end

#enable_alertsObject

Returns the value of attribute enable_alerts

Returns:

  • (Object)

    the current value of enable_alerts



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def enable_alerts
  @enable_alerts
end

#enable_monitorObject

Returns the value of attribute enable_monitor

Returns:

  • (Object)

    the current value of enable_monitor



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def enable_monitor
  @enable_monitor
end

#graphite_urlObject

Returns the value of attribute graphite_url

Returns:

  • (Object)

    the current value of graphite_url



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def graphite_url
  @graphite_url
end

#loggerObject

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def logger
  @logger
end

#pagerduty_urlObject

Returns the value of attribute pagerduty_url

Returns:

  • (Object)

    the current value of pagerduty_url



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def pagerduty_url
  @pagerduty_url
end

#preload_jobsObject

Returns the value of attribute preload_jobs

Returns:

  • (Object)

    the current value of preload_jobs



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def preload_jobs
  @preload_jobs
end

#sandbox_dirObject

Returns the value of attribute sandbox_dir

Returns:

  • (Object)

    the current value of sandbox_dir



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def sandbox_dir
  @sandbox_dir
end

#sandbox_execObject

Returns the value of attribute sandbox_exec

Returns:

  • (Object)

    the current value of sandbox_exec



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def sandbox_exec
  @sandbox_exec
end

#sandbox_timeoutObject

Returns the value of attribute sandbox_timeout

Returns:

  • (Object)

    the current value of sandbox_timeout



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def sandbox_timeout
  @sandbox_timeout
end

#verifyObject

Returns the value of attribute verify

Returns:

  • (Object)

    the current value of verify



4
5
6
# File 'lib/rearview/configuration.rb', line 4

def verify
  @verify
end

Instance Method Details

#alerts_enabled?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rearview/configuration.rb', line 23

def alerts_enabled?
  enable_alerts
end

#monitor_enabled?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rearview/configuration.rb', line 27

def monitor_enabled?
  enable_monitor
end

#preload_jobs?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rearview/configuration.rb', line 31

def preload_jobs?
  preload_jobs
end

#set_defaultsObject



48
49
50
# File 'lib/rearview/configuration.rb', line 48

def set_defaults
  members.each { |member| send("#{member}=", DEFAULTS[member.to_sym]) }
end

#to_sObject



52
53
54
55
56
# File 'lib/rearview/configuration.rb', line 52

def to_s
  @elems = []
  members.each { |m| @elems << "Rearview::Configuration #{m} : #{self[m]}" }
  @elems.join("\n")
end

#verify?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rearview/configuration.rb', line 35

def verify?
  verify
end

#with_argv(argv) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/rearview/configuration.rb', line 39

def with_argv(argv)
  OptionParser.new do |opts|
    opts.on("--[no-]preload", "Enable/disable job loading")  { |v| self.preload_jobs = v }
    opts.on("--[no-]alerts", "Enable/disable alerts")  { |v| self.enable_alerts = v }
    opts.on("--[no-]monitor", "Enable/disable monitor")  { |v| self.enable_monitor = v }
    opts.on("--[no-]verify", "Enable/disable verification")  { |v| self.verify = v }
  end.parse!(argv)
end