class Flow::Flowfile

Constants

NAMES

find flowfile path by convention check for name by convention in this order:

Attributes

steps[R]

Public Class Methods

find_file() click to toggle source
# File lib/flow-lite.rb, line 54
def self.find_file
  NAMES.each do |name|
    return "./#{name}"   if File.exist?( "./#{name}" )
  end
  nil
end
load( code ) click to toggle source

another convenience method - use like Flowfile.load()

# File lib/flow-lite.rb, line 69
def self.load( code )
  flowfile = new
  flowfile.instance_eval( code )
  flowfile
end
load_file( path ) click to toggle source

convenience method - use like Flowfile.load_file()

# File lib/flow-lite.rb, line 63
def self.load_file( path )
  code = File.open( path, 'r:utf-8' ) { |f| f.read }
  load( code )
end
new( opts={} ) click to toggle source
# File lib/flow-lite.rb, line 99
def initialize( opts={} )
  @opts  = opts
  @steps = []
end

Public Instance Methods

build_flow_class() click to toggle source
# File lib/flow-lite.rb, line 86
def build_flow_class
  puts "[flow]  building flow class..."
  klass = Class.new( Base )

  steps.each do |step|
    klass.define_step( step.names, &step.block )
  end

  klass
end
flow() click to toggle source
# File lib/flow-lite.rb, line 77
def flow
  ## todo/check: always return a new instance why? why not?
  flow_class.new
end
flow_class() click to toggle source
# File lib/flow-lite.rb, line 82
def flow_class
  @flow_class ||= build_flow_class
end
run( name ) click to toggle source
# File lib/flow-lite.rb, line 111
def run( name )
  ## todo/check: always return/use a new instance why? why not?
  flow_class.new.step( name )
end
step( name, &block ) click to toggle source

“classic / basic” primitives - step

# File lib/flow-lite.rb, line 107
def step( name, &block )
  @steps << Step.new( name, block )
end