Class: MiniAutobot::Settings
- Inherits:
-
Object
- Object
- MiniAutobot::Settings
- 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
- #auto_finalize? ⇒ Boolean
- #connector ⇒ Object
- #env ⇒ Object
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
- #inspect ⇒ Object
- #io ⇒ Object
- #merge!(other) ⇒ Object
-
#parallel ⇒ Object
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.
- #raw_arguments ⇒ Object
- #rerun_failure ⇒ Object
- #reuse_driver? ⇒ Boolean
- #seed ⇒ Object
- #tags ⇒ Object
- #verbose? ⇒ Boolean
- #verbosity_level ⇒ Object
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
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 |
#connector ⇒ Object
26 27 28 |
# File 'lib/mini_autobot/settings.rb', line 26 def connector hsh.fetch(:connector, :firefox).to_s end |
#env ⇒ Object
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 |
#inspect ⇒ Object
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 |
#io ⇒ Object
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 |
#parallel ⇒ Object
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_arguments ⇒ Object
55 56 57 |
# File 'lib/mini_autobot/settings.rb', line 55 def raw_arguments hsh.fetch(:args, nil).to_s end |
#rerun_failure ⇒ Object
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 |
#seed ⇒ Object
67 68 69 |
# File 'lib/mini_autobot/settings.rb', line 67 def seed hsh.fetch(:seed, nil).to_i end |
#tags ⇒ Object
71 72 73 |
# File 'lib/mini_autobot/settings.rb', line 71 def hsh[:tags] ||= [] end |
#verbose? ⇒ Boolean
75 76 77 |
# File 'lib/mini_autobot/settings.rb', line 75 def verbose? verbosity_level > 0 end |
#verbosity_level ⇒ Object
79 80 81 |
# File 'lib/mini_autobot/settings.rb', line 79 def verbosity_level hsh.fetch(:verbosity_level, 0).to_i end |