opal-scrivener 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scrivener.rb +6 -1
- data/test/scrivener_test.rb +4 -32
- 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: 414a2e9c89fcac777942b9bdf48e395ad505e823
|
4
|
+
data.tar.gz: 5bc899fc92cd77fdb7a8d2b35a523face5bfb14d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d578597020f6f673ac61501bea49fd3a0a8552a50f5014ef1a4dada682417e4e937a4bf6ea65f9a22f4efa4aef059f5b98592409ea844ea1dbecd222309185e2
|
7
|
+
data.tar.gz: 89137530d68a6f19da55a3e0fbd33f2f480b3da51625d122ffe30aad1e39a16e41265d188ef46d59f161fea4f2a15c45bc815cc8ab318844dc79fc2f6507d24a
|
data/lib/scrivener.rb
CHANGED
@@ -2,11 +2,16 @@ require_relative "scrivener/validations"
|
|
2
2
|
require_relative "scrivener/types"
|
3
3
|
|
4
4
|
class Scrivener
|
5
|
-
VERSION = "1.0.
|
5
|
+
VERSION = "1.0.2"
|
6
6
|
|
7
7
|
include Validations
|
8
8
|
extend Types
|
9
9
|
|
10
|
+
# This will allow you to inhreit from other Scrivener classes
|
11
|
+
def self.inherited(sub_class)
|
12
|
+
sub_class.send(:attr_accessor, *instance_methods(false).select { |m| !m['='] }) unless self.name == 'Scrivener'
|
13
|
+
end
|
14
|
+
|
10
15
|
# Initialize with a hash of attributes and values.
|
11
16
|
# Extra attributes are discarded.
|
12
17
|
#
|
data/test/scrivener_test.rb
CHANGED
@@ -208,34 +208,6 @@ end
|
|
208
208
|
|
209
209
|
class H < Scrivener
|
210
210
|
attr_accessor :a
|
211
|
-
|
212
|
-
def validate
|
213
|
-
assert_length :a, 3..10
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
scope do
|
218
|
-
test "length validation" do
|
219
|
-
filter = H.new({})
|
220
|
-
|
221
|
-
assert ! filter.valid?
|
222
|
-
assert filter.errors[:a].include?(:not_in_range)
|
223
|
-
|
224
|
-
filter = H.new(a: "fo")
|
225
|
-
assert ! filter.valid?
|
226
|
-
assert filter.errors[:a].include?(:not_in_range)
|
227
|
-
|
228
|
-
filter = H.new(a: "foofoofoofo")
|
229
|
-
assert ! filter.valid?
|
230
|
-
assert filter.errors[:a].include?(:not_in_range)
|
231
|
-
|
232
|
-
filter = H.new(a: "foo")
|
233
|
-
assert filter.valid?
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
class I < Scrivener
|
238
|
-
attr_accessor :a
|
239
211
|
attr_accessor :b
|
240
212
|
|
241
213
|
def validate
|
@@ -246,21 +218,21 @@ end
|
|
246
218
|
|
247
219
|
scope do
|
248
220
|
test "equality validation" do
|
249
|
-
filter =
|
221
|
+
filter = H.new({})
|
250
222
|
|
251
223
|
assert ! filter.valid?
|
252
224
|
assert filter.errors[:a].include?(:not_equal)
|
253
225
|
assert filter.errors[:b].include?(:not_equal)
|
254
226
|
|
255
|
-
filter =
|
227
|
+
filter = H.new(a: "foo", b: "bar")
|
256
228
|
assert ! filter.valid?
|
257
229
|
|
258
|
-
filter =
|
230
|
+
filter = H.new(a: "foo")
|
259
231
|
assert ! filter.valid?
|
260
232
|
assert filter.errors[:a].empty?
|
261
233
|
assert filter.errors[:b].include?(:not_equal)
|
262
234
|
|
263
|
-
filter =
|
235
|
+
filter = H.new(a: "foo", b: 42)
|
264
236
|
filter.valid?
|
265
237
|
assert filter.valid?
|
266
238
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-scrivener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Martens
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cutest
|
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
version: '0'
|
70
70
|
requirements: []
|
71
71
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.
|
72
|
+
rubygems_version: 2.5.1
|
73
73
|
signing_key:
|
74
74
|
specification_version: 4
|
75
75
|
summary: Validation frontend for models.
|