simplerubysteps 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8be19b6aa108f0bad7ca85714f134b3ae8876a43a2da627f685fc1f181a1e81b
4
- data.tar.gz: feb25d925cc950177873b1e6a5a2bf19406d7b7a796ee0983d03a44461d49d6c
3
+ metadata.gz: b1331d05828403e219eed44ad66888362be212c7cb31d7676e2c58ced835b0b8
4
+ data.tar.gz: f402ca43e00170f1b4814098a03b9e1048ba7d52b6f44bf613726f4409d57e98
5
5
  SHA512:
6
- metadata.gz: '04878fef3099b7798994503ceb9c373d559a0bee170ac9747b26a4f27548cd978810627c08ffe579a05eaf0e2bec1ab6d82e7288852c07cec9438b9403181ec4'
7
- data.tar.gz: 6c719c0cc7ae0e8a9e25387131f552ece86774eed9b45649589070d3e32f1f593e6bcac3915dca64ec836d0cdce647868b2b6a1f6d73c1e6f6efecc2379eadad
6
+ metadata.gz: 2c8c8fb7a7e62c32abd550ad902082ccdc0568093b1a262b804b64ae9886bc9dd5dbc2673ce4460a3d881d68953a4b593a659bc507c295966e9be719f792638d
7
+ data.tar.gz: '05327638e236a405009d752d23d0b4ea28ae7cb5a77bcc43deb7ecb909674b83f80ca9f197e0ba1c2c0e6ff5172ccd7aad194a84c55b1888bdb169f0c56f8385'
data/README.md CHANGED
@@ -59,6 +59,14 @@ After checking out the repo, run `bin/setup` to install dependencies.
59
59
 
60
60
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
61
61
 
62
+ ### TODOs
63
+
64
+ * Support for StateMachineType (STANDARD or EXPRESS)
65
+ * Custom IAM role policies (Step Functions and Lambda)
66
+ * sls-like tooling in ruby with AWS SDK
67
+ * Workflow action unit test support
68
+ * ...
69
+
62
70
  ## Contributing
63
71
 
64
72
  Bug reports and pull requests are (soon - after alpha phase) welcome on GitHub at https://github.com/chtz/simplerubysteps
@@ -1,3 +1,3 @@
1
1
  module Simplerubysteps
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -76,7 +76,24 @@ module Simplerubysteps
76
76
  end
77
77
 
78
78
  def perform_action(input)
79
- @action_block.call(input) if @action_block
79
+ output = nil
80
+ output = @action_block.call(input) if @action_block
81
+
82
+ if @implicit_choice
83
+ output = {} unless output
84
+ @implicit_choice.perform_action(output)
85
+ end
86
+
87
+ output
88
+ end
89
+
90
+ def implicit_choice
91
+ unless @implicit_choice
92
+ @implicit_choice = Choice.new("#{name}_choice")
93
+ $sm.add @implicit_choice
94
+ self.next = @implicit_choice
95
+ end
96
+ @implicit_choice
80
97
  end
81
98
  end
82
99
 
@@ -105,6 +122,8 @@ module Simplerubysteps
105
122
  end
106
123
 
107
124
  class ChoiceItem
125
+ attr_accessor :implicit_condition_block
126
+
108
127
  def initialize(dict = {}, state = nil)
109
128
  @dict = dict
110
129
  self.next = state if state
@@ -117,6 +136,12 @@ module Simplerubysteps
117
136
  def render
118
137
  @dict
119
138
  end
139
+
140
+ def perform_action(choice_name, output)
141
+ if @implicit_condition_block
142
+ output["#{choice_name}_#{@dict[:Next]}"] = @implicit_condition_block.call(output) ? "yes" : "no"
143
+ end
144
+ end
120
145
  end
121
146
 
122
147
  class Choice < State
@@ -152,6 +177,12 @@ module Simplerubysteps
152
177
  dict[:Choices] = @choices.map { |item| item.render }
153
178
  dict
154
179
  end
180
+
181
+ def perform_action(output)
182
+ @choices.each do |choice|
183
+ choice.perform_action name, output
184
+ end
185
+ end
155
186
  end
156
187
 
157
188
  # Workflow DSL
@@ -187,6 +218,25 @@ module Simplerubysteps
187
218
  $tasks.last.next = state
188
219
  end
189
220
 
221
+ def transition_to(state, &condition_block)
222
+ choice = $tasks.last.implicit_choice
223
+
224
+ c = ChoiceItem.new({
225
+ :Variable => "$.#{choice.name}_#{state}",
226
+ :StringMatches => "yes",
227
+ })
228
+ c.next = state
229
+ c.implicit_condition_block = condition_block
230
+
231
+ choice.add c
232
+ end
233
+
234
+ def default_transition_to(state)
235
+ choice = $tasks.last.implicit_choice
236
+
237
+ choice.default = state
238
+ end
239
+
190
240
  def choice(name)
191
241
  t = $sm.add Choice.new(name)
192
242
 
@@ -13,8 +13,7 @@ task :t1 do
13
13
  string_matches "$.Foo1", "ja" do
14
14
  callback :t3 do
15
15
  action do |input, token|
16
- puts "Callback t3: #{input}, #{token}"
17
- # input.merge({ "Foo3": "Bar3x" })
16
+ puts "Callback t3: #{input}, #{token}" # The logged token is picked up by continue-callbackbranch.sh
18
17
  end
19
18
 
20
19
  transition :t5
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require "simplerubysteps"
4
+ include Simplerubysteps
5
+
6
+ task :t1 do
7
+ action do |input|
8
+ puts "Task t1: #{input}"
9
+ input.merge({ "t1" => (input["bar"] ? input["bar"] : "") + "t1" })
10
+ end
11
+
12
+ transition_to :t2 do |output|
13
+ output["t1"] == "foot1"
14
+ end
15
+
16
+ default_transition_to :t3
17
+ end
18
+
19
+ task :t2 do
20
+ action do |input|
21
+ puts "Task t2: #{input}"
22
+ input.merge({ "t2" => "yes" })
23
+ end
24
+
25
+ transition :t4
26
+ end
27
+
28
+ task :t3 do
29
+ action do |input|
30
+ puts "Task t3: #{input}"
31
+ input.merge({ "t3" => "yes" })
32
+ end
33
+
34
+ task :t4 do
35
+ action do |input|
36
+ puts "Task t4: #{input}"
37
+ input.merge({ "t4" => "yes" })
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplerubysteps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Tschenett
@@ -73,6 +73,7 @@ files:
73
73
  - samples/sample1/start-callbackbranch.sh
74
74
  - samples/sample1/start-directbranch.sh
75
75
  - samples/sample1/workflow.rb
76
+ - samples/sample2/workflow.rb
76
77
  - simplerubysteps.gemspec
77
78
  homepage: https://github.com/chtz/simplerubysteps
78
79
  licenses: