Class: ChainReactor::Conf
- Inherits:
-
Object
- Object
- ChainReactor::Conf
- 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
-
#address ⇒ Object
Get the IP address to bind to.
-
#address=(address) ⇒ Object
Set the default bind IP address.
-
#chainfile ⇒ Object
Get the chainfile, as a File object.
-
#initialize(cli_params) ⇒ Conf
constructor
Create a new Conf object with the parameters from Main.
-
#log_file ⇒ Object
Get the log file location.
-
#log_file=(log_file) ⇒ Object
Set the log file location.
-
#multithreaded ⇒ Object
(also: #multithreaded?)
Whether the server should open each client connection in a new thread.
-
#multithreaded=(multithreaded) ⇒ Object
Set the whether to run multithreaded by default.
-
#on_top ⇒ Object
(also: #on_top?)
Whether to run on top (instead of daemonizing).
-
#on_top=(on_top) ⇒ Object
Set whether to run on top (instead of daemonizing).
-
#pid_file ⇒ Object
Get the pid file location.
-
#pid_file=(pid_file) ⇒ Object
Set the pid file location.
-
#port ⇒ Object
Get the port number.
-
#port=(port) ⇒ Object
Set the default port number.
-
#verbosity ⇒ Object
How verbose the program should be.
-
#verbosity=(verbosity) ⇒ Object
Set the default verbosity.
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
#address ⇒ Object
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 |
#chainfile ⇒ Object
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_file ⇒ Object
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 |
#multithreaded ⇒ Object 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_top ⇒ Object 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_file ⇒ Object
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 |
#port ⇒ Object
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 |
#verbosity ⇒ Object
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 |