chillout 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/lib/chillout.rb +1 -0
- data/lib/chillout/integrations/state_machine.rb +90 -0
- data/lib/chillout/railtie.rb +15 -1
- data/lib/chillout/version.rb +1 -1
- data/test/acceptance/client_sends_state_machine_metrics_test.rb +45 -0
- data/test/support/rails_4_0_0/Gemfile +1 -0
- data/test/support/rails_4_0_0/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_4_0_0/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_4_0_0/app/models/entity.rb +35 -1
- data/test/support/rails_4_0_0/config/routes.rb +1 -0
- data/test/support/rails_4_0_0/db/schema.rb +2 -0
- data/test/support/rails_4_0_13/Gemfile +1 -0
- data/test/support/rails_4_0_13/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_4_0_13/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_4_0_13/app/models/entity.rb +35 -1
- data/test/support/rails_4_0_13/config/routes.rb +1 -0
- data/test/support/rails_4_0_13/db/schema.rb +2 -0
- data/test/support/rails_4_1_0/Gemfile +1 -0
- data/test/support/rails_4_1_0/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_4_1_0/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_4_1_0/app/models/entity.rb +35 -1
- data/test/support/rails_4_1_0/config/initializers/state_machine_integration_hack.rb +3 -0
- data/test/support/rails_4_1_0/config/routes.rb +1 -0
- data/test/support/rails_4_1_0/db/schema.rb +2 -0
- data/test/support/rails_4_1_16/Gemfile +2 -1
- data/test/support/rails_4_1_16/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_4_1_16/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_4_1_16/app/jobs/create_entity_job.rb +1 -1
- data/test/support/rails_4_1_16/app/models/entity.rb +35 -1
- data/test/support/rails_4_1_16/config/initializers/state_machine_integration_hack.rb +3 -0
- data/test/support/rails_4_1_16/config/routes.rb +1 -0
- data/test/support/rails_4_1_16/db/schema.rb +2 -0
- data/test/support/rails_4_2_0/Gemfile +2 -1
- data/test/support/rails_4_2_0/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_4_2_0/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_4_2_0/app/jobs/create_entity_job.rb +1 -1
- data/test/support/rails_4_2_0/app/models/entity.rb +35 -1
- data/test/support/rails_4_2_0/config/initializers/state_machine_integration_hack.rb +3 -0
- data/test/support/rails_4_2_0/config/routes.rb +1 -0
- data/test/support/rails_4_2_0/db/schema.rb +2 -0
- data/test/support/rails_4_2_8/Gemfile +7 -1
- data/test/support/rails_4_2_8/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_4_2_8/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_4_2_8/app/jobs/create_entity_job.rb +1 -1
- data/test/support/rails_4_2_8/app/models/entity.rb +35 -1
- data/test/support/rails_4_2_8/config/initializers/state_machine_integration_hack.rb +3 -0
- data/test/support/rails_4_2_8/config/routes.rb +1 -0
- data/test/support/rails_4_2_8/db/schema.rb +2 -0
- data/test/support/rails_5_0_3/Gemfile +7 -1
- data/test/support/rails_5_0_3/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_5_0_3/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_5_0_3/app/jobs/create_entity_job.rb +1 -1
- data/test/support/rails_5_0_3/app/models/entity.rb +35 -1
- data/test/support/rails_5_0_3/config/initializers/state_machine_integration_hack.rb +3 -0
- data/test/support/rails_5_0_3/config/routes.rb +1 -0
- data/test/support/rails_5_0_3/db/schema.rb +2 -0
- data/test/support/rails_5_1_1/Gemfile +6 -0
- data/test/support/rails_5_1_1/app/controllers/entities_controller.rb +1 -1
- data/test/support/rails_5_1_1/app/controllers/transitions_controller.rb +8 -0
- data/test/support/rails_5_1_1/app/jobs/create_entity_job.rb +1 -1
- data/test/support/rails_5_1_1/app/models/application_record.rb +3 -0
- data/test/support/rails_5_1_1/app/models/entity.rb +35 -1
- data/test/support/rails_5_1_1/app/models/user.rb +2 -0
- data/test/support/rails_5_1_1/config/routes.rb +2 -1
- data/test/support/rails_5_1_1/db/schema.rb +2 -0
- data/test/test_helper.rb +19 -3
- metadata +36 -3
@@ -15,6 +15,8 @@ ActiveRecord::Schema.define(:version => 20130103115400) do
|
|
15
15
|
|
16
16
|
create_table "entities", :force => true do |t|
|
17
17
|
t.string "name"
|
18
|
+
t.string "state"
|
19
|
+
t.string "seatbelt"
|
18
20
|
t.datetime "created_at", :null => false
|
19
21
|
t.datetime "updated_at", :null => false
|
20
22
|
end
|
@@ -1,2 +1,36 @@
|
|
1
1
|
class Entity < ActiveRecord::Base
|
2
|
-
|
2
|
+
state_machine :initial => :parked do
|
3
|
+
before_transition :parked => any - :parked, do: :put_on_seatbelt
|
4
|
+
after_transition any => :parked do |vehicle, _transition|
|
5
|
+
vehicle.seatbelt = 'off'
|
6
|
+
end
|
7
|
+
around_transition :benchmark
|
8
|
+
|
9
|
+
event :ignite do
|
10
|
+
transition :parked => :idling
|
11
|
+
end
|
12
|
+
|
13
|
+
event :shift_up do
|
14
|
+
transition :idling => :first_gear,
|
15
|
+
:first_gear => :second_gear,
|
16
|
+
:second_gear => :third_gear
|
17
|
+
end
|
18
|
+
|
19
|
+
state :first_gear, :second_gear do
|
20
|
+
validates_presence_of :seatbelt_on
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def put_on_seatbelt
|
25
|
+
sleep(0.1)
|
26
|
+
self.seatbelt = 'on'
|
27
|
+
end
|
28
|
+
|
29
|
+
def benchmark
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
|
33
|
+
def seatbelt_on
|
34
|
+
self.seatbelt == 'on'
|
35
|
+
end
|
36
|
+
end
|
@@ -15,6 +15,8 @@ ActiveRecord::Schema.define(:version => 20130103115400) do
|
|
15
15
|
|
16
16
|
create_table "entities", :force => true do |t|
|
17
17
|
t.string "name"
|
18
|
+
t.string "state"
|
19
|
+
t.string "seatbelt"
|
18
20
|
t.datetime "created_at", :null => false
|
19
21
|
t.datetime "updated_at", :null => false
|
20
22
|
end
|
@@ -1,2 +1,36 @@
|
|
1
1
|
class Entity < ActiveRecord::Base
|
2
|
-
|
2
|
+
state_machine :initial => :parked do
|
3
|
+
before_transition :parked => any - :parked, do: :put_on_seatbelt
|
4
|
+
after_transition any => :parked do |vehicle, _transition|
|
5
|
+
vehicle.seatbelt = 'off'
|
6
|
+
end
|
7
|
+
around_transition :benchmark
|
8
|
+
|
9
|
+
event :ignite do
|
10
|
+
transition :parked => :idling
|
11
|
+
end
|
12
|
+
|
13
|
+
event :shift_up do
|
14
|
+
transition :idling => :first_gear,
|
15
|
+
:first_gear => :second_gear,
|
16
|
+
:second_gear => :third_gear
|
17
|
+
end
|
18
|
+
|
19
|
+
state :first_gear, :second_gear do
|
20
|
+
validates_presence_of :seatbelt_on
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def put_on_seatbelt
|
25
|
+
sleep(0.1)
|
26
|
+
self.seatbelt = 'on'
|
27
|
+
end
|
28
|
+
|
29
|
+
def benchmark
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
|
33
|
+
def seatbelt_on
|
34
|
+
self.seatbelt == 'on'
|
35
|
+
end
|
36
|
+
end
|
@@ -15,6 +15,8 @@ ActiveRecord::Schema.define(:version => 20130103115400) do
|
|
15
15
|
|
16
16
|
create_table "entities", :force => true do |t|
|
17
17
|
t.string "name"
|
18
|
+
t.string "state"
|
19
|
+
t.string "seatbelt"
|
18
20
|
t.datetime "created_at", :null => false
|
19
21
|
t.datetime "updated_at", :null => false
|
20
22
|
end
|
@@ -3,4 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'rails', '4.2.8'
|
4
4
|
gem 'sqlite3'
|
5
5
|
gem 'chillout', :path => '../../../'
|
6
|
-
gem "sidekiq", ENV['SIDEKIQ_VERSION'] || ">= 5"
|
6
|
+
gem "sidekiq", ENV['SIDEKIQ_VERSION'] || ">= 5"
|
7
|
+
if ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
8
|
+
gem "state_machines-activerecord", ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
9
|
+
gem "state_machines", ENV['STATE_MACHINES_VERSION'] || ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
10
|
+
else
|
11
|
+
gem "state_machine", ENV['STATE_MACHINE_VERSION'] || ">= 1.2"
|
12
|
+
end
|
@@ -1,2 +1,36 @@
|
|
1
1
|
class Entity < ActiveRecord::Base
|
2
|
-
|
2
|
+
state_machine :initial => :parked do
|
3
|
+
before_transition :parked => any - :parked, do: :put_on_seatbelt
|
4
|
+
after_transition any => :parked do |vehicle, _transition|
|
5
|
+
vehicle.seatbelt = 'off'
|
6
|
+
end
|
7
|
+
around_transition :benchmark
|
8
|
+
|
9
|
+
event :ignite do
|
10
|
+
transition :parked => :idling
|
11
|
+
end
|
12
|
+
|
13
|
+
event :shift_up do
|
14
|
+
transition :idling => :first_gear,
|
15
|
+
:first_gear => :second_gear,
|
16
|
+
:second_gear => :third_gear
|
17
|
+
end
|
18
|
+
|
19
|
+
state :first_gear, :second_gear do
|
20
|
+
validates_presence_of :seatbelt_on
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def put_on_seatbelt
|
25
|
+
sleep(0.1)
|
26
|
+
self.seatbelt = 'on'
|
27
|
+
end
|
28
|
+
|
29
|
+
def benchmark
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
|
33
|
+
def seatbelt_on
|
34
|
+
self.seatbelt == 'on'
|
35
|
+
end
|
36
|
+
end
|
@@ -15,6 +15,8 @@ ActiveRecord::Schema.define(:version => 20130103115400) do
|
|
15
15
|
|
16
16
|
create_table "entities", :force => true do |t|
|
17
17
|
t.string "name"
|
18
|
+
t.string "state"
|
19
|
+
t.string "seatbelt"
|
18
20
|
t.datetime "created_at", :null => false
|
19
21
|
t.datetime "updated_at", :null => false
|
20
22
|
end
|
@@ -3,4 +3,10 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'rails', '5.0.3'
|
4
4
|
gem 'sqlite3'
|
5
5
|
gem 'chillout', :path => '../../../'
|
6
|
-
gem "sidekiq", ENV['SIDEKIQ_VERSION'] || ">= 5"
|
6
|
+
gem "sidekiq", ENV['SIDEKIQ_VERSION'] || ">= 5"
|
7
|
+
if ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
8
|
+
gem "state_machines-activerecord", ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
9
|
+
gem "state_machines", ENV['STATE_MACHINES_VERSION'] || ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
10
|
+
else
|
11
|
+
gem "state_machine", ENV['STATE_MACHINE_VERSION'] || ">= 1.2"
|
12
|
+
end
|
@@ -1,2 +1,36 @@
|
|
1
1
|
class Entity < ActiveRecord::Base
|
2
|
-
|
2
|
+
state_machine :initial => :parked do
|
3
|
+
before_transition :parked => any - :parked, do: :put_on_seatbelt
|
4
|
+
after_transition any => :parked do |vehicle, _transition|
|
5
|
+
vehicle.seatbelt = 'off'
|
6
|
+
end
|
7
|
+
around_transition :benchmark
|
8
|
+
|
9
|
+
event :ignite do
|
10
|
+
transition :parked => :idling
|
11
|
+
end
|
12
|
+
|
13
|
+
event :shift_up do
|
14
|
+
transition :idling => :first_gear,
|
15
|
+
:first_gear => :second_gear,
|
16
|
+
:second_gear => :third_gear
|
17
|
+
end
|
18
|
+
|
19
|
+
state :first_gear, :second_gear do
|
20
|
+
validates_presence_of :seatbelt_on
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def put_on_seatbelt
|
25
|
+
sleep(0.1)
|
26
|
+
self.seatbelt = 'on'
|
27
|
+
end
|
28
|
+
|
29
|
+
def benchmark
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
|
33
|
+
def seatbelt_on
|
34
|
+
self.seatbelt == 'on'
|
35
|
+
end
|
36
|
+
end
|
@@ -15,6 +15,8 @@ ActiveRecord::Schema.define(:version => 20130103115400) do
|
|
15
15
|
|
16
16
|
create_table "entities", :force => true do |t|
|
17
17
|
t.string "name"
|
18
|
+
t.string "state"
|
19
|
+
t.string "seatbelt"
|
18
20
|
t.datetime "created_at", :null => false
|
19
21
|
t.datetime "updated_at", :null => false
|
20
22
|
end
|
@@ -4,3 +4,9 @@ gem 'rails', '5.1.1'
|
|
4
4
|
gem 'sqlite3'
|
5
5
|
gem 'chillout', :path => '../../../'
|
6
6
|
gem "sidekiq", ENV['SIDEKIQ_VERSION'] || ">= 5"
|
7
|
+
if ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
8
|
+
gem "state_machines-activerecord", ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
9
|
+
gem "state_machines", ENV['STATE_MACHINES_VERSION'] || ENV['STATE_MACHINES_ACTIVERECORD_VERSION']
|
10
|
+
else
|
11
|
+
gem "state_machine", ENV['STATE_MACHINE_VERSION'] || ">= 1.2"
|
12
|
+
end
|