Class: Dogfood::Pack
- Inherits:
-
Object
- Object
- Dogfood::Pack
- Defined in:
- lib/dogfood/pack.rb
Constant Summary collapse
- UnknownScenario =
Class.new(StandardError)
Class Attribute Summary collapse
-
.current ⇒ Object
Returns the value of attribute current.
Instance Attribute Summary collapse
-
#delay_distributions ⇒ Object
readonly
Returns the value of attribute delay_distributions.
-
#mixin_modules ⇒ Object
readonly
Returns the value of attribute mixin_modules.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pools(*mods) ⇒ Object
readonly
Returns the value of attribute pools.
-
#scenarios ⇒ Object
readonly
Returns the value of attribute scenarios.
-
#step_modules ⇒ Object
readonly
Returns the value of attribute step_modules.
Instance Method Summary collapse
- #delays(hash) ⇒ Object
- #find_scenario(name) ⇒ Object
- #include_mixins(*mods) ⇒ Object
- #include_steps(*mods) ⇒ Object
-
#initialize(name) {|_self| ... } ⇒ Pack
constructor
A new instance of Pack.
- #load_dir(glob) ⇒ Object
- #load_file(path) ⇒ Object
- #register(name, klass) ⇒ Object
- #scenario_keys ⇒ Object
Constructor Details
#initialize(name) {|_self| ... } ⇒ Pack
Returns a new instance of Pack.
13 14 15 16 17 18 19 20 21 |
# File 'lib/dogfood/pack.rb', line 13 def initialize(name) @name = name @step_modules = [] @mixin_modules = [] @pools = {} @delay_distributions = {} @scenarios = {} yield self if block_given? end |
Class Attribute Details
.current ⇒ Object
Returns the value of attribute current.
8 9 10 |
# File 'lib/dogfood/pack.rb', line 8 def current @current end |
Instance Attribute Details
#delay_distributions ⇒ Object (readonly)
Returns the value of attribute delay_distributions.
11 12 13 |
# File 'lib/dogfood/pack.rb', line 11 def delay_distributions @delay_distributions end |
#mixin_modules ⇒ Object (readonly)
Returns the value of attribute mixin_modules.
11 12 13 |
# File 'lib/dogfood/pack.rb', line 11 def mixin_modules @mixin_modules end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/dogfood/pack.rb', line 11 def name @name end |
#pools(*mods) ⇒ Object (readonly)
Returns the value of attribute pools.
11 12 13 |
# File 'lib/dogfood/pack.rb', line 11 def pools @pools end |
#scenarios ⇒ Object (readonly)
Returns the value of attribute scenarios.
11 12 13 |
# File 'lib/dogfood/pack.rb', line 11 def scenarios @scenarios end |
#step_modules ⇒ Object (readonly)
Returns the value of attribute step_modules.
11 12 13 |
# File 'lib/dogfood/pack.rb', line 11 def step_modules @step_modules end |
Instance Method Details
#delays(hash) ⇒ Object
35 36 37 |
# File 'lib/dogfood/pack.rb', line 35 def delays(hash) @delay_distributions.merge!(hash) end |
#find_scenario(name) ⇒ Object
47 48 49 |
# File 'lib/dogfood/pack.rb', line 47 def find_scenario(name) @scenarios[name.to_sym] or raise UnknownScenario, "Unknown scenario: #{name}" end |
#include_mixins(*mods) ⇒ Object
27 28 29 |
# File 'lib/dogfood/pack.rb', line 27 def include_mixins(*mods) @mixin_modules.concat(mods) end |
#include_steps(*mods) ⇒ Object
23 24 25 |
# File 'lib/dogfood/pack.rb', line 23 def include_steps(*mods) @step_modules.concat(mods) end |
#load_dir(glob) ⇒ Object
51 52 53 |
# File 'lib/dogfood/pack.rb', line 51 def load_dir(glob) Dir[glob].each { |path| load_file(path) } end |
#load_file(path) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/dogfood/pack.rb', line 55 def load_file(path) require "yaml" yaml = YAML.load_file(path) require_relative "dsl/schema" require_relative "dsl/compiler" Dogfood::DSL::Schema.validate!(yaml) klass = Dogfood::DSL::Compiler.compile(yaml, pack: self) register(yaml["name"].to_sym, klass) end |
#register(name, klass) ⇒ Object
39 40 41 |
# File 'lib/dogfood/pack.rb', line 39 def register(name, klass) @scenarios[name.to_sym] = klass end |
#scenario_keys ⇒ Object
43 44 45 |
# File 'lib/dogfood/pack.rb', line 43 def scenario_keys @scenarios.keys end |