simple_state_machine 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cf708bed33ca00037b1fbb2562b2a4c351666d82a4555b84078600b9e90ad03
4
- data.tar.gz: 251e24c03f5c59313aec334045670ed024c2720630c188d17bfed1eced1827be
3
+ metadata.gz: 03d0976fcf4c2dccd328f82cb00f8b5050f2cc052b578ae98d0227aca37afb5b
4
+ data.tar.gz: 193ae0211b9f82a386317032a2fe3ee245d263801cfab69981c3c6d9cfbe2053
5
5
  SHA512:
6
- metadata.gz: 482b1ba0a9e91260dfe56153453b636640dcd7c37916fd692e13d8607f59ee141d7161c9db6e9a50cdbb14b21b2895227129edf1c4f35dbcb733caceafeb8beb
7
- data.tar.gz: 5c3b05eb49e792a4289e85c5be1f10f9239020a0147e0ab5b617bba58d7fac4b727a47f45564c472e25e4079e8d1fb7d52838f9a8af9dd610a90e2580d6a9132
6
+ metadata.gz: 4e31fd218c64886a4e5fba9334d4b5b71c9bdcbc1fd3216df488a3edc25d6d9a846336887c700623c84b401fc89a6a4afdaa02a0a7ad0d7e3e9456c6bcfdba2e
7
+ data.tar.gz: 4659c64c0b4422967418ca9289ce97e259defd2c4bcbd621e51e37422b2d036b2c8bede71b8b59c97a81137aa076a11403d47c6de2231314272b611b0d7cc08a
data/Changelog.rdoc CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.6.1
2
+ - Run against latest rubies and activerecord
3
+ - Remove old rubygems version requirement
4
+ - Remove some trailing whitespace [Petrik]
5
+ - Use `expect` instead if old `should` notation [Petrik]
6
+ - Drop support for Ruby 1.9 [Petrik]
7
+
1
8
  == 0.6.0
2
9
  === Enhancements
3
10
  - Define decorated methods as #{event_name}_with_managed_state instead of with_managed_state_#{event_name} [Petrik]
@@ -1,3 +1,3 @@
1
1
  module SimpleStateMachine
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_state_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek de Heus
@@ -20,27 +20,10 @@ extra_rdoc_files:
20
20
  - LICENSE
21
21
  - README.rdoc
22
22
  files:
23
- - ".github/workflows/build.yml"
24
- - ".gitignore"
25
- - ".rspec"
26
- - ".travis.yml"
27
23
  - Changelog.rdoc
28
- - Gemfile
29
24
  - LICENSE
30
25
  - README.rdoc
31
- - Rakefile
32
- - examples/conversation.rb
33
- - examples/lamp.rb
34
- - examples/relationship.rb
35
- - examples/traffic_light.rb
36
- - examples/user.rb
37
- - gemfiles/Gemfile.activerecord-5.2.x
38
- - gemfiles/Gemfile.activerecord-6.0.x
39
- - gemfiles/Gemfile.activerecord-6.1.x
40
- - gemfiles/Gemfile.activerecord-main.x
41
- - gemfiles/Gemfile.basic
42
26
  - lib/simple_state_machine.rb
43
- - lib/simple_state_machine/.DS_Store
44
27
  - lib/simple_state_machine/active_record.rb
45
28
  - lib/simple_state_machine/decorator/active_record.rb
46
29
  - lib/simple_state_machine/decorator/default.rb
@@ -54,18 +37,6 @@ files:
54
37
  - lib/simple_state_machine/transition.rb
55
38
  - lib/simple_state_machine/version.rb
56
39
  - lib/tasks/graphviz.rake
57
- - simple_state_machine.gemspec
58
- - spec/.DS_Store
59
- - spec/active_record_spec.rb
60
- - spec/decorator/default_spec.rb
61
- - spec/examples_spec.rb
62
- - spec/mountable_spec.rb
63
- - spec/simple_state_machine_spec.rb
64
- - spec/spec_helper.rb
65
- - spec/state_machine_definition_spec.rb
66
- - spec/state_machine_spec.rb
67
- - spec/tools/graphviz_spec.rb
68
- - spec/tools/inspector_spec.rb
69
40
  homepage: http://github.com/mdh/ssm
