Class: ChainReactor::Conf

Inherits:
Object
  • Object
show all
Defined in:
lib/chain-reactor/conf.rb

Overview

Configuration object that combines default values and command line options.

The command line parameters are provided through the gem ‘main’, and these take precedent over options set through the chain file.

Instance Method Summary collapse

Constructor Details

#initialize(cli_params) ⇒ Conf

Create a new Conf object with the parameters from Main.



15
16
17
18
# File 'lib/chain-reactor/conf.rb', line 15

def initialize(cli_params)
  @params = cli_params
  @defaults = {}
end

Instance Method Details

#addressObject

Get the IP address to bind to.



33
34
35
# File 'lib/chain-reactor/conf.rb', line 33

def address
  get_value :address
end

#address=(address) ⇒ Object

Set the default bind IP address.



28
29
30
# File 'lib/chain-reactor/conf.rb', line 28

def address=(address)
  set_default :address, address
end

#chainfileObject

Get the chainfile, as a File object.

This is the exception - it has to come as a CLI parameter.



23
24
25
# File 'lib/chain-reactor/conf.rb', line 23

def chainfile
  @params[:chainfile].value
end

#log_fileObject

Get the log file location.



43
44
45
# File 'lib/chain-reactor/conf.rb', line 43

def log_file
  get_value :logfile
end

#log_file=(log_file) ⇒ Object

Set the log file location.



38
39
40
# File 'lib/chain-reactor/conf.rb', line 38

def log_file=(log_file)
  set_default :logfile, log_file
end

#multithreadedObject Also known as: multithreaded?

Whether the server should open each client connection in a new thread.



73
74
75
# File 'lib/chain-reactor/conf.rb', line 73

def multithreaded
  get_value :multithreaded
end

#multithreaded=(multithreaded) ⇒ Object

Set the whether to run multithreaded by default.



68
69
70
# File 'lib/chain-reactor/conf.rb', line 68

def multithreaded=(multithreaded)
  set_default :multithreaded, multithreaded
end

#on_topObject Also known as: on_top?

Whether to run on top (instead of daemonizing).



93
94
95
# File 'lib/chain-reactor/conf.rb', line 93

def on_top
  get_value :ontop
end

#on_top=(on_top) ⇒ Object

Set whether to run on top (instead of daemonizing).



88
89
90
# File 'lib/chain-reactor/conf.rb', line 88

def on_top=(on_top)
  set_default :ontop, on_top
end

#pid_fileObject

Get the pid file location.



53
54
55
# File 'lib/chain-reactor/conf.rb', line 53

def pid_file
  get_value :pidfile
end

#pid_file=(pid_file) ⇒ Object

Set the pid file location.



48
49
50
# File 'lib/chain-reactor/conf.rb', line 48

def pid_file=(pid_file)
  set_default :pidfile, pid_file
end

#portObject

Get the port number.



63
64
65
# File 'lib/chain-reactor/conf.rb', line 63

def port
  get_value :port
end

#port=(port) ⇒ Object

Set the default port number.



58
59
60
# File 'lib/chain-reactor/conf.rb', line 58

def port=(port)
  set_default :port, port
end

#verbosityObject

How verbose the program should be.



83
84
85
# File 'lib/chain-reactor/conf.rb', line 83

def verbosity
  get_value :verbosity
end

#verbosity=(verbosity) ⇒ Object

Set the default verbosity.



78
79
80
# File 'lib/chain-reactor/conf.rb', line 78

def verbosity=(verbosity)
  set_default :verbosity, verbosity
end