flow-lite 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4af502cc9764efd28671cbd3e4e498c0cc9dbd87
4
+ data.tar.gz: af96b08715862f411dfb3cdc7a2b87bc8ac4c8e6
5
+ SHA512:
6
+ metadata.gz: c2edc964d13234f76c67c52989e4ff9e664164a61ba185f472d6f24a6300d1ee87cdc8ec30eb40a88258fd9beb63e133f95e852249b7f0d5b624e17430a86b31
7
+ data.tar.gz: 90a4af15059474729db047b8ad658c36cfacbcdfd0db1802ec29423d22893806eea0a9beeb371364a05f848ffbf8b82aa15333b32fbf3cfe630d8a73287e7eee
@@ -0,0 +1,4 @@
1
+ ### 0.0.1 / 2020-10-23
2
+
3
+ * Everything is new. First release.
4
+
@@ -0,0 +1,7 @@
1
+ CHANGELOG.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ bin/flow
6
+ lib/flow-lite.rb
7
+ lib/flow-lite/version.rb
@@ -0,0 +1,23 @@
1
+ # flow-lite
2
+
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
+
5
+
6
+ * home :: [github.com/rubycoco/git](https://github.com/rubycoco/git)
7
+ * bugs :: [github.com/rubycoco/git/issues](https://github.com/rubycoco/git/issues)
8
+ * gem :: [rubygems.org/gems/flow-lite](https://rubygems.org/gems/flow-lite)
9
+ * rdoc :: [rubydoc.info/gems/flow-lite](http://rubydoc.info/gems/flow-lite)
10
+
11
+
12
+
13
+ ## Usage
14
+
15
+ To be done
16
+
17
+
18
+
19
+ ## License
20
+
21
+ The `flow-lite` scripts are dedicated to the public domain.
22
+ Use it as you please with no restrictions whatsoever.
23
+
@@ -0,0 +1,31 @@
1
+ require 'hoe'
2
+ require './lib/flow-lite/version.rb'
3
+
4
+ Hoe.spec 'flow-lite' do
5
+
6
+ self.version = FlowLite::VERSION
7
+
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
+ self.description = summary
10
+
11
+ self.urls = { home: 'https://github.com/rubycoco/git' }
12
+
13
+ self.author = 'Gerald Bauer'
14
+ self.email = 'ruby-talk@ruby-lang.org'
15
+
16
+ # switch extension to .markdown for gihub formatting
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'CHANGELOG.md'
19
+
20
+ self.extra_deps = [
21
+ ['gitti', '>= 0.6.1' ],
22
+ ['hubba', '>= 1.0.0' ],
23
+ ['monos', '>= 0.5.0' ],
24
+ ]
25
+
26
+ self.licenses = ['Public Domain']
27
+
28
+ self.spec_extras = {
29
+ required_ruby_version: '>= 2.2.2'
30
+ }
31
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/flow
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/flow
13
+ #
14
+
15
+ require 'flow-lite'
16
+
17
+ Flow::Tool.main
@@ -0,0 +1,142 @@
1
+ require 'pp'
2
+ require 'optparse'
3
+
4
+
5
+
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 ???
13
+
14
+
15
+
16
+ #####################
17
+ # our own code
18
+ require 'flow-lite/version' # note: let version always go first
19
+
20
+
21
+
22
+ module Flow
23
+ class Step
24
+ attr_reader :names # e.g. :list or [:list,:ls] etc.
25
+ attr_reader :block
26
+
27
+ def name() @names[0]; end ## "primary" name
28
+
29
+ def initialize( name_or_names, block )
30
+ @names = if name_or_names.is_a?( Array )
31
+ name_or_names
32
+ else
33
+ [name_or_names] ## assume single symbol (name); wrap in array
34
+ end
35
+ @names = @names.map {|name| name.to_sym } ## make sure we always use symbols
36
+ @block = block
37
+ end
38
+ end # class Step
39
+
40
+
41
+
42
+ class Base ## base class for flow class (auto)-constructed/build from flowfile
43
+ end
44
+
45
+
46
+ class Flowfile
47
+ ## convenience method - use like Flowfile.load_file()
48
+ def self.load_file( path='./Flowfile' )
49
+ code = File.open( path, 'r:utf-8' ) { |f| f.read }
50
+ load( code )
51
+ end
52
+
53
+ ## another convenience method - use like Flowfile.load()
54
+ def self.load( code )
55
+ flowfile = new
56
+ flowfile.instance_eval( code )
57
+ flowfile
58
+ end
59
+
60
+
61
+
62
+ def flow ## build flow class
63
+ @flow_class ||= build_flow_class
64
+ @flow_class.new ## todo/check: always return a new instance why? why not?
65
+ end
66
+
67
+ def build_flow_class
68
+ puts " building flow class..."
69
+ flowfile = self
70
+ klass = Class.new( Base ) do
71
+ flowfile.steps.each_with_index do |step,i|
72
+ name = step.names[0]
73
+ puts " adding step #{i+1}/#{flowfile.steps.size} >#{name}<..."
74
+ define_method( name, &step.block )
75
+
76
+ alt_names = step.names[1..-1]
77
+ alt_names.each do |alt_name|
78
+ puts " adding alias >#{alt_name}< for >#{name}<..."
79
+ alias_method( alt_name, name )
80
+ end
81
+ end
82
+ end
83
+ klass
84
+ end
85
+
86
+
87
+
88
+ def initialize( opts={} )
89
+ @opts = opts
90
+ @steps = []
91
+ end
92
+
93
+ attr_reader :steps
94
+
95
+ ## "classic / basic" primitives - step
96
+ def step( name, &block )
97
+ @steps << Step.new( name, block )
98
+ end
99
+
100
+
101
+ def run( name )
102
+ name = name.to_sym ## make sure we always use symbols
103
+ if flow.respond_to?( name )
104
+ flow.send( name )
105
+ else
106
+ puts "!! ERROR: step definition >#{name}< not found; cannot run/execute - known steps include:"
107
+ pp @steps
108
+ exit 1
109
+ end
110
+ end
111
+ end # class Flowfile
112
+
113
+
114
+
115
+ class Tool
116
+ def self.main( args=ARGV )
117
+ options = {}
118
+ OptionParser.new do |parser|
119
+ parser.on( '-f FILENAME', '--flowfile FILENAME' ) do |filename|
120
+ options[:flowfile] = filename
121
+ end
122
+ end.parse!( args )
123
+
124
+ path = options[:flowfile] || './Flowfile'
125
+ flowfile = Flowfile.load_file( path )
126
+
127
+ ## allow multipe steps getting called - why? why not?
128
+ ## flow setup clone update etc??
129
+ args.each do |arg|
130
+ flowfile.run( arg )
131
+ end
132
+ end
133
+ end # class Tool
134
+
135
+ end # module Flow
136
+
137
+
138
+
139
+ # say hello
140
+ puts FlowLite.banner
141
+
142
+
@@ -0,0 +1,20 @@
1
+ module FlowLite
2
+
3
+ MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
+ MINOR = 0
5
+ PATCH = 1
6
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
7
+
8
+ def self.version
9
+ VERSION
10
+ end
11
+
12
+ def self.banner
13
+ "flow-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
14
+ end
15
+
16
+ def self.root
17
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
18
+ end
19
+
20
+ end # module FlowLite
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flow-lite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-23 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '7'
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '4.0'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '7'
75
+ - !ruby/object:Gem::Dependency
76
+ name: hoe
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.22'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.22'
89
+ description: flow-lite gem - (yet) another (lite) workflow engine; let's you define
90
+ your workflow steps in Flowfiles; incl. the flow command line tool
91
+ email: ruby-talk@ruby-lang.org
92
+ executables:
93
+ - flow
94
+ extensions: []
95
+ extra_rdoc_files:
96
+ - CHANGELOG.md
97
+ - Manifest.txt
98
+ - README.md
99
+ files:
100
+ - CHANGELOG.md
101
+ - Manifest.txt
102
+ - README.md
103
+ - Rakefile
104
+ - bin/flow
105
+ - lib/flow-lite.rb
106
+ - lib/flow-lite/version.rb
107
+ homepage: https://github.com/rubycoco/git
108
+ licenses:
109
+ - Public Domain
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options:
113
+ - "--main"
114
+ - README.md
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: 2.2.2
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.5.2
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: flow-lite gem - (yet) another (lite) workflow engine; let's you define your
133
+ workflow steps in Flowfiles; incl. the flow command line tool
134
+ test_files: []