json_schema_spec 0.0.6 → 0.0.7

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: e4bfd7bd1989b315c60dfa41ff86e355f4fd4911
4
- data.tar.gz: 266803e4339603af2970620e1cacefc40707c2af
3
+ metadata.gz: bf70f1c088dae444228c66e116e4218f9330688d
4
+ data.tar.gz: ce429fb15d04d5cd2dcf374bbb3b9e404f125ac8
5
5
  SHA512:
6
- metadata.gz: 45ba5b2e0895881ff441e34cc55682ef11052bde228280c9fc719098807d7cde9d558f4aec038a318c29f521e8a047055418402c7a8722910baa4161fd07fef9
7
- data.tar.gz: 3c6b53cda5fc19b7fcbd95ebd1ddc0092d734ffa017259da5e26a3907e608c14d7c61ed114a153246fa61ca79f8a404093045ded9e6c8f745f099ededece7f86
6
+ metadata.gz: 98d692fc82bf5e5362dc908779a1b65c0f9dc000e74e6130c2474e3727bf8b5bcbd889cf91ccb88d08d339d81286b1bc2c267d06c26e2ffe31fee603c19e2e48
7
+ data.tar.gz: 545648611bf63ed700c0da46b31ffc428d2d5ebda26b09b1b52efde1c9a483a248938b4c6449133aa41160316e7f9c222cf231a17da808da1b053eb09958781a
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0-preview1
1
+ 2.1.0
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "json_schema_spec"
7
- spec.version = "0.0.6"
7
+ spec.version = "0.0.7"
8
8
  spec.authors = ["Winton Welsh"]
9
9
  spec.email = ["mail@wintoni.us"]
10
10
  spec.description = %q{Generate fixtures from JSON schemas.}
@@ -98,8 +98,8 @@ module JsonSchemaSpec
98
98
 
99
99
  [ :request, :response ].each do |direction|
100
100
  validates = JSON::Validator.fully_validate(
101
- schema[direction],
102
- params[direction],
101
+ Util.stringify_keys(schema[direction]),
102
+ Util.stringify_keys(params[direction]),
103
103
  :validate_schema => true
104
104
  )
105
105
  expect(validates).to eq([])
@@ -28,13 +28,29 @@ module JsonSchemaSpec
28
28
 
29
29
  value
30
30
  end
31
+
32
+ def stringify_keys(value)
33
+ work_on_keys(value) { |k| k.to_s }
34
+ end
31
35
 
32
- def symbolize_keys(hash)
33
- hash.inject({}) do |memo, (key, value)|
34
- key = (key.to_sym rescue key) || key
35
- value = symbolize_keys(value) if value.is_a?(Hash)
36
- memo[key] = value
37
- memo
36
+ def symbolize_keys(value)
37
+ work_on_keys(value) { |k| k.to_sym }
38
+ end
39
+
40
+ def work_on_keys(value, &block)
41
+ if value.is_a?(Array)
42
+ value.collect { |v| work_on_keys(v, &block) }
43
+
44
+ elsif value.is_a?(Hash)
45
+ value.inject({}) do |memo, (k, v)|
46
+ k = (yield(k) rescue k) || k
47
+ v = work_on_keys(v, &block)
48
+
49
+ memo[k] = v
50
+ memo
51
+ end
52
+
53
+ else value
38
54
  end
39
55
  end
40
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-15 00:00:00.000000000 Z
11
+ date: 2014-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.1.5
142
+ rubygems_version: 2.2.0
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Generate fixtures from JSON schemas