golden_fleece 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: f996bbd5d3cba822166100ddbc5dce786e65b816
4
- data.tar.gz: f35cf4bf3aa2e42e6570e802be2f643fe9304a92
3
+ metadata.gz: 6dadad30183120be89348ef186c0be8de8d1cf6e
4
+ data.tar.gz: 13e14e0c497115e0e7dff33822b2864efd0bb7c6
5
5
  SHA512:
6
- metadata.gz: 9c6fb47d237602b4f038de774bf5b5a596f1e73f9639d0892a4f49e60c1b5f33f2c4b9b42e52718ed952dd21f5ba0e88721a3c8ffd35775febea096cd44852c8
7
- data.tar.gz: c677a968dc4a79037c4f5580787e23452d8fd53bee4c317986ec42515b0039abf989e5b4bafececf4419ff0b449740559c5424cec63cd0a618f424f1886be7c8
6
+ metadata.gz: c5b3b5e14665764464cbf89ba630db8c549463572696dc98de7a31a607549426d0d9cc821f06838850313aec07f4f5fcdbaa37cb05acff66544b01638f66fc03
7
+ data.tar.gz: 7c115cdb975db18cda2b27aca36329e2c7d23e3ac0c160601e922e18f50a9bb348cdc8df721efbeef5071ff19172889c6f7f8529a9e84b9379307d7493fe35ae
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
7
  ## [Unreleased]
8
+ ### [0.1.2] - 2015-05-26
9
+ ### Changed
10
+ - Allow redefining individual schemas
11
+
12
+ ### Fixed
13
+ - Validation no longer stops after encountering a single invalid key in a hash
8
14
 
9
15
  ## [0.1.1] - 2017-05-25
10
16
  ### Fixed
@@ -20,5 +26,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
20
26
  - Getters
21
27
  - Specs
22
28
 
23
- [Unreleased]: https://github.com/earksiinni/golden_fleece/compare/v0.1.1...HEAD
24
- [0.1.1]: https://github.com/earksiinni/golden_fleece/compare/ad25a847b5678b1f3a6c1c0b6a986d784142d38f...v0.1.1
29
+ [Unreleased]: https://github.com/earksiinni/golden_fleece/compare/v0.1.2...HEAD
30
+ [0.1.2]: https://github.com/earksiinni/golden_fleece/compare/v0.1.1...v0.1.2
31
+ [0.1.1]: https://github.com/earksiinni/golden_fleece/compare/v0.1.0...v0.1.1
@@ -2,8 +2,18 @@ module GoldenFleece
2
2
  class Context
3
3
  module Schemas
4
4
  def define_schemas(attribute, schema_definitions = {})
5
- schemas[attribute.to_sym] ||= schema_definitions
6
- attributes << attribute
5
+ attribute_schema = schemas[attribute.to_sym]
6
+
7
+ # Allow redefining individual schemas
8
+ if attribute_schema
9
+ schema_definitions.each do |schema_name, schema_definition|
10
+ schemas[attribute.to_sym][schema_name.to_sym] = schema_definition
11
+ end
12
+ else
13
+ schemas[attribute.to_sym] = schema_definitions
14
+ end
15
+
16
+ attributes << attribute unless attributes.include? attribute
7
17
  end
8
18
  end
9
19
  end
@@ -29,10 +29,7 @@ module GoldenFleece
29
29
  validatable_keys.each do |key|
30
30
  path = build_json_path(parent_path, key)
31
31
 
32
- validate_key key, path
33
-
34
- # If all keys on our current level are valid, proceed
35
- if errors.empty?
32
+ if validate_key key, path
36
33
  schema = schemas[key]
37
34
  value = schema.value.compute(record)
38
35
 
@@ -52,7 +49,12 @@ module GoldenFleece
52
49
  attr_reader :persisted_json, :schemas, :parent_path, :validatable_keys, :record, :attribute, :errors
53
50
 
54
51
  def validate_key(key, path)
55
- errors << "Invalid key #{error_suffix(attribute, path)}" unless schemas.keys.include? key
52
+ if schemas.keys.include? key
53
+ true
54
+ else
55
+ errors << "Invalid key #{error_suffix(attribute, path)}"
56
+ false
57
+ end
56
58
  end
57
59
 
58
60
  def validate_type(value, valid_types, path)
@@ -4,7 +4,7 @@ require 'hana'
4
4
  module GoldenFleece
5
5
  class Value
6
6
  include Utility
7
-
7
+
8
8
  def initialize(schema)
9
9
  @schema = schema
10
10
  self.value_initialized = false
@@ -1,3 +1,3 @@
1
1
  module GoldenFleece
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: golden_fleece
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
  - Ersin Akinci