eight_ball 2.1.0 → 2.2.0

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: cfb41f3a25afd43037e59c1a38078ccc708eabae72b07e298f120e6aee0264be
4
- data.tar.gz: f92d80db7fa985f68fe3050a65351586445487fdb9b07122f844c4f76becd991
3
+ metadata.gz: 521486fba75fc1996224ec260d22ed00860955da71941256452cb910adb3539d
4
+ data.tar.gz: 2c905caa109755024226a5ae088c9731ee7349930e423bf76a5d96de057e2b2c
5
5
  SHA512:
6
- metadata.gz: a8551c6bc776407190501c1c284f7c0487f96960028bf1e42d7facd98d6545047ea643bbb2ca387e676479c846508ccff55b2e44e64f01e2f1dac0e62292374b
7
- data.tar.gz: 81e40138cc534dab592c5847c30221a0b557c2d02598fe8eb53173d65f00316e085381c1b149934cd7bf969c37517d445bad55c5d38241518ade1d2c1607caa3
6
+ metadata.gz: b9265bc7abf5060158f14ba9b42e9945a618fc4fb94c6f97b946228927fa37f8638fc5e9f014340aa4e03698edf00df39d24f3ef58bd2087dda0f15162ea59a3
7
+ data.tar.gz: c55f4e5fc008e92bc1b70a6c5d02efe5af600c59834aa35bbf850ccab0fd2d89c427ee16ca1931bc781009e4cc57b0ed6ac358f8632d81f55520d0aac0dccddc
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.0]
4
+ - Add `==` to `Feature` and `Conditions`
5
+
3
6
  ## [2.1.0]
4
7
  - Add `features` parameter to `EightBall.marshall` to allow marshalling any Features, not just the ones
5
8
  from the configured Provider.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eight_ball (2.1.0)
4
+ eight_ball (2.2.0)
5
5
  awrence (~> 1.1)
6
6
  plissken (~> 1.2)
7
7
 
@@ -12,8 +12,21 @@ module EightBall::Conditions
12
12
  raise 'You can never satisfy the Base condition'
13
13
  end
14
14
 
15
+ def ==(other)
16
+ other.class == self.class && other.state == state
17
+ end
18
+ alias eql? ==
19
+
20
+ def hash
21
+ state.hash
22
+ end
23
+
15
24
  protected
16
25
 
26
+ def state
27
+ [@parameter]
28
+ end
29
+
17
30
  def parameter=(parameter)
18
31
  return if parameter.nil?
19
32
 
@@ -31,5 +31,11 @@ module EightBall::Conditions
31
31
  def satisfied?(value)
32
32
  values.include? value
33
33
  end
34
+
35
+ protected
36
+
37
+ def state
38
+ super + [@values.sort]
39
+ end
34
40
  end
35
41
  end
@@ -44,5 +44,11 @@ module EightBall::Conditions
44
44
  def satisfied?(value)
45
45
  value >= min && value <= max
46
46
  end
47
+
48
+ protected
49
+
50
+ def state
51
+ super + [@min, @max]
52
+ end
47
53
  end
48
54
  end
@@ -48,6 +48,15 @@ module EightBall
48
48
  any_satisfied?(@enabled_for, parameters) && !any_satisfied?(@disabled_for, parameters)
49
49
  end
50
50
 
51
+ def ==(other)
52
+ name == other.name &&
53
+ enabled_for.size == other.enabled_for.size &&
54
+ enabled_for.all? { |condition| other.enabled_for.any? { |other_condition| condition == other_condition } } &&
55
+ disabled_for.size == other.disabled_for.size &&
56
+ disabled_for.all? { |condition| other.disabled_for.any? { |other_condition| condition == other_condition } }
57
+ end
58
+ alias eql? ==
59
+
51
60
  private
52
61
 
53
62
  def any_satisfied?(conditions, parameters)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EightBall
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eight_ball
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rewind.io
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awrence