state_machina 0.1.5 → 0.1.6

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: 31ba09ef350378e653c3f7c99c3ade469cdb2da45bffebd2669ab7e61e316a8c
4
- data.tar.gz: 97b54c53c83db2dbc0fe7e25664b0feb98ef7b82b7c8a5ad5dde536aaba24f8f
3
+ metadata.gz: dafbf3b6c0e98deba3f63e96af9dc514736a486e1c899ef3160085141c987a95
4
+ data.tar.gz: c243f44bf6bc3c1fed703a8233ad9afe8f712081b946a7f72e3a227d621e0567
5
5
  SHA512:
6
- metadata.gz: 1edbdd79a822c472e7eadb77869c68282c467f36602a323214170af7690dce27e18dec9b53f821690f47a65c7a189fb4441d1df8ed48301e96b05c855a71ea63
7
- data.tar.gz: ed5e069229f0b4c8d6abae3fe050a97b73066a784b6abfe94d2e37a940a8b86f5cf4251fa1e6a9d632ad16af9743675e06c6b0e081a8566a41347459e08f7f1b
6
+ metadata.gz: 685b1a4811ba9ce5949ade06712bb1381c88d4cec75d8677b125797e5095abc8b1de51f089450ac5e2cc335e829a2431251cf8f43924ca1fde074eee8b258360
7
+ data.tar.gz: b6c32281cef34382ad98b978c9f2df9204b96e15e2ffea630fd3dabd8a88ff63a1b53944549f63a24d7a17fb20626a7a1ef2ddb36eb84635dd68b13a761f57ff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- state_machina (0.1.5)
4
+ state_machina (0.1.6)
5
5
  concurrent-ruby (< 2)
6
6
 
7
7
  GEM
@@ -19,11 +19,12 @@ module StateMachina
19
19
  end
20
20
 
21
21
  def transitions
22
- transitions = StateMachina::Registry.find_transitions(model_name, machine_name, name)
22
+ transitions = StateMachina::Registry.find_transitions(model_name, machine_name, name).map(&:dup)
23
23
  transitions.each do |transition|
24
24
  transition.machine = machine
25
25
  transition.guard_context = guard_context
26
26
  end
27
+
27
28
  transitions
28
29
  end
29
30
 
@@ -32,9 +33,7 @@ module StateMachina
32
33
  end
33
34
 
34
35
  def resolve_to_transition
35
- transitions.find do |transition|
36
- transition.possible? && transition.permitted?
37
- end
36
+ transitions.find(&:permitted?)
38
37
  end
39
38
 
40
39
  def possible?
@@ -47,7 +47,7 @@ module StateMachina
47
47
  def machine(machine_name = 'default')
48
48
  model_name = StateMachina::Util.normalized_klass_to_name(self.class)
49
49
 
50
- machine = StateMachina::Registry.find_machine!(model_name, machine_name)
50
+ machine = StateMachina::Registry.find_machine!(model_name, machine_name).dup
51
51
  machine.model = self
52
52
  machine
53
53
  end
@@ -58,7 +58,7 @@ module StateMachina
58
58
  def machines
59
59
  model_name = StateMachina::Util.normalized_klass_to_name(self.class)
60
60
 
61
- machines = StateMachina::Registry.find_machines(model_name)
61
+ machines = StateMachina::Registry.find_machines(model_name).map(&:dup)
62
62
  machines.map do |machine|
63
63
  machine.model = self
64
64
  machine
@@ -23,7 +23,7 @@ module StateMachina
23
23
  end
24
24
 
25
25
  def states
26
- states = StateMachina::Registry.find_states(model_name, name).values
26
+ states = StateMachina::Registry.find_states(model_name, name).values.map(&:dup)
27
27
  states.each do |state|
28
28
  state.machine = self
29
29
  end
@@ -32,7 +32,7 @@ module StateMachina
32
32
  end
33
33
 
34
34
  def events(possible: false, permitted: false, guard_context: model)
35
- events = StateMachina::Registry.find_events(model_name, name).values
35
+ events = StateMachina::Registry.find_events(model_name, name).values.map(&:dup)
36
36
  events.each do |event|
37
37
  event.machine = self
38
38
  event.guard_context = guard_context
@@ -14,7 +14,7 @@ module StateMachina
14
14
 
15
15
  def self.register_machine(machine)
16
16
  machines[machine.model_name] ||= {}
17
- machines[machine.model_name][machine.name] = machine
17
+ machines[machine.model_name][machine.name] = machine.freeze
18
18
 
19
19
  machine
20
20
  end
@@ -30,7 +30,7 @@ module StateMachina
30
30
  def self.register_state(state)
31
31
  states[state.model_name] ||= {}
32
32
  states[state.model_name][state.machine_name] ||= {}
33
- states[state.model_name][state.machine_name][state.name] = state
33
+ states[state.model_name][state.machine_name][state.name] = state.freeze
34
34
 
35
35
  state
36
36
  end
@@ -46,7 +46,7 @@ module StateMachina
46
46
  def self.register_event(event)
47
47
  events[event.model_name] ||= {}
48
48
  events[event.model_name][event.machine_name] ||= {}
49
- events[event.model_name][event.machine_name][event.name] = event
49
+ events[event.model_name][event.machine_name][event.name] = event.freeze
50
50
 
51
51
  event
52
52
  end
@@ -63,7 +63,7 @@ module StateMachina
63
63
  transitions[transition.model_name] ||= {}
64
64
  transitions[transition.model_name][transition.machine_name] ||= {}
65
65
  transitions[transition.model_name][transition.machine_name][transition.event_name] ||= []
66
- transitions[transition.model_name][transition.machine_name][transition.event_name].append(transition)
66
+ transitions[transition.model_name][transition.machine_name][transition.event_name].append(transition.freeze)
67
67
 
68
68
  transition
69
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StateMachina
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/state_machina/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "state_machina"
7
+ spec.version = StateMachina::VERSION
8
+ spec.authors = ["Jan van der Pas"]
9
+ spec.email = ["jan.vanderpas@beequip.nl"]
10
+
11
+ spec.summary = "State machine supporting multiple machines per object"
12
+ # spec.description = "TODO: Write a longer description or delete this line."
13
+ # spec.homepage = "TODO: Put your gem's website or public repo URL here."
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ # spec.metadata["homepage_uri"] = spec.homepage
20
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "concurrent-ruby", "< 2"
35
+ spec.add_development_dependency "pry", "< 0.15"
36
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan van der Pas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-29 00:00:00.000000000 Z
11
+ date: 2024-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -68,6 +68,7 @@ files:
68
68
  - lib/state_machina/util.rb
69
69
  - lib/state_machina/version.rb
70
70
  - sig/state_machina.rbs
71
+ - state_machina.gemspec
71
72
  homepage:
72
73
  licenses:
73
74
  - MIT