scrivener 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a106b8c9aa9ba83fc66fec4afc4c030da9f25291
4
- data.tar.gz: d5918f87defb857d0870932c1914db935497aca8
3
+ metadata.gz: dc1f71859949ac9d78b3bc589d6d04ec70531240
4
+ data.tar.gz: 5bbd3d104350d6472cd03da0f18c1d90b6120dea
5
5
  SHA512:
6
- metadata.gz: 5afc2e5969db3a93670a20ede2992d3a1e095369d4407292bda46956f3d50fa8bc857d1dc9233adaf45fb044f99bdc672414fc0dc58655cc3ee1dc6d02295cd6
7
- data.tar.gz: cab3e3c0e586c192768ce7788359cfcb0fd36a8b8681f7097a5cd4deeeddf544fc0482fffba70e09cf3708dbee3b752c5726649c1c3e89ccd56a8e6eb6e2413e
6
+ metadata.gz: dd5c732af472a97cfdd34d0091fa9eab509d9121d57369b1197cd259e7f1bdb8a02c7fdccf7746cf753819b838a00c8b456d1e856192f1f80fc228ad2b2ce60f
7
+ data.tar.gz: 2117ae9707e937dfa06d4ae54b99b8a299dcb6ead0aca9ca14a354e05fd570706b065bb344a5896cf9aad9b1346d2bd7f85bfad8aca33008e8516e6547ad2dd9
data/README.md CHANGED
@@ -23,9 +23,7 @@ and its features are a subset of Bureaucrat's. For a more robust and tested
23
23
  solution, please [check it](https://github.com/tizoc/bureaucrat).
24
24
 
25
25
  This library exists to satify the need of extracting Ohm's validations for
26
- reuse in other scenarios. By doing this, all projects using `Ohm::Validations`
27
- will be able to profit from extra assertions such as those provided by
28
- [ohm-contrib](https://github.com/cyx/ohm-contrib).
26
+ reuse in other scenarios.
29
27
 
30
28
  Usage
31
29
  -----
@@ -60,7 +58,7 @@ body = "I am a rather elderly man..."
60
58
  article = Article.new(title: title, body: body)
61
59
 
62
60
  article.valid? #=> false
63
- article.errors.on(:state) #=> ["cannot be empty"]
61
+ article.errors[:state] #=> [:not_present]
64
62
  ```
65
63
 
66
64
  Of course, what you would do instead is declare `:title` and `:body` as allowed
@@ -1,7 +1,7 @@
1
1
  require_relative "scrivener/validations"
2
2
 
3
3
  class Scrivener
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
 
6
6
  include Validations
7
7
 
@@ -25,13 +25,6 @@ class Scrivener
25
25
  #
26
26
  # Other validations are simply added on a per-model or per-project basis.
27
27
  #
28
- # If you want other validations you may want to take a peek at Ohm::Contrib
29
- # and all of the validation modules it provides.
30
- #
31
- # @see http://cyx.github.com/ohm-contrib/doc/Ohm/WebValidations.html
32
- # @see http://cyx.github.com/ohm-contrib/doc/Ohm/NumberValidations.html
33
- # @see http://cyx.github.com/ohm-contrib/doc/Ohm/ExtraValidations.html
34
- #
35
28
  # @example
36
29
  #
37
30
  # class Quote
@@ -117,17 +110,14 @@ class Scrivener
117
110
  assert(!send(att).to_s.empty?, error)
118
111
  end
119
112
 
120
- # Checks if all the characters of an attribute is a digit. If you want to
121
- # verify that a value is a decimal, try looking at Ohm::Contrib's
122
- # assert_decimal assertion.
113
+ # Checks if all the characters of an attribute is a digit.
123
114
  #
124
115
  # @param [Symbol] att The attribute you wish to verify the numeric format.
125
116
  # @param [Array<Symbol, Symbol>] error The error that should be returned
126
117
  # when the validation fails.
127
- # @see http://cyx.github.com/ohm-contrib/doc/Ohm/NumberValidations.html
128
118
  def assert_numeric(att, error = [att, :not_numeric])
129
119
  if assert_present(att, error)
130
- assert_format(att, /\A\d+\z/, error)
120
+ assert_format(att, /\A\-?\d+\z/, error)
131
121
  end
132
122
  end
133
123
 
@@ -163,7 +153,7 @@ class Scrivener
163
153
  end
164
154
  end
165
155
 
166
- DECIMAL = /\A(\d+)?(\.\d+)?\z/
156
+ DECIMAL = /\A\-?(\d+)?(\.\d+)?\z/
167
157
 
168
158
  def assert_decimal(att, error = [att, :not_decimal])
169
159
  assert_format att, DECIMAL, error
@@ -193,7 +193,7 @@ scope do
193
193
  assert ! filter.valid?
194
194
  assert_equal [:not_decimal], filter.errors[:a]
195
195
 
196
- %w{10 10.1 10.100000 0.100000 .1000}.each do |a|
196
+ %w{10 10.1 10.100000 0.100000 .1000 -10}.each do |a|
197
197
  filter = G.new(a: a)
198
198
  assert filter.valid?
199
199
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-19 00:00:00.000000000 Z
11
+ date: 2014-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cutest
@@ -59,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.0.3
62
+ rubygems_version: 2.0.14
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Validation frontend for models.