dev_suite 0.2.10 → 0.2.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92ff382f54afdf8f68f1f3d5f2f3bec8c496138b0af875b0970b2cceaec24e36
4
- data.tar.gz: 743a74d46e4448c8e363d7b00e501bd1b2740eb5a10eb1bd019432cb01afd4ea
3
+ metadata.gz: 3aa7bc365cd71c523150cc3dde4eb92eb84c7c7b3cff4435ac373474f7d73871
4
+ data.tar.gz: 7ec2c14843c493cfa0ef819350463e994344e407a248a5d83f317ec6d9c021ff
5
5
  SHA512:
6
- metadata.gz: 7dffd5d2cf8ca2f1712e4e9599e5432666e654a8b6c5696fc185a7898342f574018c2d1311fd96a832a956f4c3aacf1023a7c3ffd83523c3094fb8823b3133f2
7
- data.tar.gz: db80d0b5c8d9f425ac520b59b6b0988bf5dabadaaaff2647312511aa47bb5eaf738661ec6efe6253028d031baedd49012b910cd0bda65dac6872eaa7c314affe
6
+ metadata.gz: e86091d8c8ca69fa6dec4a1a8a7b5403671e7fcd8a08db8a364b71a473704c613d8135a70645e990741e8a23b00cac8ffdab1cb419c2582e9b75476829842a9d
7
+ data.tar.gz: 6fbbf0e0cb281dd9ead32c6a4eeeeec414d3cf2216865f2c3c01908e3d25eb946b9de82de68002c34d170e05bd7038cbe2fae7ba86b88a5c78de412e49dff279
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dev_suite (0.2.10)
4
+ dev_suite (0.2.11)
5
5
  benchmark (~> 0.1)
6
6
  csv (~> 3.0)
7
7
  get_process_mem (~> 1.0)
data/examples/setup.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "helpers/helpers"
@@ -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 "../helpers"
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
- workflow.step(register_step)
159
- .step(save_users_step)
160
- .step(login_step)
161
- .step(fetch_order_step)
162
- .step(process_payment_step)
163
- .execute
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
- component_class.new(**options, &block)
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
- Driver.build_component(options.fetch(:driver), **options.except(:driver))
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevSuite
4
- VERSION = "0.2.10"
4
+ VERSION = "0.2.11"
5
5
  end
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.10
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