juncture 0.1.2 → 0.1.3

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: bc76c4cc245934c24f3e67dec255cb33949d16ba
4
- data.tar.gz: 5f49ebd01f47ec182ae9af2f4041f904b7584562
3
+ metadata.gz: 1f28a15579970e84b17cd602610f67d1aa1fb0fe
4
+ data.tar.gz: ced8f397144e95be239664b175790d463aa96dc1
5
5
  SHA512:
6
- metadata.gz: d97a227a484135fa8309a04d720d03733d0bbe67eec4b0b93232932b3be830ed61c93ab686cf9602a3965f5d777221abed1dae9700148bc54c01dbf4b3c284c9
7
- data.tar.gz: 8170557309b5875213a0de13fc3bc429a542a93367cb09e4855fefb478441e3f3358250aa3694ecc4d6f1ea80358eebeb3c74135ba72e9eb148fa03eae7024db
6
+ metadata.gz: 6bb89d966c61a680c1ee2510b921d4961f430a813b9a19f50420c6df11088c05c20d9c3334951089209c06e03eb37a4ea11818c3efd11fff14ed66d12f78e526
7
+ data.tar.gz: 1da2fb3916a43f6799c87dbaa1d6b3ae29f77bdb944d14589f85cba60ec4814d47019efabc0c99dfc7abe90afdf0bae1953945e082b04a001c4fb5a99d2ec54d
@@ -1,4 +1,4 @@
1
1
  class Juncture
2
- VERSION = "0.1.2".freeze
2
+ VERSION = "0.1.3".freeze
3
3
  DATE = "2014-02-04".freeze
4
4
  end
data/lib/juncture.rb CHANGED
@@ -44,24 +44,24 @@ class Juncture
44
44
  end
45
45
 
46
46
  def <(value)
47
- @states[(index+1)..-1].include? value
47
+ index < index(value)
48
48
  end
49
49
 
50
50
  def <=(value)
51
- @states[index..-1].include? value
51
+ index <= index(value)
52
52
  end
53
53
 
54
54
  def >(value)
55
- @states[0..(index-1)].include? value
55
+ index > index(value)
56
56
  end
57
57
 
58
58
  def >=(value)
59
- @states[0..index].include? value
59
+ index >= index(value)
60
60
  end
61
61
 
62
62
  private
63
63
 
64
- def index
65
- @states.index(@current_state)
64
+ def index value = @current_state
65
+ @states.index(value) || @states[0]
66
66
  end
67
67
  end
@@ -6,177 +6,177 @@ describe Juncture do
6
6
  end
7
7
 
8
8
  describe '::new' do
9
- it 'creates a new instance of Juncture' do
10
- expect(Juncture.new []).to be_an_instance_of Juncture
11
- end
9
+ it 'creates a new instance of Juncture' do
10
+ expect(Juncture.new []).to be_an_instance_of Juncture
11
+ end
12
12
  end
13
13
 
14
14
  describe '#inspect' do
15
- it 'returns the Juncture object' do
16
- expect(Juncture.new([]).inspect).to match(/<Juncture:\S+ State:\S*>/)
17
- end
15
+ it 'returns the Juncture object' do
16
+ expect(Juncture.new([]).inspect).to match(/<Juncture:\S+ State:\S*>/)
17
+ end
18
18
  end
19
19
 
20
20
  describe '#state' do
21
- it 'returns the current state' do
22
- temp = Juncture.new 1, 2, 3
23
- expect(temp.state).to be_nil
24
- end
25
-
26
- it 'returns the default state' do
27
- temp = Juncture.new 1, 2, 3, default: 1
28
- expect(temp.state).to eq 1
29
- end
21
+ it 'returns the current state' do
22
+ temp = Juncture.new :first, :second, :third
23
+ expect(temp.state).to be_nil
24
+ end
25
+
26
+ it 'returns the default state' do
27
+ temp = Juncture.new :first, :second, :third, default: :first
28
+ expect(temp.state).to eq :first
29
+ end
30
30
  end
31
31
 
32
32
  describe '#set' do
