json-schema_builder 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/json/schema_builder/schema.rb +2 -2
- data/lib/json/schema_builder/version.rb +1 -1
- data/spec/unit/schema_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9d8f8342dec85f473fec720fefb55c0a584e6b7
|
4
|
+
data.tar.gz: 60d64252fd465336fda5a32b012860002e658c7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15c9cb066c9fc51ff075d9c77142e7a43c9f04f25cade97e4864d3672deb4e9b0da57bbb57856daa9766ad1e281766d75ec4a48a5a408a6cf9c4f2827fbef600
|
7
|
+
data.tar.gz: 302be39bebe17e01cc5b14af72c6e0ac3483ceb680f3ace8405ed36c14b734af538bfa2c9a020df8258e2f3c69bcc434389003ba442c744831ff8264af35ba6f
|
@@ -4,11 +4,11 @@ module JSON
|
|
4
4
|
module SchemaBuilder
|
5
5
|
class Schema < OpenStruct
|
6
6
|
def merge(schema)
|
7
|
-
self.class.new to_h.deep_merge
|
7
|
+
self.class.new to_h.deep_stringify_keys.deep_merge(schema.to_h.deep_stringify_keys)
|
8
8
|
end
|
9
9
|
|
10
10
|
def merge!(schema)
|
11
|
-
@table = to_h.deep_merge schema.to_h
|
11
|
+
@table = to_h.deep_stringify_keys.deep_merge schema.to_h.deep_stringify_keys
|
12
12
|
self
|
13
13
|
end
|
14
14
|
end
|
data/spec/unit/schema_spec.rb
CHANGED
@@ -2,14 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe JSON::SchemaBuilder::Schema, type: :unit do
|
4
4
|
let(:schema){ described_class.new a: 1, b: { c: 3 } }
|
5
|
-
let(:other){ described_class.new a: 2, b
|
5
|
+
let(:other){ described_class.new a: 2, "b" => { d: 4 } }
|
6
6
|
it{ is_expected.to be_a OpenStruct }
|
7
7
|
|
8
8
|
describe '#merge' do
|
9
9
|
it 'should deep merge' do
|
10
10
|
merged = schema.merge other
|
11
11
|
expect(merged).to be_a described_class
|
12
|
-
expect(merged.to_h).to eql a: 2, b: { c
|
12
|
+
expect(merged.to_h).to eql a: 2, b: { "c" => 3, "d" => 4 }
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should not modify the source schema' do
|
@@ -25,7 +25,7 @@ RSpec.describe JSON::SchemaBuilder::Schema, type: :unit do
|
|
25
25
|
it 'should deep merge in place' do
|
26
26
|
merged = schema.merge! other
|
27
27
|
expect(merged).to be_a described_class
|
28
|
-
expect(merged.to_h).to eql a
|
28
|
+
expect(merged.to_h).to eql "a" => 2, "b" => { "c" => 3, "d" => 4 }
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should not modify the merging schema' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-schema_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Parrish
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|