flow-lite 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Manifest.txt +2 -0
- data/README.md +120 -20
- data/Rakefile +2 -6
- data/lib/flow-lite.rb +36 -60
- data/lib/flow-lite/base.rb +89 -0
- data/lib/flow-lite/tool.rb +130 -0
- data/lib/flow-lite/version.rb +1 -1
- metadata +5 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48d2755dfa5c6d365387d7a788804dd458d0fedf
|
4
|
+
data.tar.gz: '04586b4969ec5b3aa278ba933904c62ea753f765'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10c26e5b61781002e063f4695d676d8847e666950b25c6fe451a1d4e396b14c5b85f5892ecd2cbcc1ac35840f3823462edcb95e0ff221acf06021e30a0503db1
|
7
|
+
data.tar.gz: b7fdb1a505e1b9eb92dd219e8e86af7813b17874562f1f45ab0b9f18be8f4f3cf1c44a8d2571c56cb8b17912960ff58b82de1f1af379b92c3cb62a1452c456ce
|
data/Manifest.txt
CHANGED
data/README.md
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
flow-lite gem - (yet) another (lite) workflow engine; let's you define your workflow steps in Flowfiles; incl. the flow command line tool
|
4
4
|
|
5
5
|
|
6
|
-
* home :: [github.com/rubycoco/
|
7
|
-
* bugs :: [github.com/rubycoco/
|
6
|
+
* home :: [github.com/rubycoco/flow](https://github.com/rubycoco/flow)
|
7
|
+
* bugs :: [github.com/rubycoco/flow/issues](https://github.com/rubycoco/flow/issues)
|
8
8
|
* gem :: [rubygems.org/gems/flow-lite](https://rubygems.org/gems/flow-lite)
|
9
9
|
* rdoc :: [rubydoc.info/gems/flow-lite](http://rubydoc.info/gems/flow-lite)
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
+
|
13
14
|
## Usage
|
14
15
|
|
15
16
|
|
@@ -19,12 +20,12 @@ Define the workflow steps in a Flowfile. Example:
|
|
19
20
|
``` ruby
|
20
21
|
step :first_step do
|
21
22
|
puts "first_step"
|
22
|
-
second_step # note: you can call other steps
|
23
|
+
step :second_step # note: you can call other steps with step
|
23
24
|
end
|
24
25
|
|
25
26
|
step :second_step do
|
26
27
|
puts "second_step"
|
27
|
-
third_step
|
28
|
+
step :third_step
|
28
29
|
end
|
29
30
|
|
30
31
|
step :third_step do
|
@@ -32,14 +33,40 @@ step :third_step do
|
|
32
33
|
end
|
33
34
|
```
|
34
35
|
|
35
|
-
And
|
36
|
+
And then use the `flow` command line tool to run a step.
|
36
37
|
Example:
|
37
38
|
|
38
39
|
```
|
39
40
|
$ flow first_step
|
40
41
|
```
|
41
42
|
|
42
|
-
Note: By default the `flow` command line tool reads in
|
43
|
+
Note: By default the `flow` command line tool reads in and looks for `flowfile`, `Flowfile`, `flowfile.rb`, `Flowfile.rb`
|
44
|
+
in that order.
|
45
|
+
Use the `-f/--flowfile` option to use a different file.
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
**Prelude / Prolog**
|
50
|
+
|
51
|
+
Use the `-r/--require` option to (auto-)require
|
52
|
+
some extra libraries or scripts.
|
53
|
+
By default for now the "prelude / prolog" that always
|
54
|
+
gets auto-required includes:
|
55
|
+
|
56
|
+
``` ruby
|
57
|
+
require 'pp'
|
58
|
+
require 'time'
|
59
|
+
require 'date'
|
60
|
+
require 'json'
|
61
|
+
require 'yaml'
|
62
|
+
require 'fileutils'
|
63
|
+
|
64
|
+
require 'uri'
|
65
|
+
require 'net/http'
|
66
|
+
require 'net/https'
|
67
|
+
```
|
68
|
+
|
69
|
+
Tip: See the [`flow-lite.rb`](https://github.com/rubycoco/flow/blob/master/flow-lite/lib/flow-lite.rb) source for the definite always up-to-date list.
|
43
70
|
|
44
71
|
|
45
72
|
That's it for now.
|
@@ -66,14 +93,17 @@ flowfile = Flow::Flowfile.load( <<TXT )
|
|
66
93
|
end
|
67
94
|
TXT
|
68
95
|
|
69
|
-
flow = flowfile.
|
70
|
-
|
71
|
-
flow.
|
72
|
-
flow.
|
96
|
+
flow = flowfile.flow_class.new # (auto-)build a flow class (see Note 1)
|
97
|
+
# and construct/return a new instance
|
98
|
+
flow.step_hello #=> "Hello, world!"
|
99
|
+
flow.step_hola #=> "¡Hola, mundo!"
|
100
|
+
flow.step( :hello ) #=> "Hello, world!"
|
101
|
+
flow.step( :hola ) #=> "¡Hola, mundo!"
|
102
|
+
flow.class.step_methods #=> [:hello, :hola]
|
73
103
|
|
74
104
|
# or use ruby's (regular) message/metaprogramming machinery
|
75
|
-
flow.send( :
|
76
|
-
flow.send( :
|
105
|
+
flow.send( :step_hello ) #=> "Hello, world!"
|
106
|
+
flow.send( :step_hola ) #=> "¡Hola, mundo!"
|
77
107
|
# or try
|
78
108
|
flow.class.instance_methods.grep( /^step_/ ) #=> [:step_hello, :step_hola]
|
79
109
|
# ...
|
@@ -95,27 +125,48 @@ gets used to (auto-) build (via metaprogramming) a flow class like:
|
|
95
125
|
|
96
126
|
``` ruby
|
97
127
|
class Greeter < Flow::Base
|
98
|
-
def
|
128
|
+
def step_hello
|
129
|
+
puts "Hello, world!"
|
130
|
+
end
|
131
|
+
|
132
|
+
def step_hola
|
133
|
+
puts "¡Hola, mundo!"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
```
|
137
|
+
|
138
|
+
|
139
|
+
Note: Behind the stage the metaprogramming "class macro"
|
140
|
+
`define_step( symbol, method )`
|
141
|
+
or `define_step( symbol ) { block }` defined in `Flow::Base`
|
142
|
+
gets used, thus,
|
143
|
+
if you want to create steps in a "hand-coded" class
|
144
|
+
use:
|
145
|
+
|
146
|
+
|
147
|
+
``` ruby
|
148
|
+
class Greeter < Flow::Base
|
149
|
+
define_step :hello do
|
99
150
|
puts "Hello, world!"
|
100
151
|
end
|
101
|
-
alias_method :step_hello, :hello
|
102
152
|
|
103
|
-
|
153
|
+
define_step :hola do
|
104
154
|
puts "¡Hola, mundo!"
|
105
155
|
end
|
106
|
-
alias_method :step_hola, :hola
|
107
156
|
end
|
108
157
|
```
|
109
158
|
|
110
159
|
|
111
160
|
|
161
|
+
|
162
|
+
|
112
163
|
**Tips & Tricks**
|
113
164
|
|
114
165
|
Auto-include pre-build / pre-defined steps. Use a (regular) Module e.g.:
|
115
166
|
|
116
167
|
``` ruby
|
117
168
|
module GitHubActions
|
118
|
-
def
|
169
|
+
def step_setup
|
119
170
|
# setup ssh
|
120
171
|
ssh_key = ENV['SSH_KEY']
|
121
172
|
ssh_path = File.expand_path( '~/.ssh' )
|
@@ -133,8 +184,6 @@ module GitHubActions
|
|
133
184
|
|
134
185
|
# ...
|
135
186
|
end
|
136
|
-
# optional - for auto-discovery add a step alias
|
137
|
-
alias_method :step_setup, :setup
|
138
187
|
end
|
139
188
|
```
|
140
189
|
|
@@ -144,9 +193,60 @@ and than use (regular) include e.g.:
|
|
144
193
|
class Flow::Base
|
145
194
|
include GitHubActions
|
146
195
|
end
|
196
|
+
|
197
|
+
#-or-
|
198
|
+
|
199
|
+
Flow::Base.include( GitHubActions )
|
200
|
+
```
|
201
|
+
|
202
|
+
Now all your flows can (re)use `setup` or any other step methods you define.
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
## Real World Examples
|
208
|
+
|
209
|
+
**Collect GitHub Statistics**
|
210
|
+
|
211
|
+
Use GitHub Actions to collect
|
212
|
+
GitHub Statistics via GitHub API calls
|
213
|
+
and update the JSON datasets
|
214
|
+
in the `/cache.github` repo at the `yorobot` org(anization):
|
215
|
+
|
216
|
+
``` ruby
|
217
|
+
step :clone do
|
218
|
+
Mono.clone( '@yorobot/cache.github' )
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
step :update do
|
223
|
+
Hubba.config.data_dir = Mono.real_path( '@yorobot/cache.github' )
|
224
|
+
|
225
|
+
username = 'geraldb'
|
226
|
+
h = Hubba.reposet( username )
|
227
|
+
pp h
|
228
|
+
|
229
|
+
Hubba.update_stats( h )
|
230
|
+
Hubba.update_traffic( h )
|
231
|
+
puts "Done."
|
232
|
+
end
|
233
|
+
|
234
|
+
|
235
|
+
step :push do
|
236
|
+
msg = "auto-update week #{Date.today.cweek}"
|
237
|
+
|
238
|
+
Mono.open( '@yorobot/cache.github' ) do |proj|
|
239
|
+
if proj.changes?
|
240
|
+
proj.add( "." )
|
241
|
+
proj.commit( msg )
|
242
|
+
proj.push
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
147
246
|
```
|
148
247
|
|
149
|
-
|
248
|
+
(Sources: [`Flowfile`](https://github.com/yorobot/backup/blob/master/Flowfile.rb), [`workflows/update.yml`](https://github.com/yorobot/backup/blob/master/.github/workflows/update.yml) @ `yorobot/backup`)
|
249
|
+
|
150
250
|
|
151
251
|
|
152
252
|
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ Hoe.spec 'flow-lite' do
|
|
8
8
|
self.summary = "flow-lite gem - (yet) another (lite) workflow engine; let's you define your workflow steps in Flowfiles; incl. the flow command line tool"
|
9
9
|
self.description = summary
|
10
10
|
|
11
|
-
self.urls = { home: 'https://github.com/rubycoco/
|
11
|
+
self.urls = { home: 'https://github.com/rubycoco/flow' }
|
12
12
|
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'ruby-talk@ruby-lang.org'
|
@@ -17,11 +17,7 @@ Hoe.spec 'flow-lite' do
|
|
17
17
|
self.readme_file = 'README.md'
|
18
18
|
self.history_file = 'CHANGELOG.md'
|
19
19
|
|
20
|
-
self.extra_deps = [
|
21
|
-
['gitti', '>= 0.6.1' ],
|
22
|
-
['hubba', '>= 1.0.0' ],
|
23
|
-
['monos', '>= 0.5.0' ],
|
24
|
-
]
|
20
|
+
self.extra_deps = []
|
25
21
|
|
26
22
|
self.licenses = ['Public Domain']
|
27
23
|
|
data/lib/flow-lite.rb
CHANGED
@@ -1,21 +1,28 @@
|
|
1
|
+
##
|
2
|
+
## "prelude / prolog " add some common used stdlibs
|
3
|
+
## add more - why? why not?
|
1
4
|
require 'pp'
|
2
|
-
require '
|
5
|
+
require 'time'
|
6
|
+
require 'date'
|
7
|
+
require 'json'
|
8
|
+
require 'yaml'
|
9
|
+
require 'fileutils'
|
3
10
|
|
11
|
+
require 'uri'
|
12
|
+
require 'net/http'
|
13
|
+
require 'net/https'
|
4
14
|
|
5
15
|
|
6
|
-
|
7
|
-
# "prelude/prolog" add some 3rd party libs/gems
|
8
|
-
# -- our own
|
9
|
-
require 'gitti'
|
10
|
-
require 'hubba' ## todo/fix: rename to gitti-api/gitti-apis
|
11
|
-
require 'mono'
|
12
|
-
# -- some more ???
|
16
|
+
require 'optparse'
|
13
17
|
|
14
18
|
|
15
19
|
|
16
20
|
#####################
|
17
21
|
# our own code
|
18
22
|
require 'flow-lite/version' # note: let version always go first
|
23
|
+
require 'flow-lite/base'
|
24
|
+
require 'flow-lite/tool'
|
25
|
+
|
19
26
|
|
20
27
|
|
21
28
|
|
@@ -38,27 +45,22 @@ class Step
|
|
38
45
|
end # class Step
|
39
46
|
|
40
47
|
|
48
|
+
class Flowfile
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
alt_names = step.names[1..-1]
|
50
|
-
alt_names.each do |alt_name|
|
51
|
-
puts " adding alias >#{alt_name}< for >#{name}<..."
|
52
|
-
alias_method( alt_name, name )
|
50
|
+
## find flowfile path by convention
|
51
|
+
## check for name by convention in this order:
|
52
|
+
NAMES = ['flowfile', 'Flowfile',
|
53
|
+
'flowfile.rb', 'Flowfile.rb']
|
54
|
+
def self.find_file
|
55
|
+
NAMES.each do |name|
|
56
|
+
return "./#{name}" if File.exist?( "./#{name}" )
|
53
57
|
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
58
|
+
nil
|
59
|
+
end # method self.find_file
|
57
60
|
|
58
61
|
|
59
|
-
class Flowfile
|
60
62
|
## convenience method - use like Flowfile.load_file()
|
61
|
-
def self.load_file( path
|
63
|
+
def self.load_file( path )
|
62
64
|
code = File.open( path, 'r:utf-8' ) { |f| f.read }
|
63
65
|
load( code )
|
64
66
|
end
|
@@ -72,17 +74,21 @@ class Flowfile
|
|
72
74
|
|
73
75
|
|
74
76
|
|
75
|
-
def flow
|
77
|
+
def flow
|
78
|
+
## todo/check: always return a new instance why? why not?
|
79
|
+
flow_class.new
|
80
|
+
end
|
81
|
+
|
82
|
+
def flow_class
|
76
83
|
@flow_class ||= build_flow_class
|
77
|
-
@flow_class.new ## todo/check: always return a new instance why? why not?
|
78
84
|
end
|
79
85
|
|
80
86
|
def build_flow_class
|
81
|
-
puts " building flow class..."
|
87
|
+
puts "[flow] building flow class..."
|
82
88
|
klass = Class.new( Base )
|
83
89
|
|
84
90
|
steps.each do |step|
|
85
|
-
klass.define_step( step )
|
91
|
+
klass.define_step( step.names, &step.block )
|
86
92
|
end
|
87
93
|
|
88
94
|
klass
|
@@ -102,41 +108,11 @@ class Flowfile
|
|
102
108
|
@steps << Step.new( name, block )
|
103
109
|
end
|
104
110
|
|
105
|
-
|
106
111
|
def run( name )
|
107
|
-
|
108
|
-
|
109
|
-
flow.send( name )
|
110
|
-
else
|
111
|
-
puts "!! ERROR: step definition >#{name}< not found; cannot run/execute - known steps include:"
|
112
|
-
pp @steps
|
113
|
-
exit 1
|
114
|
-
end
|
112
|
+
## todo/check: always return/use a new instance why? why not?
|
113
|
+
flow_class.new.step( name )
|
115
114
|
end
|
116
115
|
end # class Flowfile
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
class Tool
|
121
|
-
def self.main( args=ARGV )
|
122
|
-
options = {}
|
123
|
-
OptionParser.new do |parser|
|
124
|
-
parser.on( '-f FILENAME', '--flowfile FILENAME' ) do |filename|
|
125
|
-
options[:flowfile] = filename
|
126
|
-
end
|
127
|
-
end.parse!( args )
|
128
|
-
|
129
|
-
path = options[:flowfile] || './Flowfile'
|
130
|
-
flowfile = Flowfile.load_file( path )
|
131
|
-
|
132
|
-
## allow multipe steps getting called - why? why not?
|
133
|
-
## flow setup clone update etc??
|
134
|
-
args.each do |arg|
|
135
|
-
flowfile.run( arg )
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end # class Tool
|
139
|
-
|
140
116
|
end # module Flow
|
141
117
|
|
142
118
|
|
@@ -0,0 +1,89 @@
|
|
1
|
+
|
2
|
+
module Flow
|
3
|
+
|
4
|
+
class Base ## base class for flow class (auto)-constructed/build from flowfile
|
5
|
+
def self.define_step( name_or_names, &block )
|
6
|
+
names = if name_or_names.is_a?( Array )
|
7
|
+
name_or_names
|
8
|
+
else
|
9
|
+
[name_or_names] ## assume single symbol (name); wrap in array
|
10
|
+
end
|
11
|
+
names = names.map {|name| name.to_sym } ## make sure we always use symbols
|
12
|
+
|
13
|
+
|
14
|
+
name = names[0]
|
15
|
+
puts "[flow] adding step >#{name}<..."
|
16
|
+
define_method( :"step_#{name}", &block )
|
17
|
+
|
18
|
+
alt_names = names[1..-1]
|
19
|
+
alt_names.each do |alt_name|
|
20
|
+
puts "[flow] adding alias >#{alt_name}< for >#{name}<..."
|
21
|
+
alias_method( :"step_#{alt_name}", :"step_#{name}" )
|
22
|
+
end
|
23
|
+
end # method self.define_step
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
TRUE_VALUES = [
|
29
|
+
'true', 't',
|
30
|
+
'yes', 'y',
|
31
|
+
'on',
|
32
|
+
'1',
|
33
|
+
]
|
34
|
+
|
35
|
+
### include / check for ruby debug flag too - why? why not?
|
36
|
+
def debug?
|
37
|
+
value = ENV['DEBUG']
|
38
|
+
if value && TRUE_VALUES.include?( value.downcase )
|
39
|
+
true
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
## run step by symbol/name (e.g. step :hello - etc.)
|
48
|
+
##
|
49
|
+
## todo/check: allow (re)entrant calls to step (step calling step etc.) - why? why not?
|
50
|
+
def step( name )
|
51
|
+
step_name = :"step_#{name}" ## note: make sure we always use symbols
|
52
|
+
if respond_to?( step_name )
|
53
|
+
#######
|
54
|
+
## check: track (and report) call stack - why? why not?
|
55
|
+
## e.g.
|
56
|
+
## [flow >(1) first_step)] step >first_step< - starting...
|
57
|
+
## [flow >(2) ..first_step > second_step)] step >second_step< - starting...
|
58
|
+
## [flow >(3) ....first_step > second_step > third_step)] step >third_step< - starting...
|
59
|
+
@stack ||= [] ## use a call stack of step names
|
60
|
+
@stack.push( name )
|
61
|
+
|
62
|
+
puts "[flow >(#{@stack.size}) #{'..'*(@stack.size-1)}#{@stack.join(' > ')})] step >#{name}< - starting..."
|
63
|
+
start_time = Time.now ## todo: use Timer? t = Timer.start / stop / diff etc. - why? why not?
|
64
|
+
|
65
|
+
__send__( step_name )
|
66
|
+
|
67
|
+
end_time = Time.now
|
68
|
+
diff_time = end_time - start_time
|
69
|
+
puts "[flow <(#{@stack.size}) #{'..'*(@stack.size-1)}#{@stack.join(' < ')})] step >#{name}< - done in #{diff_time} sec(s)"
|
70
|
+
@stack.pop
|
71
|
+
else
|
72
|
+
puts "!! ERROR: step definition >#{name}< not found; cannot run/execute - known (defined) steps include:"
|
73
|
+
pp self.class.step_methods #=> e.g. [:hello, ...]
|
74
|
+
exit 1
|
75
|
+
end
|
76
|
+
end # method step
|
77
|
+
|
78
|
+
|
79
|
+
def self.step_methods
|
80
|
+
names = instance_methods.reduce([]) do |names, name|
|
81
|
+
names << $1.to_sym if name =~ /^step_(.+)/
|
82
|
+
names
|
83
|
+
end
|
84
|
+
names
|
85
|
+
end
|
86
|
+
end # class Base
|
87
|
+
|
88
|
+
|
89
|
+
end # module Flow
|
@@ -0,0 +1,130 @@
|
|
1
|
+
module Flow
|
2
|
+
|
3
|
+
class Tool
|
4
|
+
def self.main( args=ARGV )
|
5
|
+
options = {}
|
6
|
+
OptionParser.new do |parser|
|
7
|
+
parser.on( '-f FILE', '--file FILE', '--flowfile FILE',
|
8
|
+
'Read FILE as a flowfile.'
|
9
|
+
) do |file|
|
10
|
+
options[:flowfile] = file
|
11
|
+
end
|
12
|
+
|
13
|
+
## note:
|
14
|
+
## you can add many/multiple modules
|
15
|
+
## e.g. -r gitti -r mono etc.
|
16
|
+
parser.on( '-r NAME', '--require NAME') do |name|
|
17
|
+
options[:requires] ||= []
|
18
|
+
options[:requires] << name
|
19
|
+
end
|
20
|
+
|
21
|
+
parser.on( '-d', '--debug') do |debug|
|
22
|
+
options[:debug] = debug
|
23
|
+
## note: for no auto-set env here - why? why not
|
24
|
+
ENV['DEBUG']='1' ## use t or true or such - why? why not?
|
25
|
+
puts "[flow] setting >DEBUG< env variable to >#{1}<"
|
26
|
+
end
|
27
|
+
|
28
|
+
## todo/check/reserve: add -e/--env(iornmanet) e.g. dev/test/prod(uction) etc.
|
29
|
+
## plus (convenience) shortcuts e.g. --dev, --prod(uction), --test
|
30
|
+
end.parse!( args )
|
31
|
+
|
32
|
+
|
33
|
+
## check for any (dynamic/auto) requires
|
34
|
+
if options[:requires]
|
35
|
+
names = options[:requires]
|
36
|
+
names.each do |name|
|
37
|
+
## todo/check: add some error/exception handling here - why? why not?
|
38
|
+
puts "[flow] auto-require >#{name}<..."
|
39
|
+
require( name )
|
40
|
+
end
|
41
|
+
else ## use/try defaults
|
42
|
+
config_path = "./config.rb"
|
43
|
+
if File.exist?( config_path )
|
44
|
+
puts "[flow] auto-require (default) >#{config_path}<..."
|
45
|
+
require( config_path )
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
path = nil
|
51
|
+
if options[:flowfile]
|
52
|
+
path = options[:flowfile]
|
53
|
+
else
|
54
|
+
path = Flowfile.find_file
|
55
|
+
|
56
|
+
if path.nil?
|
57
|
+
STDERR.puts "!! ERROR - no flowfile found, sorry - looking for: #{Flowfile::NAMES.join(', ')} in (#{Dir.pwd})"
|
58
|
+
exit 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
### split args into vars and steps
|
64
|
+
vars = []
|
65
|
+
args = args.select do |arg|
|
66
|
+
## note: mark freestanding = as fatal error (empty var)
|
67
|
+
if arg == '='
|
68
|
+
STDERR.puts "!! ERROR - empty var (=) in args; sorry - make sure there are NO spaces before ="
|
69
|
+
exit 1
|
70
|
+
elsif arg =~ /^[A-Za-z][A-Za-z0-9_]*=/
|
71
|
+
vars << arg
|
72
|
+
false ## filter -- do NOT include
|
73
|
+
else
|
74
|
+
true
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
if args.size > 0
|
79
|
+
puts "[flow] #{args.size} arg(s):"
|
80
|
+
pp args
|
81
|
+
end
|
82
|
+
|
83
|
+
if vars.size > 0
|
84
|
+
puts "[flow] #{vars.size} var(s):"
|
85
|
+
pp vars
|
86
|
+
|
87
|
+
## auto-add vars to ENV
|
88
|
+
## note: if the value is empty e.g. DEBUG= or such
|
89
|
+
## the variable gets deleted / undefined / unset!!
|
90
|
+
vars.each do |var|
|
91
|
+
pos = var.index('=') ## split on first =
|
92
|
+
name = var[0..(pos-1)]
|
93
|
+
value = var[(pos+1)..-1]
|
94
|
+
# print "[flow] splitting "
|
95
|
+
# print "%-24s " % ">#{var}<"
|
96
|
+
# print "=> name: "
|
97
|
+
# print "%-18s " % ">#{name}<,"
|
98
|
+
# print "value: >#{value}< (#{value.class.name})"
|
99
|
+
# print "\n"
|
100
|
+
|
101
|
+
if value.empty? ## note: variable gets deleted / undefined / unset
|
102
|
+
puts "[flow] UNSET >#{name}< env variable"
|
103
|
+
ENV[ name ] = nil
|
104
|
+
else
|
105
|
+
puts "[flow] set >#{name}< env variable to >#{value}<"
|
106
|
+
ENV[ name ] = value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
puts "[flow] loading >#{path}<..."
|
114
|
+
flowfile = Flowfile.load_file( path )
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
## allow multipe steps getting called - why? why not?
|
119
|
+
## flow setup clone update etc. - yes, yes
|
120
|
+
## follow make model and allow variables with FOO= or bar= too
|
121
|
+
## note: mark freestanding = as fatal error (empty var)
|
122
|
+
|
123
|
+
args.each do |arg|
|
124
|
+
flowfile.run( arg )
|
125
|
+
end
|
126
|
+
end # method self.main
|
127
|
+
end # class Tool
|
128
|
+
|
129
|
+
|
130
|
+
end # module Flow
|
data/lib/flow-lite/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flow-lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: gitti
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.6.1
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.6.1
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: hubba
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: monos
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.5.0
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.5.0
|
55
13
|
- !ruby/object:Gem::Dependency
|
56
14
|
name: rdoc
|
57
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,8 +61,10 @@ files:
|
|
103
61
|
- Rakefile
|
104
62
|
- bin/flow
|
105
63
|
- lib/flow-lite.rb
|
64
|
+
- lib/flow-lite/base.rb
|
65
|
+
- lib/flow-lite/tool.rb
|
106
66
|
- lib/flow-lite/version.rb
|
107
|
-
homepage: https://github.com/rubycoco/
|
67
|
+
homepage: https://github.com/rubycoco/flow
|
108
68
|
licenses:
|
109
69
|
- Public Domain
|
110
70
|
metadata: {}
|