Class: Dogfood::Pack

Inherits:
Object
  • Object
show all
Defined in:
lib/dogfood/pack.rb

Constant Summary collapse

UnknownScenario =
Class.new(StandardError)

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) {|_self| ... } ⇒ Pack

Returns a new instance of Pack.

Yields:

  • (_self)

Yield Parameters:

  • _self (Dogfood::Pack)

    the object that the method was called on



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

.currentObject

Returns the value of attribute current.



8
9
10
# File 'lib/dogfood/pack.rb', line 8

def current
  @current
end

Instance Attribute Details

#delay_distributionsObject (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_modulesObject (readonly)

Returns the value of attribute mixin_modules.



11
12
13
# File 'lib/dogfood/pack.rb', line 11

def mixin_modules
  @mixin_modules
end

#nameObject (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

#scenariosObject (readonly)

Returns the value of attribute scenarios.



11
12
13
# File 'lib/dogfood/pack.rb', line 11

def scenarios
  @scenarios
end

#step_modulesObject (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_keysObject



43
44
45
# File 'lib/dogfood/pack.rb', line 43

def scenario_keys
  @scenarios.keys
end