rulz 1.0.2 → 1.0.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: 681be360b37e47b3422574c47c04c713f88443b9
4
- data.tar.gz: 2a32bd493a9f486cc679f3c4429dc507d44be2eb
3
+ metadata.gz: de63333148931a63988610e1ac333419a3e6f1fe
4
+ data.tar.gz: a26e35c475f09dc16c2159d0e95249d53d274e6d
5
5
  SHA512:
6
- metadata.gz: 923a43fe955a88fb484061c238189e3650a1b59f931de4cfc7de5350372db8ef534b75d241fbf16de7ffad76243cb2686443cabc510a8bd5b71b6195c9b8c794
7
- data.tar.gz: bf1c4f7fb180282a743ea87ff3cda4f39f16dcd197243e3180779c33f3d27d22d46ec2a68c7f232ca1b585e75c83c340af787584ba071bf0e60577ec662080a8
6
+ metadata.gz: acf732fcdb41c69d99b1d94f14fd13e3db579b665053f678c4453bcb50381658ec4b5781026d3eb936bc5ff48566c80f7185aebfd210d9e1762cf26c769210a5
7
+ data.tar.gz: 2a0b0b54739038dafa7332d0337a17578e957b10205f34b234b760200a6e205dec17364f24a50d8f58516ce6e791f6a3e32bd42d9f1af069f29574c1aabfe867
@@ -4,6 +4,7 @@ require "rulz/condition"
4
4
  require "rulz/evaluator"
5
5
  require "rulz/action"
6
6
  require "rulz/rule"
7
+ require "rulz/conditions/boolean"
7
8
  require "rulz/conditions/comparison"
8
9
  require "rulz/conditions/container"
9
10
  require "rulz/conditions/string"
@@ -0,0 +1,33 @@
1
+ module Rulz
2
+ module Conditions
3
+ module Boolean
4
+ def self.load_conditions(reciever, attr)
5
+ reciever.class_eval do
6
+ define_rulz do
7
+ attribute attr do
8
+ condition "true" do
9
+ send(attr)
10
+ end
11
+ condition "false" do
12
+ opposite_of "true"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.included(base)
20
+ base.class_eval do
21
+ define_rulz do
22
+ condition "true" do
23
+ it
24
+ end
25
+ condition "false" do
26
+ opposite_of "true"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -6,13 +6,20 @@ module Rulz
6
6
  Comparison.load_conditions(reciever, attribute)
7
7
  when :float
8
8
  Comparison.load_conditions(reciever, attribute)
9
+ when :decimal
10
+ Comparison.load_conditions(reciever, attribute)
9
11
  when :string
10
12
  Container.load_conditions(reciever, attribute)
11
13
  String.load_conditions(reciever, attribute)
14
+ when :text
15
+ Container.load_conditions(reciever, attribute)
16
+ String.load_conditions(reciever, attribute)
12
17
  when :array
13
18
  Container.load_conditions(reciever, attribute)
14
19
  when :hash
15
20
  Container.load_conditions(reciever, attribute)
21
+ when :boolean
22
+ Boolean.load_conditions(reciever, attribute)
16
23
  end
17
24
  end
18
25
  end
@@ -18,6 +18,12 @@ module Rulz
18
18
  condition "not like" do |other|
19
19
  opposite_of "like", other
20
20
  end
21
+ condition "equals" do |other|
22
+ send(attr) == other
23
+ end
24
+ condition "does not equal" do |other|
25
+ opposite_of "equal to", other
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -27,6 +33,12 @@ module Rulz
27
33
  base.class_eval do
28
34
  include Rulz::Conditions::Container
29
35
  define_rulz do
36
+ condition "equals" do |other|
37
+ send(attr) == other
38
+ end
39
+ condition "does not equal" do |other|
40
+ opposite_of "equal to", other
41
+ end
30
42
  condition "does not match" do |regex|
31
43
  it.scan(regex).empty?
32
44
  end
@@ -1,3 +1,3 @@
1
1
  module Rulz
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -58,6 +58,15 @@ describe "condition" do
58
58
  include Rulz::Conditions::String
59
59
  include Rulz::Conditions::Comparison
60
60
  end
61
+ class TrueClass
62
+ include Rulz
63
+ include Rulz::Conditions::Boolean
64
+ end
65
+ class FalseClass
66
+ include Rulz
67
+ include Rulz::Conditions::Boolean
68
+ end
69
+
61
70
  end
62
71
 
63
72
  it "should recognize contains" do
@@ -104,7 +113,17 @@ describe "condition" do
104
113
  "a".condition_true?("less than", "b").should be_true
105
114
  "b".condition_true?("less than", "a").should be_false
106
115
  end
107
-
116
+
117
+ it "should recognize true" do
118
+ true.condition_true?("true").should be_true
119
+ false.condition_true?("true").should be_false
120
+ end
121
+
122
+ it "should recognize false" do
123
+ false.condition_true?("false").should be_true
124
+ true.condition_true?("false").should be_false
125
+ end
126
+
108
127
  end
109
128
 
110
129
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rulz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chase Conklin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ files:
85
85
  - lib/rulz/action.rb
86
86
  - lib/rulz/attribute.rb
87
87
  - lib/rulz/condition.rb
88
+ - lib/rulz/conditions/boolean.rb
88
89
  - lib/rulz/conditions/comparison.rb
89
90
  - lib/rulz/conditions/conditions.rb
90
91
  - lib/rulz/conditions/container.rb
@@ -118,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  requirements: []
120
121
  rubyforge_project:
121
- rubygems_version: 2.0.2
122
+ rubygems_version: 2.0.3
122
123
  signing_key:
123
124
  specification_version: 4
124
125
  summary: Enables users to create mail-like rules for processing Ruby objects.