array_logic 0.0.4 → 0.0.5

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.
@@ -33,7 +33,7 @@ module ArrayLogic
33
33
 
34
34
  def object_ids_used
35
35
  chrs_after_first = 1..-1
36
- objects_identifiers_in_rule.collect{|i| i[chrs_after_first].to_i}
36
+ objects_identifiers_in_rule.collect{|i| i[chrs_after_first].to_i}.uniq
37
37
  end
38
38
 
39
39
  def combinations_that_match
@@ -1,3 +1,3 @@
1
1
  module ArrayLogic
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -227,6 +227,11 @@ module ArrayLogic
227
227
  assert_equal([1, 2, 3, 4], @rule.object_ids_used)
228
228
  end
229
229
 
230
+ def test_object_ids_user_does_not_return_duplicates
231
+ @rule.rule = 't1 and t2 and (2 in t1 t2)'
232
+ assert_equal([1, 2], @rule.object_ids_used)
233
+ end
234
+
230
235
  def test_combinations_that_match
231
236
  @rule.rule = 't1 or t2'
232
237
  assert_equal([[1], [2], [1,2]], @rule.combinations_that_match)
@@ -241,6 +246,11 @@ module ArrayLogic
241
246
  assert_nil(@rule.combinations_that_match, "combinations_that_match should return nil if the rule is blank")
242
247
  end
243
248
 
249
+ def test_combinations_that_match_with_duplicate_ids
250
+ @rule.rule = 't1 and t2 and (2 in t1 t2)'
251
+ assert_equal(1, @rule.combinations_that_match.length, "should not identify combinations for both occurancies of each id")
252
+ end
253
+
244
254
  def test_combinations_that_do_not_match
245
255
  @rule.rule = 't1 or t2'
246
256
  assert_equal([], @rule.combinations_that_do_not_match)
@@ -259,6 +269,6 @@ module ArrayLogic
259
269
  @rule.rule = 't1'
260
270
  assert_equal([], @rule.combinations_that_do_not_match)
261
271
  end
262
-
272
+
263
273
  end
264
274
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: array_logic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-28 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Allow a user to define a set of rules, and then test to see if an array
15
15
  of object match those rules.