33
- it 'sets the current state' do
34
- temp = Juncture.new 1, 2, 3
35
- temp.set 1
36
- expect(temp.state).to eq 1
37
- end
38
-
39
- it 'raises an error if the state is not present' do
40
- temp = Juncture.new 1, 2, 3
41
- expect{ temp.set 4 }.to raise_error
42
- end
33
+ it 'sets the current state' do
34
+ temp = Juncture.new :first, :second, :third
35
+ temp.set :first
36
+ expect(temp.state).to eq :first
37
+ end
38
+
39
+ it 'raises an error if the state is not present' do
40
+ temp = Juncture.new :first, :second, :third
41
+ expect{ temp.set :fourth }.to raise_error
42
+ end
43
43
  end
44
44
 
45
45
  describe '#next' do
46
46
  it 'moves the state forward one step' do
47
- temp = Juncture.new 1, 2, 3, default: 1
48
- expect(temp.next).to eq 2
49
- expect(temp.state).to eq 2
50
- expect(temp.next).to eq 3
51
- expect(temp.state).to eq 3
47
+ temp = Juncture.new :first, :second, :third, default: :first
48
+ expect(temp.next).to eq :second
49
+ expect(temp.state).to eq :second
50
+ expect(temp.next).to eq :third
51
+ expect(temp.state).to eq :third
52
52
  end
53
53
 
54
54
  it 'resets if on final state' do
55
- temp = Juncture.new 1, 2, 3, default: 2
56
- expect(temp.next).to eq 3
57
- expect(temp.state).to eq 3
58
- expect(temp.next).to eq 1
59
- expect(temp.state).to eq 1
55
+ temp = Juncture.new :first, :second, :third, default: :second
56
+ expect(temp.next).to eq :third
57
+ expect(temp.state).to eq :third
58
+ expect(temp.next).to eq :first
59
+ expect(temp.state).to eq :first
60
60
  end
61
61
 
62
62
  it 'resets if default is nil' do
63
- temp = Juncture.new 1, 2, 3
64
- expect(temp.next).to eq 1
65
- expect(temp.state).to eq 1
66
- expect(temp.next).to eq 2
67
- expect(temp.state).to eq 2
63
+ temp = Juncture.new :first, :second, :third
64
+ expect(temp.next).to eq :first
65
+ expect(temp.state).to eq :first
66
+ expect(temp.next).to eq :second
67
+ expect(temp.state).to eq :second
68
68
  end
69
69
 
70
70
  it 'resets if default is not a state' do
71
- temp = Juncture.new 1, 2, 3, default: 4
72
- expect(temp.next).to eq 1
73
- expect(temp.state).to eq 1
74
- expect(temp.next).to eq 2
75
- expect(temp.state).to eq 2
71
+ temp = Juncture.new :first, :second, :third, default: 4
72
+ expect(temp.next).to eq :first
73
+ expect(temp.state).to eq :first
74
+ expect(temp.next).to eq :second
75
+ expect(temp.state).to eq :second
76
76
  end
77
77
  end
78
78
 
79
79
  describe '#==' do
80
80
  it 'returns true if matching' do
81
- temp = Juncture.new 1, 2, 3, default: 2
82
- expect(temp == 2).to be_true
81
+ temp = Juncture.new :first, :second, :third, default: :second
82
+ expect(temp == :second).to be_true
83
83
  end
84
84
 
85
85
  it 'returns false if not matching' do
86
- temp = Juncture.new 1, 2, 3, default: 2
87
- expect(temp == 1).to be_false
86
+ temp = Juncture.new :first, :second, :third, default: :second
87
+ expect(temp == :first).to be_false
88
88
  end
89
89
  end
90
90
 
91
91
  describe '#===' do
92
92
  it 'returns true if matching' do
93
- temp = Juncture.new 1, 2, 3, default: 2
94
- expect(temp === 2).to be_true
93
+ temp = Juncture.new :first, :second, :third, default: :second
94
+ expect(temp === :second).to be_true
95
95
  end
96
96
 
97
97
  it 'returns false if not matching' do
98
- temp = Juncture.new 1, 2, 3, default: 2
99
- expect(temp === 1).to be_false
98
+ temp = Juncture.new :first, :second, :third, default: :second
99
+ expect(temp === :first).to be_false
100
100
  end
101
101
  end
102
102
 
103
103
  describe '#<' do
104
104
  it 'returns true if matching' do
105
- temp = Juncture.new 1, 2, 3, default: 2
106
- expect(temp < 3).to be_true
105
+ temp = Juncture.new :first, :second, :third, default: :second
106
+ expect(temp < :third).to be_true
107
107
  end
