Hello,
I have bundled up in the flow-lite gem [1] - a lite (lightweight)
workflow engine that let's you define your workflow steps in Flowfiles (in ruby)
and includes the flow command line tool.
The original itch / need / inspiration was / is the use in GitHub
Actions (Workflows).
Happy automating with ruby. Cheers. Prost.
[1] https://github.com/rubycoco/git/tree/master/flow-lite
PS: From the readme - Usage:
Define the workflow steps in a Flowfile. Example:
step :first_step do
puts "first_step"
second_step # note: you can call other steps like methods
end
step :second_step do
puts "second_step"
third_step
end
step :third_step do
puts "third_step"
end
And then use the `flow` command line tool to run a step. Example:
$ flow first_step
Note: By default the `flow` command line tool reads in the `Flowfile`.
Use `-f/--flowfile` option to use a different file.
Some Backstage Internals / Inside Flowfiles
If you read in a `Flowfile` the flow machinery
builds a new (regular) class derived from `Flow::Base`
and every step becomes a (regular) method. Example:
require 'flow-lite'
flowfile = Flow::Flowfile.load( <<TXT )
step :hello do
puts "Hello, world!"
end
step :hola do
puts "¡Hola, mundo!"
end
TXT
flow = flowfile.flow # (auto-)builds a flow class (see Note 1)
# and constructs/returns an instance
flow.hello #=> "Hello, world!"
flow.hola #=> "¡Hola, mundo!"
# or use ruby's (regular) message/metaprogramming machinery
flow.send( :hello ) #=> "Hello, world!"
flow.send( :hola ) #=> "¡Hola, mundo!"
# or try
flow.class.instance_methods.grep( /^step_/ ) #=> [:step_hello, :step_hola]
# ...
Note 1: The Flowfile "source / configuration":
step :hello do
puts "Hello, world!"
end
step :hola do
puts "¡Hola, mundo!"
end
gets used to (auto-) build (via metaprogramming) a flow class like:
class Greeter < Flow::Base
def hello
puts "Hello, world!"
end
alias_method :step_hello, :hello
def hola
puts "¡Hola, mundo!"
end
alias_method :step_hola, :hola
end