dev_suite 0.2.10 → 0.2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/examples/setup.rb +3 -0
- data/examples/workflow/conditional_workflow.rb +1 -1
- data/examples/workflow/full_workflow.rb +2 -2
- data/examples/workflow/loop_workflow.rb +1 -1
- data/examples/workflow/order_processing_workflow.rb +13 -11
- data/lib/dev_suite/utils/construct/component/manager.rb +6 -1
- data/lib/dev_suite/utils/store/store.rb +3 -1
- data/lib/dev_suite/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aa7bc365cd71c523150cc3dde4eb92eb84c7c7b3cff4435ac373474f7d73871
|
4
|
+
data.tar.gz: 7ec2c14843c493cfa0ef819350463e994344e407a248a5d83f317ec6d9c021ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e86091d8c8ca69fa6dec4a1a8a7b5403671e7fcd8a08db8a364b71a473704c613d8135a70645e990741e8a23b00cac8ffdab1cb419c2582e9b75476829842a9d
|
7
|
+
data.tar.gz: 6fbbf0e0cb281dd9ead32c6a4eeeeec414d3cf2216865f2c3c01908e3d25eb946b9de82de68002c34d170e05bd7038cbe2fae7ba86b88a5c78de412e49dff279
|
data/Gemfile.lock
CHANGED
data/examples/setup.rb
ADDED
@@ -7,7 +7,7 @@ require "dev_suite"
|
|
7
7
|
engine = DevSuite::Workflow::Engine.new(user: "Bob", role: "admin")
|
8
8
|
|
9
9
|
# Add a conditional step
|
10
|
-
conditional_step = DevSuite::Workflow.create_conditional_step("Admin Greeting", ->(ctx) {
|
10
|
+
conditional_step = DevSuite::Workflow.create_conditional_step("Admin Greeting", condition: ->(ctx) {
|
11
11
|
ctx.get(:role) == "admin"
|
12
12
|
}) do |context|
|
13
13
|
puts "Welcome Admin, #{context.get(:user)}!"
|
@@ -20,14 +20,14 @@ greet_step = DevSuite::Workflow.create_step("Greet User") do |context|
|
|
20
20
|
end
|
21
21
|
|
22
22
|
# Step 2: Create a conditional step to greet only admins
|
23
|
-
admin_step = DevSuite::Workflow.create_conditional_step("Admin Greeting", ->(ctx) {
|
23
|
+
admin_step = DevSuite::Workflow.create_conditional_step("Admin Greeting", condition: ->(ctx) {
|
24
24
|
ctx.get(:role) == "admin"
|
25
25
|
}) do |context|
|
26
26
|
puts "Welcome, Admin #{context.get(:user)}!"
|
27
27
|
end
|
28
28
|
|
29
29
|
# Step 3: Create a loop step that repeats 3 times
|
30
|
-
loop_step = DevSuite::Workflow.create_loop_step("Loop Step", 3) do |ctx|
|
30
|
+
loop_step = DevSuite::Workflow.create_loop_step("Loop Step", iterations: 3) do |ctx|
|
31
31
|
iteration = ctx.get(:iteration_count) + 1
|
32
32
|
ctx.update({ iteration_count: iteration })
|
33
33
|
puts "Iteration #{iteration} completed."
|
@@ -7,7 +7,7 @@ require "dev_suite"
|
|
7
7
|
engine = DevSuite::Workflow::Engine.new(iteration_count: 0)
|
8
8
|
|
9
9
|
# Add a loop step
|
10
|
-
loop_step = DevSuite::Workflow.create_loop_step("Repeat Task", 3) do |context|
|
10
|
+
loop_step = DevSuite::Workflow.create_loop_step("Repeat Task", iterations: 3) do |context|
|
11
11
|
iteration = context.get(:iteration_count) + 1
|
12
12
|
context.update({ iteration_count: iteration })
|
13
13
|
puts "Iteration #{iteration}"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative "../
|
3
|
+
require_relative "../setup"
|
4
4
|
|
5
5
|
$LOAD_PATH.unshift(File.expand_path("../../lib", __dir__))
|
6
6
|
require "dev_suite"
|
@@ -95,7 +95,7 @@ register_step = DevSuite::Workflow.create_step("Register Users") do |ctx|
|
|
95
95
|
ctx.data
|
96
96
|
end
|
97
97
|
|
98
|
-
save_users_step = DevSuite::Workflow.create_conditional_step("Save Users to Store", ->(ctx) {
|
98
|
+
save_users_step = DevSuite::Workflow.create_conditional_step("Save Users to Store", condition: ->(ctx) {
|
99
99
|
ctx.get(:users)&.any?
|
100
100
|
}) do |ctx|
|
101
101
|
ctx.store.set(:users, ctx.get(:users))
|
@@ -103,7 +103,7 @@ save_users_step = DevSuite::Workflow.create_conditional_step("Save Users to Stor
|
|
103
103
|
ctx.data
|
104
104
|
end
|
105
105
|
|
106
|
-
login_step = DevSuite::Workflow.create_conditional_step("Login Users", ->(ctx) {
|
106
|
+
login_step = DevSuite::Workflow.create_conditional_step("Login Users", condition: ->(ctx) {
|
107
107
|
ctx.get(:username) && ctx.get(:password)
|
108
108
|
}) do |ctx|
|
109
109
|
response = login_user(ctx.get(:username), ctx.get(:password))
|
@@ -119,7 +119,7 @@ login_step = DevSuite::Workflow.create_conditional_step("Login Users", ->(ctx) {
|
|
119
119
|
ctx.data
|
120
120
|
end
|
121
121
|
|
122
|
-
fetch_order_step = DevSuite::Workflow.create_conditional_step("Fetch Orders", ->(ctx) {
|
122
|
+
fetch_order_step = DevSuite::Workflow.create_conditional_step("Fetch Orders", condition: ->(ctx) {
|
123
123
|
ctx.get(:token) && ctx.get(:user_id)
|
124
124
|
}) do |ctx|
|
125
125
|
response = fetch_order(ctx.get(:token), ctx.get(:user_id))
|
@@ -134,7 +134,7 @@ fetch_order_step = DevSuite::Workflow.create_conditional_step("Fetch Orders", ->
|
|
134
134
|
ctx.data
|
135
135
|
end
|
136
136
|
|
137
|
-
process_payment_step = DevSuite::Workflow.create_conditional_step("Process Payment", ->(ctx) {
|
137
|
+
process_payment_step = DevSuite::Workflow.create_conditional_step("Process Payment", condition: ->(ctx) {
|
138
138
|
ctx.get(:order_id) && ctx.get(:token) && ctx.get(:user_id)
|
139
139
|
}) do |ctx|
|
140
140
|
response = process_payment(ctx.get(:order_id), ctx.get(:token), ctx.get(:user_id))
|
@@ -155,9 +155,11 @@ workflow = DevSuite::Workflow.create_engine(
|
|
155
155
|
path: STORE_PATH,
|
156
156
|
)
|
157
157
|
|
158
|
-
|
159
|
-
.step(
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
158
|
+
DevSuite::MethodTracer.trace do
|
159
|
+
workflow.step(register_step)
|
160
|
+
.step(save_users_step)
|
161
|
+
.step(login_step)
|
162
|
+
.step(fetch_order_step)
|
163
|
+
.step(process_payment_step)
|
164
|
+
.execute
|
165
|
+
end
|
@@ -32,7 +32,12 @@ module DevSuite
|
|
32
32
|
|
33
33
|
raise ArgumentError, "Component not found for key: #{component_key}" unless component_class
|
34
34
|
|
35
|
-
|
35
|
+
# Check if options are empty to avoid passing unnecessary keyword arguments in Ruby 2.6
|
36
|
+
if options.empty?
|
37
|
+
component_class.new(&block)
|
38
|
+
else
|
39
|
+
component_class.new(**options, &block)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
|
38
43
|
# Build multiple components by filtering registered ones
|
@@ -44,7 +44,9 @@ module DevSuite
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def build_driver(options)
|
47
|
-
|
47
|
+
driver_type = options.fetch(:driver)
|
48
|
+
driver_options = options.reject { |key, _| key == :driver }
|
49
|
+
Driver.build_component(driver_type, **driver_options)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
data/lib/dev_suite/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_suite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huy Nguyen
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- examples/helpers/api_helper.rb
|
100
100
|
- examples/helpers/data_helper.rb
|
101
101
|
- examples/helpers/helpers.rb
|
102
|
+
- examples/setup.rb
|
102
103
|
- examples/workflow/basic_workflow.rb
|
103
104
|
- examples/workflow/composite_workflow.rb
|
104
105
|
- examples/workflow/conditional_workflow.rb
|