70
41
  licenses: []
71
42
  metadata: {}
@@ -89,14 +60,4 @@ rubygems_version: 3.1.6
89
60
  signing_key:
90
61
  specification_version: 4
91
62
  summary: A simple DSL to decorate existing methods with logic that guards state transitions.
92
- test_files:
93
- - spec/active_record_spec.rb
94
- - spec/decorator/default_spec.rb
95
- - spec/examples_spec.rb
96
- - spec/mountable_spec.rb
97
- - spec/simple_state_machine_spec.rb
98
- - spec/spec_helper.rb
99
- - spec/state_machine_definition_spec.rb
100
- - spec/state_machine_spec.rb
101
- - spec/tools/graphviz_spec.rb
102
- - spec/tools/inspector_spec.rb
63
+ test_files: []
@@ -1,46 +0,0 @@
1
- name: Build
2
- on:
3
- - push
4
- - pull_request
5
-
6
- jobs:
7
- build:
8
- name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
9
- if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
10
- strategy:
11
- fail-fast: false
12
- matrix:
13
- ruby:
14
- - "3.0"
15
- - "2.7"
16
- - "2.6"
17
- - "2.5"
18
- rails:
19
- - "5.2"
20
- - "6.0"
21
- - "6.1"
22
- - main
23
- exclude:
24
- - ruby: 2.5
25
- rails: main
26
- - ruby: 2.6
27
- rails: main
28
- - ruby: 3.0
29
- rails: "5.1"
30
- - ruby: 3.0
31
- rails: "5.2"
32
-
33
- runs-on: 'ubuntu-latest'
34
-
35
- env:
36
- BUNDLE_GEMFILE: gemfiles/Gemfile.activerecord-${{ matrix.rails }}.x
37
-
38
- steps:
39
- - uses: actions/checkout@v2
40
- - uses: ruby/setup-ruby@v1
41
- with:
42
- ruby-version: ${{ matrix.ruby }}
43
- - name: Setup project
44
- run: bundle install
45
- - name: Run test
46
- run: bundle exec rspec spec
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.swp
2
- .bundle
3
- .ruby-version
4
- Gemfile.lock
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- #--debugger
3
- --backtrace
data/.travis.yml DELETED
@@ -1,17 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.5
4
- - 2.7
5
- - 3.0
6
- - jruby-9.2.16.0
7
- script: bundle exec rspec spec
8
-
9
- gemfile:
10
- - gemfiles/Gemfile.activerecord-6.0.x
11
- - gemfiles/Gemfile.activerecord-6.1.x
12
- - gemfiles/Gemfile.basic
13
-
14
- matrix:
15
- exclude:
16
- - rvm: jruby
17
- gemfile: gemfiles/Gemfile.activerecord-4.2.x
data/Gemfile DELETED
@@ -1,11 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- gemspec
5
-
6
- group :test do
7
- gem "rspec", "~> 3.0"
8
- gem "activerecord", ">= 5.2.0"
9
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
10
- gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
11
- end
data/Rakefile DELETED
@@ -1,28 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- #require 'spec/rake/spectask'
5
- #Spec::Rake::SpecTask.new(:spec) do |spec|
6
- # spec.libs << 'lib' << 'spec'
7
- # spec.spec_files = FileList['spec/**/*_spec.rb']
8
- #end
9
- #
10
- #Spec::Rake::SpecTask.new(:rcov) do |spec|
11
- # spec.libs << 'lib' << 'spec'
12
- # spec.pattern = 'spec/**/*_spec.rb'
13
- # spec.rcov = true
14
- #end
15
- #
16
- #task :spec => :check_dependencies
17
- #
18
- #task :default => :spec
19
-
20
- require 'rake/rdoctask'
21
- Rake::RDocTask.new do |rdoc|
22
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
23
-
24
- rdoc.rdoc_dir = 'rdoc'
25
- rdoc.title = "simple_state_machine #{version}"
26
- rdoc.rdoc_files.include('README*')
27
- rdoc.rdoc_files.include('lib/**/*.rb')
28
- end
@@ -1,33 +0,0 @@
1
- # Implementation of the AASM Conversation
2
- #
3
- # class Conversation
4
- # include AASM
5
- #
6
- # aasm_column :current_state # defaults to aasm_state
7
- #
8
- # aasm_initial_state :unread
9
- #
10
- # aasm_state :unread
11
- # aasm_state :read
12
- # aasm_state :closed
13
- #
14
- # aasm_event :view do
15
- # transitions :to => :read, :from => [:unread]
16
- # end
17
- #
18
- # aasm_event :close do
19
- # transitions :to => :closed, :from => [:read, :unread]
20
- # end
21
- # end
22
-
23
- class Conversation
24
- extend SimpleStateMachine
25
-
26
- def initialize
27
- self.state = 'unread'
28
- end
29
-
30
- event :view, :unread => :read
31
- event :close, :all => :closed
32
-
33
- end
data/examples/lamp.rb DELETED
@@ -1,21 +0,0 @@
1
- class Lamp
2
-
3
- extend SimpleStateMachine
4
-
5
- def initialize
6
- self.state = 'off'
7
- end
8
-
9
- def push_button1
10
- puts "click1: #{state}"
11
- end
12
- event :push_button1, :off => :on,
13
- :on => :off
14
-
15
- def push_button2
16
- puts "click2: #{state}"
17
- end
18
- event :push_button2, :off => :on,
19
- :on => :off
20
-
21
- end
@@ -1,87 +0,0 @@
1
- # Implementation of the AASM Conversation
2
- #
3
- # class Relationship
4
- # include AASM
5
- #
6
- # aasm_column :status
7
- #
8
- # aasm_initial_state Proc.new { |relationship| relationship.strictly_for_fun? ? :intimate : :dating }
9
- #
10
- # aasm_state :dating, :enter => :make_happy, :exit => :make_depressed
11
- # aasm_state :intimate, :enter => :make_very_happy, :exit => :never_speak_again
12
- # aasm_state :married, :enter => :give_up_intimacy, :exit => :buy_exotic_car_and_wear_a_combover
13
- #
14
- # aasm_event :get_intimate do
15
- # transitions :to => :intimate, :from => [:dating], :guard => :drunk?
16
- # end
17
- #
18
- # aasm_event :get_married do
19
- # transitions :to => :married, :from => [:dating, :intimate], :guard => :willing_to_give_up_manhood?
20
- # end
21
- #
22
- # def strictly_for_fun?; end
23
- # def drunk?; end
24
- # def willing_to_give_up_manhood?; end
25
- # def make_happy; end
26
- # def make_depressed; end
27
- # def make_very_happy; end
28
- # def never_speak_again; end
29
- # def give_up_intimacy; end
30
- # def buy_exotic_car_and_wear_a_combover; end
31
- # end
32
-
33
- class Relationship
34
- extend SimpleStateMachine
35
-
36
- def initialize
37
- self.state = relationship.strictly_for_fun? ? get_intimate : start_dating
38
- end
39
-
40
- def start_dating
41
- make_happy
42
- # make_depressed not called on exit
43
- end
44
- event :start_dating, nil => :dating
45
-
46
- def get_intimate
47
- # exit if drunk?
48
- make_very_happy
49
- # never_speak_again not called on exit
50
- end
51
- event :get_intimate, :dating => :intimate
52
-
53
- def get_married
54
- give_up_intimacy
55
- #exit unless willing_to_give_up_manhood?
56
- # buy_exotic_car_and_wear_a_combover not called on exit
57
- end
58
- event :get_married, :dating => :married,
59
- :intimate => :married
60
-
61
- # extra event added
62
- def stop_dating
63
- make_depressed
64
- end
65
- event :stop_dating, :dating => nil
66
-
67
- def dump
68
- never_speak_again
69
- end
70
- event :dump, :intimate => :dump
71
-
72
- def divorce
73
- buy_exotic_car_and_wear_a_combover
74
- end
75
- event :divorce, :married => :divorced
76
-
77
-
78
- def strictly_for_fun?; end
79
- def drunk?; end
80
- def willing_to_give_up_manhood?; end
81
- def make_happy; end
82
- def make_depressed; end
83
- def make_very_happy; end
84
- def never_speak_again; end
85
- def give_up_intimacy; end
86
- def buy_exotic_car_and_wear_a_combover; end
87
- end
@@ -1,17 +0,0 @@
1
- class TrafficLight
2
-
3
- extend SimpleStateMachine
4
-
5
- def initialize
6
- self.state = 'green'
7
- end
8
-
9
- # state machine events
10
- def change_state
11
- puts "#{state} => #{@next_state}"
12
- end
13
-
14
- event :change_state, :green => :orange,
15
- :orange => :red,
16
- :red => :green
17
- end
data/examples/user.rb DELETED
@@ -1,41 +0,0 @@
1
- require 'digest/sha1'
2
- class User < ActiveRecord::Base
3
-
4
- validates_presence_of :name
5
-
6
- extend SimpleStateMachine::ActiveRecord
7
-
8
- after_initialize :after_initialize
9
- def after_initialize
10
- self.state ||= 'new'
11
- # if you get an ActiveRecord::MissingAttributeError
12
- # you'll probably need to do (http://bit.ly/35q23b):
13
- # write_attribute(:ssm_state, "pending") unless read_attribute(:ssm_state)
14
- end
15
-
16
- def invite
17
- self.activation_code = Digest::SHA1.hexdigest("salt #{Time.now.to_f}")
18
- send_activation_email(self.activation_code)
19
- end
20
- event :invite, :new => :invited
21
-
22
- def confirm_invitation activation_code
23
- if self.activation_code != activation_code
24
- errors.add 'activation_code', 'is invalid'
25
- end
26
- end
27
- event :confirm_invitation, :invited => :active
28
-
29
- #event :log_send_activation_code_failed, :new => :send_activation_code_failed
30
- #
31
- # def reset_password(new_password)
32
- # self.password = new_password
33
- # end
34
- # # do not change state, but ensure that we are in proper state
35
- # event :reset_password, :active => :active
36
-
37
- def send_activation_email(code)
38
- true
39
- end
40
-
41
- end
@@ -1,9 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- group :test do
5
- gem "rspec"
6
- gem "activerecord", "~>5.2.0"
7
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
8
- gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
9
- end
@@ -1,9 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- group :test do
5
- gem "rspec"
6
- gem "activerecord", "~>6.0.0"
7
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
8
- gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
9
- end
@@ -1,8 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- group :test do
5
- gem "rspec"
6
- gem "activerecord", "~>6.1.0"
7
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
8
- end
@@ -1,9 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- group :test do
5
- gem "rspec"
6
- gem "activerecord", git: "https://github.com/rails/rails.git", branch: "main"
7
- gem "sqlite3", :platform => [:ruby, :mswin, :mingw]
8
- gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
9
- end
@@ -1,6 +0,0 @@
1
- # A sample Gemfile
2
- source "http://rubygems.org"
3
-
4
- group :test do
5
- gem "rspec"
6
- end
Binary file
@@ -1,21 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "simple_state_machine/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = %q{simple_state_machine}
7
- s.version = SimpleStateMachine::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Marek de Heus", "Petrik de Heus"]
10
- s.description = %q{A simple DSL to decorate existing methods with state transition guards.}
11
- s.email = ["FIX@example.com"]
12
- s.homepage = %q{http://github.com/mdh/ssm}
13
- s.extra_rdoc_files = ["LICENSE","README.rdoc"]
14
- s.files = `git ls-files`.split("\n")
15
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
- s.rdoc_options = ["--charset=UTF-8"]
17
- s.require_paths = ["lib"]
18
- s.summary = %q{A simple DSL to decorate existing methods with logic that guards state transitions.}
19
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
- end
21
-
data/spec/.DS_Store DELETED
Binary file