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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f1951ae18bb524d3e7ac680a7d75b360d273c81
4
- data.tar.gz: b4b0f536b4aec61a5dcb90803de2f882d9d40464
3
+ metadata.gz: 414a2e9c89fcac777942b9bdf48e395ad505e823
4
+ data.tar.gz: 5bc899fc92cd77fdb7a8d2b35a523face5bfb14d
5
5
  SHA512:
6
- metadata.gz: 7e35931e4629bb5c7a65839185a7955de5600a959646c7a42280bc57da4cb9a78cca72303240a23380f5f9917430ebeda6c46673865c893301bc6bdabc968942
7
- data.tar.gz: 136c9825c60c8a78ce7ecd36bd0407ba6dbde953d13b4a9cd6471adcfbea8f385582db9dd49b96a4566bf3cccbcbfb2f3457cb4aa4957c671596954d35103c36
6
+ metadata.gz: d578597020f6f673ac61501bea49fd3a0a8552a50f5014ef1a4dada682417e4e937a4bf6ea65f9a22f4efa4aef059f5b98592409ea844ea1dbecd222309185e2
7
+ data.tar.gz: 89137530d68a6f19da55a3e0fbd33f2f480b3da51625d122ffe30aad1e39a16e41265d188ef46d59f161fea4f2a15c45bc815cc8ab318844dc79fc2f6507d24a
@@ -2,11 +2,16 @@ require_relative "scrivener/validations"
2
2
  require_relative "scrivener/types"
3
3
 
4
4
  class Scrivener
5
- VERSION = "1.0.1"
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
  #
@@ -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 = I.new({})
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 = I.new(a: "foo", b: "bar")
227
+ filter = H.new(a: "foo", b: "bar")
256
228
  assert ! filter.valid?
257
229
 
258
- filter = I.new(a: "foo")
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 = I.new(a: "foo", b: 42)
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.1
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-04-27 00:00:00.000000000 Z
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.4.5.1
72
+ rubygems_version: 2.5.1
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Validation frontend for models.