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 +4 -4
- data/lib/end_state/errors.rb +7 -6
- data/lib/end_state/transition.rb +5 -1
- data/lib/end_state/version.rb +1 -1
- data/spec/end_state/state_machine_spec.rb +1 -1
- data/spec/end_state/transition_spec.rb +2 -2
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f58a215a5954fd5bb0cc3241fbfd788a42aa01f7
         | 
| 4 | 
            +
              data.tar.gz: 1649c7a9404589b4c3fe167db290015849ebc085
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 963412f0c3548c8c1e2667aafb93ad956d094efca44095ae143fcedb0f6a7d211f8a70513f35ae100c98d49e130dc6b8233e1bd422ef6118b9db4715feca8d0a
         | 
| 7 | 
            +
              data.tar.gz: 1fb665f112c2a43cb582a3e145530169a37ea09eaf495f62676130c36c2453af88fa8356d2d9b71b021d8374be46e419eb0543c87c79e237e991dacc01487f9d
         | 
    
        data/lib/end_state/errors.rb
    CHANGED
    
    | @@ -1,8 +1,9 @@ | |
| 1 1 | 
             
            module EndState
         | 
| 2 | 
            -
               | 
| 3 | 
            -
               | 
| 4 | 
            -
               | 
| 5 | 
            -
               | 
| 6 | 
            -
               | 
| 7 | 
            -
               | 
| 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
         | 
    
        data/lib/end_state/transition.rb
    CHANGED
    
    | @@ -18,7 +18,7 @@ module EndState | |
| 18 18 | 
             
                end
         | 
| 19 19 |  | 
| 20 20 | 
             
                def allowed?(params={})
         | 
| 21 | 
            -
                   | 
| 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
         | 
    
        data/lib/end_state/version.rb
    CHANGED
    
    
| @@ -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 ' | 
| 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 | 
| 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- | 
| 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. | 
| 152 | 
            +
            rubygems_version: 2.4.8
         | 
| 153 153 | 
             
            signing_key: 
         | 
| 154 154 | 
             
            specification_version: 4
         | 
| 155 155 | 
             
            summary: A State Machine implementation
         |