api-blueprint 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api-blueprint.rb +1 -0
- data/lib/api-blueprint/builder.rb +1 -11
- data/lib/api-blueprint/key_replacer.rb +13 -0
- data/lib/api-blueprint/struct.rb +8 -0
- data/lib/api-blueprint/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84b4415cd8e7238b56f556969215b94c1ed7471d
|
4
|
+
data.tar.gz: fead4f882d90ea4e232dea148c22ebb93462fbc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1c4fbce9cd213728a8985ae19b163942f9c46a5204d50edb34bd33adb75147492ecc9fa115b18aafb001f1c4c192eb2e711d328c7375a6007c9ac5f0c06c986
|
7
|
+
data.tar.gz: 04e83ea3a7a15d1d12859f56aedbf6f8b61ae623fd6c9ce287ae3ba22ff0e3dd4b333a9fa5d54af517e25f0870421e0e9a053dc712fe53271d03b6fb712f1fe3
|
data/lib/api-blueprint.rb
CHANGED
@@ -23,7 +23,7 @@ module ApiBlueprint
|
|
23
23
|
response_status: status
|
24
24
|
}
|
25
25
|
|
26
|
-
meta.merge
|
26
|
+
meta.merge KeyReplacer.replace(item.deep_symbolize_keys, replacements)
|
27
27
|
end
|
28
28
|
|
29
29
|
def build_item(item)
|
@@ -34,15 +34,5 @@ module ApiBlueprint
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
private
|
38
|
-
|
39
|
-
def with_replacements(item)
|
40
|
-
item.tap do |item|
|
41
|
-
replacements.each do |bad, good|
|
42
|
-
item[good] = item.delete bad if item.has_key? bad
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
37
|
end
|
48
38
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ApiBlueprint
|
2
|
+
class KeyReplacer
|
3
|
+
|
4
|
+
def self.replace(attributes, replacements)
|
5
|
+
attributes.dup.deep_symbolize_keys.tap do |item|
|
6
|
+
replacements.each do |bad, good|
|
7
|
+
item[good] = item.delete bad if item.has_key? bad
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/lib/api-blueprint/struct.rb
CHANGED
@@ -5,5 +5,13 @@ module ApiBlueprint
|
|
5
5
|
transform_types do |type|
|
6
6
|
type.default? ? type : type.meta(omittable: true)
|
7
7
|
end
|
8
|
+
|
9
|
+
def self.new(attributes = default_attributes)
|
10
|
+
if respond_to?(:config) && config.replacements
|
11
|
+
attributes = KeyReplacer.replace(attributes, config.replacements)
|
12
|
+
end
|
13
|
+
|
14
|
+
super
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api-blueprint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damien Timewell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-types
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- lib/api-blueprint/builder.rb
|
223
223
|
- lib/api-blueprint/cache.rb
|
224
224
|
- lib/api-blueprint/collection.rb
|
225
|
+
- lib/api-blueprint/key_replacer.rb
|
225
226
|
- lib/api-blueprint/model.rb
|
226
227
|
- lib/api-blueprint/parser.rb
|
227
228
|
- lib/api-blueprint/response_middleware.rb
|