end_state 1.0.2 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2658b1366252a71619b0e67bb15f12858ab1dafe
4
- data.tar.gz: ddb735e643726468112e9c72d28fd7b73e83724b
3
+ metadata.gz: f58a215a5954fd5bb0cc3241fbfd788a42aa01f7
4
+ data.tar.gz: 1649c7a9404589b4c3fe167db290015849ebc085
5
5
  SHA512:
6
- metadata.gz: b6600b6e9ef3cdb6d25758dfb589814ce71bf448ca993273fa9a826a09b17be25e37c6b9522a48cd14c09107c69cd4d5218b637dde5e28cfcbb76a31b0dc5454
7
- data.tar.gz: be6865eacd6f30d9e44188d36215cadc5e3cc2050b1a2d483a3acb070ce098760a53ac5332da39ac52832c77c1ba81d8a8087d06b0ca1217617fc3e8ee6a22fd
6
+ metadata.gz: 963412f0c3548c8c1e2667aafb93ad956d094efca44095ae143fcedb0f6a7d211f8a70513f35ae100c98d49e130dc6b8233e1bd422ef6118b9db4715feca8d0a
7
+ data.tar.gz: 1fb665f112c2a43cb582a3e145530169a37ea09eaf495f62676130c36c2453af88fa8356d2d9b71b021d8374be46e419eb0543c87c79e237e991dacc01487f9d
@@ -1,8 +1,9 @@
1
1
  module EndState
2
- class Error < StandardError; end
3
- class UnknownState < Error; end
4
- class InvalidTransition < Error; end
5
- class GuardFailed < Error; end
6
- class ConcluderFailed < Error; end
7
- class EventConflict < Error; end
2
+ Error = Class.new(StandardError)
3
+ UnknownState = Class.new(Error)
4
+ InvalidTransition = Class.new(Error)
5
+ GuardFailed = Class.new(Error)
6
+ ConcluderFailed = Class.new(Error)
7
+ EventConflict = Class.new(Error)
8
+ MissingParams = Class.new(Error)
8
9
  end
@@ -18,7 +18,7 @@ module EndState
18
18
  end
19
19
 
20
20
  def allowed?(params={})
21
- raise "Missing params: #{missing_params(params).join(',')}" unless missing_params(params).empty?
21
+ return params_not_provided(missing_params(params)) unless missing_params(params).empty?
22
22
  guards.all? { |guard| guard.new(object, state, params).allowed? }
23
23
  end
24
24
 
@@ -42,6 +42,10 @@ module EndState
42
42
  failed ConcluderFailed, 'rolled back'
43
43
  end
44
44
 
45
+ def params_not_provided(params_list)
46
+ fail MissingParams, "Missing params: #{params_list.join(',')}"
47
+ end
48
+
45
49
  def conclude(params={})
46
50
  concluders.each_with_object([]) do |concluder, concluded|
47
51
  concluded << concluder
@@ -1,3 +1,3 @@
1
1
  module EndState
2
- VERSION = '1.0.2'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -213,7 +213,7 @@ module EndState
213
213
  let(:object) { OpenStruct.new(state: :c) }
214
214
 
215
215
  it 'blocks invalid events' do
216
- expect { machine.go! }.to raise_error
216
+ expect { machine.go! }.to raise_error(InvalidTransition)
217
217
  expect(machine.state).to eq :c
218
218
  end
219
219
  end
@@ -33,8 +33,8 @@ module EndState
33
33
  before { configuration.required_params = [:foo, :bar] }
34
34
 
35
35
  context 'and not all required are provided' do
36
- it 'throws an exception' do
37
- expect { transition.allowed? foo: 'something' }.to raise_error('Missing params: bar')
36
+ it 'raises MissingParams' do
37
+ expect { transition.allowed? foo: 'something' }.to raise_error(MissingParams, 'Missing params: bar')
38
38
  end
39
39
  end
40
40
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: end_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexpeachey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.4.6
152
+ rubygems_version: 2.4.8
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: A State Machine implementation