linear_work_flow 0.1.1 → 0.1.2

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: 9a443d34e42386dc16b0868bef778d1e656fca8c
4
- data.tar.gz: 10476e760bdb83cc72ee67a159ca44905e113a03
3
+ metadata.gz: 2b78df7b25c35a44cd5d7ffc564a66987dac0ad6
4
+ data.tar.gz: f5ea69804b59133f401afdb4375e5af07e8e5407
5
5
  SHA512:
6
- metadata.gz: 01186b7c858e17ffd03cf49c08eb7284c5a9dbedc58b0a424356285d858bab44fc06b4a085ba64f83aafa1f2b9f4a20557063731e1bbce28a8d88f949b90f2c7
7
- data.tar.gz: 95cda2b8de3322f4e487168753547a818d0699d7f1a593e5bd1e839f91e3582a5a82d9bba983afcfba389e417f25d1ccd65295e8429f8101bb9727a764175b6a
6
+ metadata.gz: 8e2a6cbf50ab336a69957c262e32246b1aa6fcafef54fefd3ee4e1af781cb1a7960b38cd9786d9c9dd89a2cf6c8ab166d02b7774c02453835dd7fafa94404ebd
7
+ data.tar.gz: 9c90a368283b5ac8099abd22e5704dc67a12b7eb22dfa225e81ab69bfcc82e3d9683c2f9793eac5c7a44294e3092cc21774255b97a68e07d8028613836029354
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.gem
data/README.md CHANGED
@@ -74,6 +74,32 @@ work_flow.first? == true
74
74
  work_flow.last? == false
75
75
  ```
76
76
 
77
+ ### Check permissible states
78
+
79
+ At any intermediate state the state can go back, go forward, or remain the same.
80
+ The `permissible_states` method returns the states that match these actions.
81
+
82
+ If the state is at the first state there cannot be a back transition, so in
83
+ this case `permissible_states` returns the current state and the go forward state.
84
+ Similarly, as the state cannot go forward from the last state, `permissible_states`
85
+ returns the go back state and the current state when the last state is the
86
+ current state.
87
+
88
+ ```ruby
89
+ work_flow = WorkFlow.new
90
+ work_flow.state == :one
91
+ work_flow.permissible_states == [:one, :two]
92
+ work_flow.forward!
93
+ work_flow.state == :two
94
+ work_flow.permissible_states == [:one, :two, :three]
95
+ work_flow.forward!
96
+ work_flow.state == :three
97
+ work_flow.permissible_states == [:two, :three, :four]
98
+ work_flow.forward!
99
+ work_flow.state == :four
100
+ work_flow.permissible_states == [:three, :four]
101
+ ```
102
+
77
103
  ### Initiate at a particular state
78
104
 
79
105
  A work flow can be initiate at a particular state.
@@ -1,3 +1,3 @@
1
1
  module LinearWorkFlow
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -40,6 +40,22 @@ module LinearWorkFlow
40
40
  index == 0
41
41
  end
42
42
 
43
+ def permissible_states
44
+ []
45
+ end
46
+
47
+ def forward_state
48
+ states[index + 1] unless last?
49
+ end
50
+
51
+ def back_state
52
+ states[index - 1] unless first?
53
+ end
54
+
55
+ def permissible_states
56
+ [back_state, state, forward_state].compact
57
+ end
58
+
43
59
  def can?(action)
44
60
  !!restore_after do
45
61
  begin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linear_work_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Nichols
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,7 +72,6 @@ files:
72
72
  - lib/linear_work_flow/errors.rb
73
73
  - lib/linear_work_flow/version.rb
74
74
  - lib/linear_work_flow/work_flow.rb
75
- - linear_work_flow-0.1.0.gem
76
75
  - linear_work_flow.gemspec
77
76
  homepage: https://github.com/reggieb/linear_work_flow
78
77
  licenses:
Binary file