Class: Specbandit::Configuration
- Inherits:
-
Object
- Object
- Specbandit::Configuration
- Defined in:
- lib/specbandit/configuration.rb
Constant Summary collapse
- DEFAULT_REDIS_URL =
'redis://localhost:6379'- DEFAULT_BATCH_SIZE =
5- DEFAULT_KEY_TTL =
6 hours in seconds
21_600- DEFAULT_KEY_RERUN_TTL =
1 week in seconds
604_800- DEFAULT_ADAPTER =
'cli'
Instance Attribute Summary collapse
-
#adapter ⇒ Object
Returns the value of attribute adapter.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#command ⇒ Object
Returns the value of attribute command.
-
#command_opts ⇒ Object
Returns the value of attribute command_opts.
-
#key ⇒ Object
Returns the value of attribute key.
-
#key_rerun ⇒ Object
Returns the value of attribute key_rerun.
-
#key_rerun_ttl ⇒ Object
Returns the value of attribute key_rerun_ttl.
-
#key_ttl ⇒ Object
Returns the value of attribute key_ttl.
-
#redis_url ⇒ Object
Returns the value of attribute redis_url.
-
#rerun ⇒ Object
Returns the value of attribute rerun.
-
#rspec_opts ⇒ Object
Returns the value of attribute rspec_opts.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/specbandit/configuration.rb', line 15 def initialize @redis_url = ENV.fetch('SPECBANDIT_REDIS_URL', DEFAULT_REDIS_URL) @batch_size = Integer(ENV.fetch('SPECBANDIT_BATCH_SIZE', DEFAULT_BATCH_SIZE)) @key = ENV.fetch('SPECBANDIT_KEY', nil) @rspec_opts = parse_rspec_opts(ENV.fetch('SPECBANDIT_RSPEC_OPTS', nil)) @key_ttl = Integer(ENV.fetch('SPECBANDIT_KEY_TTL', DEFAULT_KEY_TTL)) @key_rerun = ENV.fetch('SPECBANDIT_KEY_RERUN', nil) @key_rerun_ttl = Integer(ENV.fetch('SPECBANDIT_KEY_RERUN_TTL', DEFAULT_KEY_RERUN_TTL)) @rerun = env_truthy?('SPECBANDIT_RERUN') @verbose = env_truthy?('SPECBANDIT_VERBOSE') @adapter = ENV.fetch('SPECBANDIT_ADAPTER', DEFAULT_ADAPTER) @command = ENV.fetch('SPECBANDIT_COMMAND', nil) @command_opts = parse_space_separated(ENV.fetch('SPECBANDIT_COMMAND_OPTS', nil)) end |
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def adapter @adapter end |
#batch_size ⇒ Object
Returns the value of attribute batch_size.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def batch_size @batch_size end |
#command ⇒ Object
Returns the value of attribute command.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def command @command end |
#command_opts ⇒ Object
Returns the value of attribute command_opts.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def command_opts @command_opts end |
#key ⇒ Object
Returns the value of attribute key.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key @key end |
#key_rerun ⇒ Object
Returns the value of attribute key_rerun.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key_rerun @key_rerun end |
#key_rerun_ttl ⇒ Object
Returns the value of attribute key_rerun_ttl.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key_rerun_ttl @key_rerun_ttl end |
#key_ttl ⇒ Object
Returns the value of attribute key_ttl.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def key_ttl @key_ttl end |
#redis_url ⇒ Object
Returns the value of attribute redis_url.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def redis_url @redis_url end |
#rerun ⇒ Object
Returns the value of attribute rerun.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def rerun @rerun end |
#rspec_opts ⇒ Object
Returns the value of attribute rspec_opts.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def rspec_opts @rspec_opts end |
#verbose ⇒ Object
Returns the value of attribute verbose.
5 6 7 |
# File 'lib/specbandit/configuration.rb', line 5 def verbose @verbose end |
Instance Method Details
#validate! ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/specbandit/configuration.rb', line 30 def validate! raise Error, 'key is required (set via --key or SPECBANDIT_KEY)' if key.nil? || key.empty? raise Error, 'batch_size must be a positive integer' unless batch_size.positive? raise Error, 'key_ttl must be a positive integer' unless key_ttl.positive? raise Error, 'key_rerun_ttl must be a positive integer' unless key_rerun_ttl.positive? raise Error, '--rerun requires --key-rerun to be set' if rerun && (key_rerun.nil? || key_rerun.empty?) end |