Class: Brewby::StepLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/brewby/step_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ StepLoader

Returns a new instance of StepLoader.



3
4
5
# File 'lib/brewby/step_loader.rb', line 3

def initialize application
  @application = application
end

Instance Method Details

#generate_step(name, &block) ⇒ Object



21
22
23
24
25
# File 'lib/brewby/step_loader.rb', line 21

def generate_step name, &block
  step_generator = Brewby::Steps::DSL::Step.new name, @application
  step_generator.instance_eval &block
  step_generator.create!
end

#load_file(file) ⇒ Object



7
8
9
# File 'lib/brewby/step_loader.rb', line 7

def load_file file
  instance_eval File.read(file), file
end

#recipe(name) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
# File 'lib/brewby/step_loader.rb', line 11

def recipe name, &block
  @application.name = name
  yield self
end

#step(name, &block) ⇒ Object



16
17
18
19
# File 'lib/brewby/step_loader.rb', line 16

def step name, &block
  step = generate_step name, &block
  @application.steps.push step
end