eventful.rb 0.8.0 → 1.0.0
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/eventful.rb.gemspec +1 -2
- data/lib/Eventful/VERSION.rb +1 -1
- data/test/ActiveRecord.rb +14 -14
- data/test/ActiveRecordWhenNoFinalState.rb +14 -14
- data/test/Poro.rb +13 -13
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a3a6b9667391f457f0da31208acab094361ea4103831ead56ba1f6d39212b295
|
|
4
|
+
data.tar.gz: 0d22261339383552cac730a0b11f88adc5b661bded106cd763610f6daa7febc6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 497fb54c3fa47a91b797ff119ac732d755f0de5f73470c3d825101195a53229b4804c4e6226eac236d24617b428b29e821672607b7fd6fe2d528b0452911eda6
|
|
7
|
+
data.tar.gz: 43ffedea3742796da98af3fa96e95a20c5039b2b3f73863e031cd0062ca2cc462f635e9b48b3ec369252984412d6d87bb2af0a4557bcbbc6d6cbd26b3e383271
|
data/eventful.rb.gemspec
CHANGED
|
@@ -4,7 +4,6 @@ Gem::Specification.new do |spec|
|
|
|
4
4
|
spec.name = 'eventful.rb'
|
|
5
5
|
|
|
6
6
|
spec.version = Eventful::VERSION
|
|
7
|
-
spec.date = '2025-07-28'
|
|
8
7
|
|
|
9
8
|
spec.summary = "Automatically change state with Stateful state machines."
|
|
10
9
|
spec.description = "By defining predicate methods which except for the addition of '?' matches a state machine event and then configuring an in memory or cron-based event loop, the state machine will be able to change state automatically."
|
|
@@ -14,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
14
13
|
spec.homepage = 'http://github.com/thoran/eventful.rb'
|
|
15
14
|
spec.license = 'Ruby'
|
|
16
15
|
|
|
17
|
-
spec.required_ruby_version = '>=
|
|
16
|
+
spec.required_ruby_version = '>= 2.5'
|
|
18
17
|
|
|
19
18
|
spec.add_dependency('stateful.rb')
|
|
20
19
|
spec.files = [
|
data/lib/Eventful/VERSION.rb
CHANGED
data/test/ActiveRecord.rb
CHANGED
|
@@ -13,7 +13,7 @@ require 'active_record'
|
|
|
13
13
|
require 'pg'
|
|
14
14
|
require 'Eventful'
|
|
15
15
|
|
|
16
|
-
class CreateTableActiveRecordMachines < ActiveRecord::Migration
|
|
16
|
+
class CreateTableActiveRecordMachines < ActiveRecord::Migration[6.0]
|
|
17
17
|
|
|
18
18
|
def change
|
|
19
19
|
create_table :active_record_machines do |t|
|
|
@@ -61,11 +61,11 @@ describe Eventful do
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
it "must have successfully extended the receiver class with Stateful methods" do
|
|
64
|
-
machine.class.methods.include?(:stateful_states).must_equal true
|
|
64
|
+
_(machine.class.methods.include?(:stateful_states)).must_equal true
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
it "must have successfully extended the receiver class with Eventful methods" do
|
|
68
|
-
machine.class.methods.include?(:active).must_equal true
|
|
68
|
+
_(machine.class.methods.include?(:active)).must_equal true
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
context "only an_event? is true" do
|
|
@@ -88,22 +88,22 @@ describe Eventful do
|
|
|
88
88
|
|
|
89
89
|
it "must know which instances are active (ie. not in a final state)" do
|
|
90
90
|
machine.current_state
|
|
91
|
-
ActiveRecordMachine.active.size.must_equal 1
|
|
91
|
+
_(ActiveRecordMachine.active.size).must_equal 1
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
it "must know whether an event has occurred" do
|
|
95
|
-
machine.an_event
|
|
95
|
+
_(machine.an_event?).must_equal true
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
it "must know whether an event has not occurred" do
|
|
99
|
-
machine.another_event
|
|
100
|
-
machine.yet_another_event
|
|
99
|
+
_(machine.another_event?).must_equal false
|
|
100
|
+
_(machine.yet_another_event?).must_equal false
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "must automatically trigger state changes" do
|
|
104
104
|
machine.current_state
|
|
105
105
|
ActiveRecordMachine.run
|
|
106
|
-
machine.reload.current_state.name.must_equal :next_state
|
|
106
|
+
_(machine.reload.current_state.name).must_equal :next_state
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -127,22 +127,22 @@ describe Eventful do
|
|
|
127
127
|
|
|
128
128
|
it "must know which instances are active (ie. not in a final state)" do
|
|
129
129
|
machine.current_state
|
|
130
|
-
ActiveRecordMachine.active.size.must_equal 1
|
|
130
|
+
_(ActiveRecordMachine.active.size).must_equal 1
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
it "must know whether an event has occurred" do
|
|
134
|
-
machine.an_event
|
|
135
|
-
machine.yet_another_event
|
|
134
|
+
_(machine.an_event?).must_equal true
|
|
135
|
+
_(machine.yet_another_event?).must_equal true
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
it "must know whether an event has not occurred" do
|
|
139
|
-
machine.another_event
|
|
139
|
+
_(machine.another_event?).must_equal false
|
|
140
140
|
end
|
|
141
141
|
|
|
142
142
|
it "must automatically trigger state changes" do
|
|
143
143
|
machine.current_state = :next_state
|
|
144
144
|
ActiveRecordMachine.run
|
|
145
|
-
machine.reload.current_state.name.must_equal :final_state
|
|
145
|
+
_(machine.reload.current_state.name).must_equal :final_state
|
|
146
146
|
end
|
|
147
147
|
end
|
|
148
148
|
|
|
@@ -169,7 +169,7 @@ describe Eventful do
|
|
|
169
169
|
ActiveRecordMachine.run(2, 10) # Run every 2 seconds for not more than 10 seconds.
|
|
170
170
|
finish_time = Time.now
|
|
171
171
|
run_time = finish_time - start_time
|
|
172
|
-
run_time.must_be_close_to 10, 0.1
|
|
172
|
+
_(run_time).must_be_close_to 10, 0.1
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
|
|
@@ -13,7 +13,7 @@ require 'active_record'
|
|
|
13
13
|
require 'pg'
|
|
14
14
|
require 'Eventful'
|
|
15
15
|
|
|
16
|
-
class CreateTableActiveRecordMachines2 < ActiveRecord::Migration
|
|
16
|
+
class CreateTableActiveRecordMachines2 < ActiveRecord::Migration[6.0]
|
|
17
17
|
|
|
18
18
|
def change
|
|
19
19
|
create_table :active_record_machine2s do |t|
|
|
@@ -62,11 +62,11 @@ describe Eventful do
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
it "must have successfully extended the receiver class with Stateful methods" do
|
|
65
|
-
machine2.class.methods.include?(:stateful_states).must_equal true
|
|
65
|
+
_(machine2.class.methods.include?(:stateful_states)).must_equal true
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
it "must have successfully extended the receiver class with Eventful methods" do
|
|
69
|
-
machine2.class.methods.include?(:active).must_equal true
|
|
69
|
+
_(machine2.class.methods.include?(:active)).must_equal true
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
context "only an_event? is true" do
|
|
@@ -89,22 +89,22 @@ describe Eventful do
|
|
|
89
89
|
|
|
90
90
|
it "must know which instances are active (ie. not in a final state)" do
|
|
91
91
|
machine2.current_state
|
|
92
|
-
ActiveRecordMachine2.active.size.must_equal 1
|
|
92
|
+
_(ActiveRecordMachine2.active.size).must_equal 1
|
|
93
93
|
end
|
|
94
94
|
|
|
95
95
|
it "must know whether an event has occurred" do
|
|
96
|
-
machine2.an_event
|
|
96
|
+
_(machine2.an_event?).must_equal true
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "must know whether an event has not occurred" do
|
|
100
|
-
machine2.another_event
|
|
101
|
-
machine2.yet_another_event
|
|
100
|
+
_(machine2.another_event?).must_equal false
|
|
101
|
+
_(machine2.yet_another_event?).must_equal false
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it "must automatically trigger state changes" do
|
|
105
105
|
machine2.current_state
|
|
106
106
|
ActiveRecordMachine2.run
|
|
107
|
-
machine2.reload.current_state.name.must_equal :another_state
|
|
107
|
+
_(machine2.reload.current_state.name).must_equal :another_state
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
@@ -128,22 +128,22 @@ describe Eventful do
|
|
|
128
128
|
|
|
129
129
|
it "must know which instances are active (ie. not in a final state)" do
|
|
130
130
|
machine2.current_state
|
|
131
|
-
ActiveRecordMachine2.active.size.must_equal 1
|
|
131
|
+
_(ActiveRecordMachine2.active.size).must_equal 1
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it "must know whether an event has occurred" do
|
|
135
|
-
machine2.an_event
|
|
136
|
-
machine2.another_event
|
|
135
|
+
_(machine2.an_event?).must_equal true
|
|
136
|
+
_(machine2.another_event?).must_equal true
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
it "must know whether an event has not occurred" do
|
|
140
|
-
machine2.yet_another_event
|
|
140
|
+
_(machine2.yet_another_event?).must_equal false
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
it "must automatically trigger state changes" do
|
|
144
144
|
machine2.current_state
|
|
145
145
|
2.times{ActiveRecordMachine2.run}
|
|
146
|
-
machine2.reload.current_state.name.must_equal :yet_another_state
|
|
146
|
+
_(machine2.reload.current_state.name).must_equal :yet_another_state
|
|
147
147
|
end
|
|
148
148
|
end
|
|
149
149
|
|
|
@@ -170,7 +170,7 @@ describe Eventful do
|
|
|
170
170
|
ActiveRecordMachine2.run(2, 10) # Run every 2 seconds for not more than 10 seconds.
|
|
171
171
|
finish_time = Time.now
|
|
172
172
|
run_time = finish_time - start_time
|
|
173
|
-
run_time.must_be_close_to 10, 0.1
|
|
173
|
+
_(run_time).must_be_close_to 10, 0.1
|
|
174
174
|
end
|
|
175
175
|
end
|
|
176
176
|
|
data/test/Poro.rb
CHANGED
|
@@ -33,11 +33,11 @@ describe Eventful do
|
|
|
33
33
|
let(:machine){Machine.active.first || Machine.new}
|
|
34
34
|
|
|
35
35
|
it "must have successfully extended the receiver class with Stateful methods" do
|
|
36
|
-
machine.class.methods.include?(:stateful_states).must_equal true
|
|
36
|
+
_(machine.class.methods.include?(:stateful_states)).must_equal true
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "must have successfully extended the receiver class with Eventful methods" do
|
|
40
|
-
machine.class.methods.include?(:active).must_equal true
|
|
40
|
+
_(machine.class.methods.include?(:active)).must_equal true
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
context "only an_event? is true" do
|
|
@@ -59,22 +59,22 @@ describe Eventful do
|
|
|
59
59
|
|
|
60
60
|
it "must know which instances are active (ie. not in a final state)" do
|
|
61
61
|
machine
|
|
62
|
-
Machine.active.size.must_equal 1
|
|
62
|
+
_(Machine.active.size).must_equal 1
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "must know whether an event has occurred" do
|
|
66
|
-
machine.an_event
|
|
66
|
+
_(machine.an_event?).must_equal true
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
it "must know whether an event has not occurred" do
|
|
70
|
-
machine.another_event
|
|
71
|
-
machine.yet_another_event
|
|
70
|
+
_(machine.another_event?).must_equal false
|
|
71
|
+
_(machine.yet_another_event?).must_equal false
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "must automatically trigger state changes" do
|
|
75
75
|
machine
|
|
76
76
|
Machine.run
|
|
77
|
-
machine.current_state.name.must_equal :next_state
|
|
77
|
+
_(machine.current_state.name).must_equal :next_state
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -97,22 +97,22 @@ describe Eventful do
|
|
|
97
97
|
|
|
98
98
|
it "must know which instances are active (ie. not in a final state)" do
|
|
99
99
|
machine
|
|
100
|
-
Machine.active.size.must_equal 1
|
|
100
|
+
_(Machine.active.size).must_equal 1
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "must know whether an event has occurred" do
|
|
104
|
-
machine.an_event
|
|
105
|
-
machine.yet_another_event
|
|
104
|
+
_(machine.an_event?).must_equal true
|
|
105
|
+
_(machine.yet_another_event?).must_equal true
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it "must know whether an event has not occurred" do
|
|
109
|
-
machine.another_event
|
|
109
|
+
_(machine.another_event?).must_equal false
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
it "must automatically trigger state changes" do
|
|
113
113
|
machine.current_state = :next_state
|
|
114
114
|
Machine.run
|
|
115
|
-
machine.current_state.name.must_equal :final_state
|
|
115
|
+
_(machine.current_state.name).must_equal :final_state
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
@@ -138,7 +138,7 @@ describe Eventful do
|
|
|
138
138
|
Machine.run(2, 10) # Run every 2 seconds for not more than 10 seconds.
|
|
139
139
|
finish_time = Time.now
|
|
140
140
|
run_time = finish_time - start_time
|
|
141
|
-
run_time.must_be_close_to 10, 0.1
|
|
141
|
+
_(run_time).must_be_close_to 10, 0.1
|
|
142
142
|
end
|
|
143
143
|
end
|
|
144
144
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eventful.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: stateful.rb
|
|
@@ -57,14 +57,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
57
57
|
requirements:
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
|
-
version:
|
|
60
|
+
version: '2.5'
|
|
61
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
requirements:
|
|
63
63
|
- - ">="
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
65
|
version: '0'
|
|
66
66
|
requirements: []
|
|
67
|
-
rubygems_version:
|
|
67
|
+
rubygems_version: 4.0.9
|
|
68
68
|
specification_version: 4
|
|
69
69
|
summary: Automatically change state with Stateful state machines.
|
|
70
70
|
test_files: []
|