108
108
 
109
109
  it 'returns false if not matching' do
110
- temp = Juncture.new 1, 2, 3, default: 2
111
- expect(temp < 2).to be_false
110
+ temp = Juncture.new :first, :second, :third, default: :second
111
+ expect(temp < :second).to be_false
112
112
  end
113
113
 
114
114
  it 'returns false if not matching' do
115
- temp = Juncture.new 1, 2, 3, default: 2
116
- expect(temp < 1).to be_false
115
+ temp = Juncture.new :first, :second, :third, default: :second
116
+ expect(temp < :first).to be_false
117
117
  end
118
118
  end
119
119
 
120
120
  describe '#<=' do
121
121
  it 'returns true if matching' do
122
- temp = Juncture.new 1, 2, 3, default: 2
123
- expect(temp <= 3).to be_true
122
+ temp = Juncture.new :first, :second, :third, default: :second
123
+ expect(temp <= :third).to be_true
124
124
  end
125
125
 
126
126
  it 'returns true if matching' do
127
- temp = Juncture.new 1, 2, 3, default: 2
128
- expect(temp <= 2).to be_true
127
+ temp = Juncture.new :first, :second, :third, default: :second
128
+ expect(temp <= :second).to be_true
129
129
  end
130
130
 
131
131
  it 'returns false if not matching' do
132
- temp = Juncture.new 1, 2, 3, default: 2
133
- expect(temp <= 1).to be_false
132
+ temp = Juncture.new :first, :second, :third, default: :second
133
+ expect(temp <= :first).to be_false
134
134
  end
135
135
  end
136
136
 
137
137
  describe '#>' do
138
138
  it 'returns true if matching' do
139
- temp = Juncture.new 1, 2, 3, default: 2
140
- expect(temp > 1).to be_true
139
+ temp = Juncture.new :first, :second, :third, default: :second
140
+ expect(temp > :first).to be_true
141
141
  end
142
142
 
143
143
  it 'returns false if not matching' do
144
- temp = Juncture.new 1, 2, 3, default: 2
145
- expect(temp > 2).to be_false
144
+ temp = Juncture.new :first, :second, :third, default: :second
145
+ expect(temp > :second).to be_false
146
146
  end
147
147
 
148
148
  it 'returns false if not matching' do
149
- temp = Juncture.new 1, 2, 3, default: 2
150
- expect(temp > 3).to be_false
149
+ temp = Juncture.new :first, :second, :third, default: :second
150
+ expect(temp > :third).to be_false
151
151
  end
152
152
  end
153
153
 
154
154
  describe '#>=' do
155
155
  it 'returns true if matching' do
156
- temp = Juncture.new 1, 2, 3, default: 2
157
- expect(temp >= 1).to be_true
156
+ temp = Juncture.new :first, :second, :third, default: :second
157
+ expect(temp >= :first).to be_true
158
158
  end
159
159
 
160
160
  it 'returns true if matching' do
161
- temp = Juncture.new 1, 2, 3, default: 2
162
- expect(temp >= 2).to be_true
161
+ temp = Juncture.new :first, :second, :third, default: :second
162
+ expect(temp >= :second).to be_true
163
163
  end
164
164
 
165
165
  it 'returns false if not matching' do
166
- temp = Juncture.new 1, 2, 3, default: 2
167
- expect(temp >= 3).to be_false
166
+ temp = Juncture.new :first, :second, :third, default: :second
167
+ expect(temp >= :third).to be_false
168
168
  end
169
169
  end
170
170
 
171
171
  describe '#method_missing' do
172
172
  it 'forards to the state array' do
173
- temp = Juncture.new 1, 2, 3, default: 2
174
- expect(temp[1]).to eq 2
173
+ temp = Juncture.new :first, :second, :third, default: :second
174
+ expect(temp[1]).to eq :second
175
175
  expect(temp.length).to eq 3
176
176
  end
177
177
 
178
178
  it 'raises an error to super' do
179
- temp = Juncture.new 1, 2, 3, default: 2
179
+ temp = Juncture.new :first, :second, :third, default: :second
180
180
  expect{ temp.no_response }.to raise_error
181
181
  end
182
182
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juncture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Slaughter