Class: MiniAutobot::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_autobot/settings.rb

Overview

An object that holds runtime settings.

Furthermore, Minitest doesn’t provide any good way of passing a hash of options to each test.

TODO: We’re importing ActiveSupport’s extensions to Hash, which means that we’ll be amending the way Hash objects work; once AS updates themselves to ruby 2.0 refinements, let’s move towards that.

Instance Method Summary collapse

Constructor Details

#initializeSettings



13
14
15
# File 'lib/mini_autobot/settings.rb', line 13

def initialize
  @hsh = {}
end

Instance Method Details

#auto_finalize?Boolean



22
23
24
# File 'lib/mini_autobot/settings.rb', line 22

def auto_finalize?
  hsh.fetch(:auto_finalize, true)
end

#connectorObject



26
27
28
# File 'lib/mini_autobot/settings.rb', line 26

def connector
  hsh.fetch(:connector, :firefox).to_s
end

#envObject



30
31
32
33
34
# File 'lib/mini_autobot/settings.rb', line 30

def env
  # add a gitignored env file which stores a default env
  # pass the default env in as default
  hsh.fetch(:env, :rent_qa).to_s
end

#inspectObject



17
18
19
20
# File 'lib/mini_autobot/settings.rb', line 17

def inspect
  settings = self.class.public_instance_methods(false).sort.map(&:inspect).join(', ')
  "#<MiniAutobot::Settings #{settings}>"
end

#ioObject



36
37
38
# File 'lib/mini_autobot/settings.rb', line 36

def io
  hsh[:io]
end

#merge!(other) ⇒ Object



40
41
42
43
# File 'lib/mini_autobot/settings.rb', line 40

def merge!(other)
  hsh.merge!(other.symbolize_keys)
  self
end

#parallelObject

can be used as a flag no matter parallel option is used in command line or not can also be used to fetch the value if a valid value is specified



47
48
49
50
51
52
53
# File 'lib/mini_autobot/settings.rb', line 47

def parallel
  if hsh[:parallel] == 0
    return nil
  else
    hsh.fetch(:parallel).to_i
  end
end

#raw_argumentsObject



55
56
57
# File 'lib/mini_autobot/settings.rb', line 55

def raw_arguments
  hsh.fetch(:args, nil).to_s
end

#rerun_failureObject



63
64
65
# File 'lib/mini_autobot/settings.rb', line 63

def rerun_failure
  hsh.fetch(:rerun_failure)
end

#reuse_driver?Boolean



59
60
61
# File 'lib/mini_autobot/settings.rb', line 59

def reuse_driver?
  hsh.fetch(:reuse_driver, false)
end

#seedObject



67
68
69
# File 'lib/mini_autobot/settings.rb', line 67

def seed
  hsh.fetch(:seed, nil).to_i
end

#tagsObject



71
72
73
# File 'lib/mini_autobot/settings.rb', line 71

def tags
  hsh[:tags] ||= []
end

#verbose?Boolean



75
76
77
# File 'lib/mini_autobot/settings.rb', line 75

def verbose?
  verbosity_level > 0
end

#verbosity_levelObject



79
80
81
# File 'lib/mini_autobot/settings.rb', line 79

def verbosity_level
  hsh.fetch(:verbosity_level, 0).to_i
end