Class: Daikon::Configuration
- Inherits:
-
Object
- Object
- Daikon::Configuration
- Defined in:
- lib/daikon/configuration.rb
Constant Summary collapse
- FLAGS =
%w[-h -p -k -f -s]
- OPTIONS =
%w[redis_host redis_port api_key field_id server_prefix]
- DEFAULTS =
%w[127.0.0.1 6379 1234567890 1 https://ssl.radishapp.com]
Instance Method Summary collapse
-
#initialize(argv = []) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(argv = []) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/daikon/configuration.rb', line 9 def initialize(argv = []) FLAGS.each_with_index do |flag, flag_index| argv_index = argv.index(flag) value = if argv_index argv[argv_index + 1] else DEFAULTS[flag_index] end send "#{OPTIONS[flag_index]}=", value end if api_key == DEFAULTS[2] && argv.any? { |arg| arg =~ /start|run/ } abort "Must supply an api key to start the daemon.\nExample: daikon start #{FLAGS[2]} #{DEFAULTS[2]}" end end |