daily_affirmation 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/daily_affirmation/process_affirmation_evaluator.rb +30 -5
- data/lib/daily_affirmation/version.rb +1 -1
- data/spec/daily_affirmation_spec.rb +17 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7ba5e00c6949914c9cfd4e9cbf88ccac79a0cb7
|
4
|
+
data.tar.gz: 7023bf3b10fbc9caa76c59553f899ba06f7f8580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f34c62e82ca717e3389d6afb7b2c54de266a754d5d33a2938e41c8d00111e3744e0bf7ebc96f7a799258428e2a6947ae1ccf7b64f50765f27572395b8de94c3
|
7
|
+
data.tar.gz: fc852275569a2b97e0ce079c63a93f2cd3a7b5ac147ec084e5ab92d992d0834bd153049cea77eb891192888674c59e11aea41dee6b9c0cecd51f279a52387561
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
[](https://gemnasium.com/teamsnap/daily_affirmation)
|
9
9
|
[](http://opensource.org/licenses/MIT)
|
10
10
|
|
11
|
-
[Documentation](http://www.rubydoc.info/
|
11
|
+
[Documentation](http://www.rubydoc.info/gems/daily_affirmation)
|
12
12
|
|
13
13
|
A simple library for external validations of POROs
|
14
14
|
|
@@ -6,7 +6,7 @@ class ProcessAffirmationEvaluator
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def process?
|
9
|
-
if_statement_passes? &&
|
9
|
+
if_statement_passes? && process_non_nil_value? && process_non_blank_value?
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -21,11 +21,36 @@ class ProcessAffirmationEvaluator
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
24
|
+
def process_non_blank_value?
|
25
|
+
!(allow_blank_values? && object_is_blank?)
|
26
|
+
end
|
27
|
+
|
28
|
+
def allow_blank_values?
|
29
|
+
args.include?(:allow_blank)
|
30
|
+
end
|
31
|
+
|
32
|
+
def object_is_blank?
|
33
|
+
blank?(object.send(attribute))
|
34
|
+
end
|
35
|
+
|
36
|
+
def blank?(val)
|
37
|
+
case val
|
38
|
+
when String
|
39
|
+
val !~ /[^[:space:]]/
|
27
40
|
else
|
28
|
-
|
41
|
+
val.respond_to?(:empty?) ? val.empty? : !val
|
29
42
|
end
|
30
43
|
end
|
44
|
+
|
45
|
+
def object_is_nil?
|
46
|
+
object.send(attribute).nil?
|
47
|
+
end
|
48
|
+
|
49
|
+
def allow_nil_values?
|
50
|
+
args.include?(:allow_nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
def process_non_nil_value?
|
54
|
+
!(allow_nil_values? && object_is_nil?)
|
55
|
+
end
|
31
56
|
end
|
@@ -154,6 +154,23 @@ describe DailyAffirmation do
|
|
154
154
|
expect(affirmation2).to_not be_valid
|
155
155
|
end
|
156
156
|
|
157
|
+
it "skips an affirmation for an :allow_blank option" do
|
158
|
+
cls = Class.new do
|
159
|
+
include DailyAffirmation.affirmations
|
160
|
+
|
161
|
+
affirms_inclusion_of :name, :list => ["name1"], :allow_blank => true
|
162
|
+
end
|
163
|
+
|
164
|
+
obj1 = double(:name => "")
|
165
|
+
obj2 = double(:name => "name2")
|
166
|
+
|
167
|
+
affirmation1 = cls.new(obj1)
|
168
|
+
affirmation2 = cls.new(obj2)
|
169
|
+
|
170
|
+
expect(affirmation1).to be_valid
|
171
|
+
expect(affirmation2).to_not be_valid
|
172
|
+
end
|
173
|
+
|
157
174
|
it "allows each affirmation to be inverted via an :inverse option" do
|
158
175
|
cls = Class.new do
|
159
176
|
include DailyAffirmation.affirmations
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daily_affirmation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Emmons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.4.6
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: A simple library for external validations of POROs
|