array_logic 0.0.6 → 0.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.
- data/README.rdoc +5 -6
- data/lib/array_logic/rule.rb +2 -2
- data/lib/array_logic/version.rb +1 -1
- data/lib/example.rb +2 -4
- data/test/array_logic/rule_test.rb +6 -0
- metadata +8 -8
data/README.rdoc
CHANGED
@@ -10,13 +10,13 @@ The logic for an active record model Answer, looks like this:
|
|
10
10
|
....
|
11
11
|
a5 = Answer.find(5)
|
12
12
|
|
13
|
-
rule_one
|
13
|
+
rule_one = ArrayLogic::Rule.new "(a1 and a2) or (a3 and a4)"
|
14
14
|
|
15
|
-
rule_two
|
15
|
+
rule_two = ArrayLogic::Rule.new "a1 and not a2"
|
16
16
|
|
17
|
-
rule_three
|
17
|
+
rule_three = ArrayLogic::Rule.new "2 in a1 a2 a3"
|
18
18
|
|
19
|
-
rule_four
|
19
|
+
rule_four = ArrayLogic::Rule.new "(2 in a1 a2 a3) and (1 in a4 a5)"
|
20
20
|
|
21
21
|
|
22
22
|
rule_one rule_two rule_three rule_four
|
@@ -36,8 +36,7 @@ See test/array_logic/rule_test for more examples
|
|
36
36
|
Two methods allow you to determine sample combinations that match the current
|
37
37
|
rule.
|
38
38
|
|
39
|
-
rule = ArrayLogic::Rule.new
|
40
|
-
rule.rule = 'a1 and a2'
|
39
|
+
rule = ArrayLogic::Rule.new 'a1 and a2'
|
41
40
|
rule.matching_combinations --> [[1,2]]
|
42
41
|
rule.blocking_combinations --> [[1],[2]]
|
43
42
|
|
data/lib/array_logic/rule.rb
CHANGED
data/lib/array_logic/version.rb
CHANGED
data/lib/example.rb
CHANGED
@@ -9,8 +9,7 @@ rule_sets = [
|
|
9
9
|
|
10
10
|
rule_sets.each do |rule_set|
|
11
11
|
|
12
|
-
rule = ArrayLogic::Rule.new
|
13
|
-
rule.rule = rule_set
|
12
|
+
rule = ArrayLogic::Rule.new(rule_set)
|
14
13
|
|
15
14
|
puts "----------------------------\n"
|
16
15
|
puts "The rule '#{rule_set}' would match the following:"
|
@@ -26,8 +25,7 @@ end
|
|
26
25
|
|
27
26
|
or_rule = (1..12).to_a.collect{|n| "t#{n}"}.join(" or ")
|
28
27
|
|
29
|
-
rule = ArrayLogic::Rule.new
|
30
|
-
rule.rule = or_rule
|
28
|
+
rule = ArrayLogic::Rule.new or_rule
|
31
29
|
|
32
30
|
require 'benchmark'
|
33
31
|
|
@@ -269,6 +269,12 @@ module ArrayLogic
|
|
269
269
|
@rule.rule = 't1'
|
270
270
|
assert_equal([], @rule.blocking_combinations)
|
271
271
|
end
|
272
|
+
|
273
|
+
def test_assigning_rule_on_creation
|
274
|
+
text = 'a1 and a2'
|
275
|
+
rule = Rule.new(text)
|
276
|
+
assert_equal(text, rule.rule)
|
277
|
+
end
|
272
278
|
|
273
279
|
end
|
274
280
|
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
|
+
version: 0.1.0
|
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-
|
12
|
+
date: 2012-12-12 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.
|
@@ -19,17 +19,17 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
-
- lib/array_logic
|
22
|
+
- lib/array_logic.rb
|
23
23
|
- lib/array_logic/thing.rb
|
24
|
+
- lib/array_logic/version.rb
|
24
25
|
- lib/array_logic/rule.rb
|
25
|
-
- lib/array_logic.rb
|
26
26
|
- lib/example.rb
|
27
27
|
- MIT-LICENSE
|
28
28
|
- Rakefile
|
29
29
|
- README.rdoc
|
30
|
-
- test/array_logic/test_case.rb
|
31
|
-
- test/array_logic/rule_test.rb
|
32
30
|
- test/array_logic/thing_test.rb
|
31
|
+
- test/array_logic/rule_test.rb
|
32
|
+
- test/array_logic/test_case.rb
|
33
33
|
homepage: https://github.com/reggieb/array_logic
|
34
34
|
licenses: []
|
35
35
|
post_install_message:
|
@@ -55,6 +55,6 @@ signing_key:
|
|
55
55
|
specification_version: 3
|
56
56
|
summary: Matches arrays of objects against logical rules.
|
57
57
|
test_files:
|
58
|
-
- test/array_logic/test_case.rb
|
59
|
-
- test/array_logic/rule_test.rb
|
60
58
|
- test/array_logic/thing_test.rb
|
59
|
+
- test/array_logic/rule_test.rb
|
60
|
+
- test/array_logic/test_case.rb
|