Class: Flow::Flowfile
- Inherits:
-
Object
- Object
- Flow::Flowfile
- Defined in:
- lib/flow-lite.rb
Constant Summary collapse
- NAMES =
find flowfile path by convention check for name by convention in this order:
['flowfile', 'Flowfile', 'flowfile.rb', 'Flowfile.rb']
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Class Method Summary collapse
- .find_file ⇒ Object
-
.load(code) ⇒ Object
another convenience method - use like Flowfile.load().
-
.load_file(path) ⇒ Object
convenience method - use like Flowfile.load_file().
Instance Method Summary collapse
- #build_flow_class ⇒ Object
- #flow ⇒ Object
- #flow_class ⇒ Object
-
#initialize(opts = {}) ⇒ Flowfile
constructor
A new instance of Flowfile.
- #run(name) ⇒ Object
-
#step(name, &block) ⇒ Object
“classic / basic” primitives - step.
Constructor Details
#initialize(opts = {}) ⇒ Flowfile
Returns a new instance of Flowfile.
99 100 101 102 |
# File 'lib/flow-lite.rb', line 99 def initialize( opts={} ) @opts = opts @steps = [] end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
104 105 106 |
# File 'lib/flow-lite.rb', line 104 def steps @steps end |
Class Method Details
.find_file ⇒ Object
54 55 56 57 58 59 |
# 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) ⇒ Object
another convenience method - use like Flowfile.load()
69 70 71 72 73 |
# File 'lib/flow-lite.rb', line 69 def self.load( code ) flowfile = new flowfile.instance_eval( code ) flowfile end |
.load_file(path) ⇒ Object
convenience method - use like Flowfile.load_file()
63 64 65 66 |
# 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 |
Instance Method Details
#build_flow_class ⇒ Object
86 87 88 89 90 91 92 93 94 95 |
# 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 ⇒ Object
77 78 79 80 |
# 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 ⇒ Object
82 83 84 |
# File 'lib/flow-lite.rb', line 82 def flow_class @flow_class ||= build_flow_class end |
#run(name) ⇒ Object
111 112 113 114 |
# 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 |