Sha256: 9cad43827b7288af917c44d034e8c2e959036ceb46cf5fd05dc3475eacc04db5
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
require 'erb' module Pushpop class Step TEMPLATES_DIRECTORY = File.expand_path('templates', Dir.pwd) class ERBContext attr_accessor :response attr_accessor :step_responses def initialize(response, step_responses) self.response = response self.step_responses = step_responses end def get_binding binding end end attr_accessor :name attr_accessor :plugin attr_accessor :block def initialize(name=nil, plugin=nil, &block) self.name = name || plugin || Pushpop.random_name self.plugin = plugin self.block = block end def template(filename, response, step_responses={}, directory=TEMPLATES_DIRECTORY) erb_context = ERBContext.new(response, step_responses) ERB.new(get_template_contents(filename, directory)).result(erb_context.get_binding) end def run(last_response=nil, step_responses=nil) self.instance_exec(last_response, step_responses, &block) end private def get_template_contents(filename, directory) File.read(File.join(directory, filename)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pushpop-0.4.0 | lib/pushpop/step.rb |
pushpop-0.3.3 | lib/pushpop/step.rb |
pushpop-0.3.2 | lib/pushpop/step.rb |
pushpop-0.3.1 | lib/pushpop/step.rb |