standard_procedure_operations 0.7.4 → 0.7.5

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: 5a89c94d4e9027f50e32e00a7fc020a8cbca7c65f124868f8e4d33df88dcd40d
4
- data.tar.gz: 1cfbf4d81e61041b64bd5025af6aa2b3b43651994dadf369bb15235c2b515841
3
+ metadata.gz: 6212f5d6772368591c1780dc1fd53af91c1e298519f63929476c8df0d4d48c3f
4
+ data.tar.gz: 4ae1e463fa12b3e848363eee2e4c48171b018e924555a7b045f667ca5461d405
5
5
  SHA512:
6
- metadata.gz: 76cc19d3e82d002859ed906dd94dbeaac210d61b8cd2504bcd17907b1d9cf2a4801afb0b8fe2ea2de4c2f631c0e6d3373a331ac0ca98c505004a99483b99586d
7
- data.tar.gz: e2413ea617bf2fd83e6df88973dba9e77d032dc38153f46702db4dac4eebb0481e05f1d6a11cda9e4465e0fea1ff167056d462e1591af544bb4f514110a8e4e4
6
+ metadata.gz: 3b3a44392fc45ee6034aaffd11ac825f4b987152a49885255368afaeb36e4b99f81dd26a8861a8e20f1e11f9957081c9a7fe1d8be9fdd9fd529d2da25705e677
7
+ data.tar.gz: 07f8112e81c41c4088778dbfbba651852306a882e6949b4de5f6650f1ebd53d901db91fb87cae435c2c25fef37613e41218edd5a782641362e134fd300fa6253
data/README.md CHANGED
@@ -75,6 +75,8 @@ expect(task.available_friends).to_not be_empty
75
75
  ```
76
76
  We define the `attributes` that the task contains and its starting `state`.
77
77
 
78
+ Attributes are stored in a JSON field within the table - either as simple data types (`has_attribute :count, :integer, default: 0`) or as a reference to another ActiveRecord model (`has_model :user` or `has_model :submitted_by, "User"` if you need to restrict the model to a particular class). This uses the [HasAttributes](https://github.com/standard-procedure/has_attributes) gem.
79
+
78
80
  The initial state is `what_day_is_it?` which is a _decision_ that checks the date supplied and moves to a different state based upon the conditions defined. `buy_food`, `buy_drinks` and `invite_friends` are _actions_ which do things. Whereas `party!`, `relax` and `go_to_work` are _results_ which end the task.
79
81
 
80
82
  When you `call` the task, it runs through the process immediately and either fails with an exception or completes immediately. You can test `completed?` or `failed?` and check the `current_state`.
@@ -93,18 +95,18 @@ An action handler does some work, and then transitions to another state. Once th
93
95
 
94
96
  ```ruby
95
97
  action :have_a_party do
96
- self.food = task.buy_some_food_for(number_of_guests)
97
- self.beer = task.buy_some_beer_for(number_of_guests)
98
- self.music = task.plan_a_party_playlist
98
+ self.food = buy_some_food_for(number_of_guests)
99
+ self.beer = buy_some_beer_for(number_of_guests)
100
+ self.music = plan_a_party_playlist
99
101
  end
100
102
  go_to :send_invitations
101
103
  ```
102
104
  This is the same as:
103
105
  ```ruby
104
106
  action :have_a_party do
105
- self.food = task.buy_some_food_for(number_of_guests)
106
- self.beer = task.buy_some_beer_for(number_of_guests)
107
- self.music = task.plan_a_party_playlist
107
+ self.food = buy_some_food_for(number_of_guests)
108
+ self.beer = buy_some_beer_for(number_of_guests)
109
+ self.music = plan_a_party_playlist
108
110
  end.then :send_invitations
109
111
  ```
110
112
 
@@ -361,5 +363,6 @@ The gem is available as open source under the terms of the [LGPL License](/LICEN
361
363
  - [x] Add wait for sub-tasks capabilities
362
364
  - [x] Add visualization export for task flows
363
365
  - [ ] Replace ActiveJob with a background process
364
- - [ ] Rename StateManagent with Plan
365
- - [ ] Add interactions
366
+ - [x] Rename StateManagent with Plan
367
+ - [x] Add interactions
368
+ - [x] Specify ActiveJob queues and adapters
@@ -62,13 +62,16 @@ module Operations::Task::Plan
62
62
 
63
63
  def interaction_handler_for(name) = interaction_handlers[name.to_s]
64
64
 
65
- def default_times = {wakes_at: background_delay.from_now, expires_at: execution_timeout.from_now, delete_at: deletion_time.from_now}
65
+ def sleep_times = {wakes_at: background_delay.from_now, expires_at: execution_timeout.from_now, delete_at: deletion_time.from_now}
66
+
67
+ def default_times = {wakes_at: Time.now, expires_at: execution_timeout.from_now, delete_at: deletion_time.from_now}
66
68
  end
67
69
 
68
70
  def in?(state) = current_state == state.to_s
69
71
  alias_method :waiting_until?, :in?
70
72
 
71
73
  private def handler_for(state) = self.class.handler_for(state)
74
+ private def sleep_times = self.class.sleep_times
72
75
  private def default_times = self.class.default_times
73
76
  private def background_delay = self.class.background_delay
74
77
  private def execution_timeout = self.class.execution_timeout
@@ -38,7 +38,9 @@ module Operations
38
38
  raise ex
39
39
  end
40
40
 
41
- def go_to(next_state) = update! current_state: next_state, task_status: (state_is_immediate?(next_state) ? "active" : "waiting")
41
+ def go_to(next_state)
42
+ update! current_state: next_state, task_status: (state_is_immediate?(next_state) ? "active" : "waiting")
43
+ end
42
44
 
43
45
  def wake_up! = timeout_expired? ? call_timeout_handler : activate_and_call
44
46
 
@@ -50,7 +52,9 @@ module Operations
50
52
 
51
53
  private def state_is_immediate?(state) = handler_for(state).immediate?
52
54
 
53
- private def go_to_sleep! = update!(default_times.merge(task_status: "waiting"))
55
+ private def go_to_sleep!
56
+ update!(sleep_times.merge(task_status: "waiting"))
57
+ end
54
58
 
55
59
  private def activate_and_call
56
60
  active!
@@ -1,3 +1,3 @@
1
1
  module Operations
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
@@ -1,4 +1,4 @@
1
- desc "Start the Agent Runner process"
1
+ desc "Start the Task Runner process"
2
2
  task :agent_runner do
3
- Operations::Agent::Runner.start
3
+ Operations::Task::Runner.start
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_procedure_operations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 3.6.7
101
+ rubygems_version: 3.7.2
102
102
  specification_version: 4
103
103
  summary: Operations
104
104
  test_files: []