parametric 0.1.1 → 0.1.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: 4c88b10836d43cc641eef5dd56c0023a13773018
4
- data.tar.gz: 3ed36656d5c4093c8c6e2a8a78bd40734ab6dc88
3
+ metadata.gz: f882efaecdc92a64f9f74bf8c26545dc9d1f6610
4
+ data.tar.gz: db613b987b0d2f3b02470ef04371310840e047f9
5
5
  SHA512:
6
- metadata.gz: 12cc9a17a21d0ed570bd65dfc9e8faad3a8c9ef8a2223c8ec94c4128f5724c8fc1e83684abcd651904cd19b6999463223821c1928ecec3d352bd116e1010fba0
7
- data.tar.gz: '09800c03c3eeb47935ff603e7028e07a82ca7c231b2284694bf26d6da5943579bd35c5953125712691c0205cae4e40c0916dd3150a94bd90ac91685f43c03bfa'
6
+ metadata.gz: 5a4b6866c5c0936d92c4b06042c2b6fbae2c25f9cf6d39454e9949f5d60617dd85e0e6eaf4bd832361a4f160ac0d2df7f984a384b15de508471e61a8830da458
7
+ data.tar.gz: 9e152c1a76b4db393cb2d221b8f8e55cdcb08796ee860af789c9c72225aa1479cb53fb0f2efeb18284d9c25f91adf4823963abdf7eb2e05384885cd200146bb9
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.2.4
4
4
  - 2.3.1
data/README.md CHANGED
@@ -274,6 +274,11 @@ class MyPolicy
274
274
  def valid?(value, key, payload)
275
275
  true
276
276
  end
277
+
278
+ # merge this object into the field's meta data
279
+ def meta_data
280
+ {type: :string}
281
+ end
277
282
  end
278
283
  ```
279
284
 
@@ -327,6 +332,10 @@ class AddJobTitle
327
332
  def valid?(value, key, payload)
328
333
  true
329
334
  end
335
+
336
+ def meta_data
337
+ {}
338
+ end
330
339
  end
331
340
 
332
341
  # Register it
@@ -13,6 +13,10 @@ module Parametric
13
13
  required.policy :present
14
14
  end
15
15
 
16
+ def declared
17
+ required.policy :declared
18
+ end
19
+
16
20
  def options(opts)
17
21
  policy :options, opts
18
22
  end
@@ -1,3 +1,3 @@
1
1
  module Parametric
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/spec/field_spec.rb CHANGED
@@ -251,6 +251,14 @@ describe Parametric::Field do
251
251
  end
252
252
  end
253
253
 
254
+ it "is available as method" do
255
+ resolve(subject.declared.present, a_key: "").tap do |r|
256
+ expect(r.eligible?).to be true
257
+ has_errors
258
+ expect(r.value).to eq ""
259
+ end
260
+ end
261
+
254
262
  it "is not eligible if key does not exist" do
255
263
  resolve(subject.policy(:declared).present, foo: "").tap do |r|
256
264
  expect(r.eligible?).to be false
@@ -43,6 +43,15 @@ describe 'default validators' do
43
43
  }
44
44
  end
45
45
 
46
+ describe ':declared' do
47
+ it {
48
+ test_validator({key: 'foo'}, :key, :declared, true, true)
49
+ test_validator({key: ''}, :key, :declared, true, true)
50
+ test_validator({key: nil}, :key, :declared, true, true)
51
+ test_validator({foo: 'foo'}, :key, :declared, false, true)
52
+ }
53
+ end
54
+
46
55
  describe ':gt' do
47
56
  it {
48
57
  test_validator({key: 10}, :key, :gt, true, true, 9)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parametric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-02 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.6.8
128
+ rubygems_version: 2.5.1
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: DSL for declaring allowed parameters with options, regexp patern and default