tsubaki 0.2.0 → 0.2.1
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 +3 -3
- data/lib/tsubaki/matchers/validate_corporate_number_of_matcher.rb +10 -10
- data/lib/tsubaki/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6c8b5daa3f8151cfd170d4f2fba3c99468fa188
|
4
|
+
data.tar.gz: 5f854b1fa68205a6769b5f0e3eec30dc8ebf3e7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e0c97c7450741ef6915fb58711ef2cbe39725c9d0b6beea1215dc74ea81340abb78e00fed658a47f420a89e65076827adeaaec42c4263c2e4934b9f71a18891
|
7
|
+
data.tar.gz: 0f4bcd0366c3ad18316bf566e20b279d7e86dd1bcb8e4317d473740bca971cf68a618343a2fdaaa649c6c1a4a1a9ba8355e310897349f16a15913cf56c5622ee
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ To validate the format of an attribute, add the following to your model:
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
# Verifies the format and its check digit with `strict` option:
|
36
|
-
validates :digits, my_number: { strict: true
|
36
|
+
validates :digits, my_number: { strict: true, allow_blank: true }
|
37
37
|
|
38
38
|
# Without strict option, it verifies only the length of the digits:
|
39
39
|
validates :digits, my_number: true
|
@@ -50,7 +50,7 @@ To validate the format of an attribute, add the following to your model:
|
|
50
50
|
|
51
51
|
```ruby
|
52
52
|
# Verifies the format and its check digit with `strict` option:
|
53
|
-
validates :digits, corporate_number: { strict: true
|
53
|
+
validates :digits, corporate_number: { strict: true, allow_blank: true }
|
54
54
|
|
55
55
|
# Without strict option, it verifies only the length of the digits:
|
56
56
|
validates :digits, corporate_number: true
|
@@ -83,7 +83,7 @@ describe User do
|
|
83
83
|
it { should validate_my_number_of(:digits) }
|
84
84
|
|
85
85
|
# To ensure options:
|
86
|
-
it { should validate_validate_my_number_of(:digits).strict.with_divider('-').
|
86
|
+
it { should validate_validate_my_number_of(:digits).strict.with_divider('-').allow_blank }
|
87
87
|
end
|
88
88
|
|
89
89
|
describe Company do
|
@@ -19,7 +19,7 @@ module Tsubaki
|
|
19
19
|
@options = {}
|
20
20
|
@options[:strict] = nil
|
21
21
|
@options[:divider] = nil
|
22
|
-
@options[:
|
22
|
+
@options[:allow_blank] = nil
|
23
23
|
@failure_messages = []
|
24
24
|
self
|
25
25
|
end
|
@@ -39,7 +39,7 @@ module Tsubaki
|
|
39
39
|
result << " for #{@attribute_name}"
|
40
40
|
result << ' with strict mode' if @options[:strict].present?
|
41
41
|
result << " with divider '#{@options[:divider]}'" if @options[:divider].present?
|
42
|
-
result << ' and allow
|
42
|
+
result << ' and allow blank' if @options[:allow_blank].present?
|
43
43
|
result
|
44
44
|
end
|
45
45
|
|
@@ -53,19 +53,19 @@ module Tsubaki
|
|
53
53
|
self
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
@options[:
|
56
|
+
def allow_blank(allow_blank = true)
|
57
|
+
@options[:allow_blank] = allow_blank
|
58
58
|
self
|
59
59
|
end
|
60
60
|
|
61
61
|
protected
|
62
62
|
|
63
63
|
def error_when_not_valid
|
64
|
-
[
|
64
|
+
[error_test_allow_blank, error_test_strict, error_test_divider, error_test]
|
65
65
|
end
|
66
66
|
|
67
67
|
def no_error_when_valid
|
68
|
-
[
|
68
|
+
[no_error_test_allow_blank, no_error_test_strict, no_error_test_divider, no_error_test]
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
@@ -77,7 +77,7 @@ module Tsubaki
|
|
77
77
|
dup_subject.errors[@attribute_name].blank?
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
80
|
+
def error_test_allow_blank
|
81
81
|
true
|
82
82
|
end
|
83
83
|
|
@@ -115,11 +115,11 @@ module Tsubaki
|
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
-
def
|
119
|
-
return true if @options[:
|
118
|
+
def no_error_test_allow_blank
|
119
|
+
return true if @options[:allow_blank].nil?
|
120
120
|
|
121
121
|
if !valid_attribute_with?(nil)
|
122
|
-
@failure_messages << '
|
122
|
+
@failure_messages << 'allow_blank is not be specified'
|
123
123
|
false
|
124
124
|
else
|
125
125
|
true
|
data/lib/tsubaki/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsubaki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kakipo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|