standard_procedure_operations 0.7.3 → 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 +4 -4
- data/README.md +11 -8
- data/app/models/operations/task/plan.rb +4 -1
- data/app/models/operations/task.rb +7 -3
- data/lib/operations/version.rb +1 -1
- data/lib/tasks/operations_tasks.rake +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6212f5d6772368591c1780dc1fd53af91c1e298519f63929476c8df0d4d48c3f
|
|
4
|
+
data.tar.gz: 4ae1e463fa12b3e848363eee2e4c48171b018e924555a7b045f667ca5461d405
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 =
|
|
97
|
-
self.beer =
|
|
98
|
-
self.music =
|
|
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 =
|
|
106
|
-
self.beer =
|
|
107
|
-
self.music =
|
|
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
|
-
- [
|
|
365
|
-
- [
|
|
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
|
|
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)
|
|
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!
|
|
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!
|
|
@@ -83,7 +87,7 @@ module Operations
|
|
|
83
87
|
Operations::WakeTaskJob.perform_later task
|
|
84
88
|
end
|
|
85
89
|
ensure
|
|
86
|
-
|
|
90
|
+
Operations::WakeTaskJob.queue_adapter = adapter
|
|
87
91
|
end
|
|
88
92
|
end
|
|
89
93
|
|
data/lib/operations/version.rb
CHANGED
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
|
+
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.
|
|
101
|
+
rubygems_version: 3.7.2
|
|
102
102
|
specification_version: 4
|
|
103
103
|
summary: Operations
|
|
104
104
|
test_files: []
|