Class: Drydock::RuntimeOptions
- Inherits:
-
Object
- Object
- Drydock::RuntimeOptions
- Defined in:
- lib/drydock/runtime_options.rb
Instance Attribute Summary collapse
-
#build_opts ⇒ Object
Returns the value of attribute build_opts.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#includes ⇒ Object
Returns the value of attribute includes.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ RuntimeOptions
constructor
A new instance of RuntimeOptions.
- #set! ⇒ Object
Constructor Details
#initialize ⇒ RuntimeOptions
Returns a new instance of RuntimeOptions.
64 65 66 67 68 69 70 71 72 |
# File 'lib/drydock/runtime_options.rb', line 64 def initialize @build_opts = {} @cache = true @includes = [] @log_level = Logger::INFO @read_timeout = Excon.defaults[:read_timeout] @read_timeout = 120 if @read_timeout < 120 end |
Instance Attribute Details
#build_opts ⇒ Object
Returns the value of attribute build_opts.
7 8 9 |
# File 'lib/drydock/runtime_options.rb', line 7 def build_opts @build_opts end |
#cache ⇒ Object
Returns the value of attribute cache.
7 8 9 |
# File 'lib/drydock/runtime_options.rb', line 7 def cache @cache end |
#includes ⇒ Object
Returns the value of attribute includes.
7 8 9 |
# File 'lib/drydock/runtime_options.rb', line 7 def includes @includes end |
#log_level ⇒ Object
Returns the value of attribute log_level.
7 8 9 |
# File 'lib/drydock/runtime_options.rb', line 7 def log_level @log_level end |
#read_timeout ⇒ Object
Returns the value of attribute read_timeout.
7 8 9 |
# File 'lib/drydock/runtime_options.rb', line 7 def read_timeout @read_timeout end |
Class Method Details
.parse!(args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/drydock/runtime_options.rb', line 9 def self.parse!(args) opts = new parser = OptionParser.new do |cfg| cfg. = "Usage: #{$0} [options...] [drydock-filename]" cfg.separator '' cfg.separator 'Runtime / build options:' cfg.on('-b', '--build-opts KEY=VALUE', 'KEY=VALUE build-time options', 'can be specified multiple times') do |kv| key, value = kv.split('=', 2) opts.build_opts[key.to_s] = value opts.build_opts[key.to_sym] = value end cfg.on('-C', '--no-cache', 'Disable the build cache') do opts.cache = false end cfg.on('-i', '--include PATH', 'Load custom plugins from PATH') do |path| opts.includes << path end cfg.separator '' cfg.separator 'General options:' cfg.on('-h', '--help', 'Show this help message') do puts cfg exit end cfg.on('-q', '--quiet', 'Run silently, except for errors') do |value| opts.log_level = Logger::ERROR end cfg.on('-t SECONDS', '--timeout SECONDS', "Set transaction timeout to SECONDS (default = #{opts.read_timeout})") do |value| opts.read_timeout = value.to_i || 60 end cfg.on('-v', '--verbose', 'Run verbosely') do |value| opts.log_level = Logger::DEBUG end cfg.on('-V', '--version', 'Show version') do puts Drydock. exit end end parser.parse!(args) opts.set! opts end |
Instance Method Details
#set! ⇒ Object
74 75 76 |
# File 'lib/drydock/runtime_options.rb', line 74 def set! Excon.defaults[:read_timeout] = self.read_timeout end |