lacerda 0.6.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.markdown +3 -0
- data/README.md +1 -1
- data/lib/lacerda.rb +8 -1
- data/lib/lacerda/consume_contract.rb +6 -3
- data/lib/lacerda/consumed_object.rb +1 -1
- data/lib/lacerda/conversion/data_structure.rb +4 -2
- data/lib/lacerda/object_description.rb +3 -1
- data/lib/lacerda/publish_contract.rb +3 -3
- data/lib/lacerda/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b79f31c341b389ee76539bade775431468b9bd50
|
4
|
+
data.tar.gz: 4cfc0aaf1282b2b0cfe6982c0f33299fafefeb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d5be7e36ab570f3a860a52a91d7006248ddbf48751e44f7b8cf2437e5db8dea4aeee63c5583d6b301e533c02b12cd6c4b7337f75b003b3822362d7e30370e43
|
7
|
+
data.tar.gz: 90847e492f4b7bbede6bc1ca00a09a008fd89cdb3f07e6e6ed0e462e72a44d57ee0a5734ff5250e05dd4f867474bcaaa4a5eda1891c9796fb6c8735337945b85
|
data/CHANGELOG.markdown
CHANGED
data/README.md
CHANGED
@@ -66,4 +66,4 @@ By converting all files in a directory this gem will build up the following rela
|
|
66
66
|
|
67
67
|
# References
|
68
68
|
|
69
|
-
[1] This quote in French quotation marks is from "Fear and Loathing in Las Vegas". Since I can't link to the book, a link to the [movie script](http://www.dailyscript.com/scripts/fearandloathing.html) shall suffice.
|
69
|
+
[1] This quote in French quotation marks is from "Fear and Loathing in Las Vegas". Since I can't link to the book, a link to the [movie script](http://www.dailyscript.com/scripts/fearandloathing.html) shall suffice.
|
data/lib/lacerda.rb
CHANGED
@@ -6,5 +6,12 @@ require "lacerda/infrastructure"
|
|
6
6
|
require "lacerda/compare/json_schema"
|
7
7
|
|
8
8
|
module Lacerda
|
9
|
-
SCOPE_SEPARATOR = '
|
9
|
+
SCOPE_SEPARATOR = '::'
|
10
|
+
|
11
|
+
# An underscore that doesn't turn :: into /
|
12
|
+
def self.underscore(string)
|
13
|
+
string.gsub(/#{SCOPE_SEPARATOR}/, ':')
|
14
|
+
.underscore
|
15
|
+
.gsub(/:/, SCOPE_SEPARATOR)
|
16
|
+
end
|
10
17
|
end
|
@@ -7,17 +7,20 @@ module Lacerda
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def scoped_schema(service)
|
10
|
+
service_name_prefix = Lacerda.underscore(service.name + Lacerda::SCOPE_SEPARATOR)
|
11
|
+
|
10
12
|
# Poor man's deep clone: json 🆗 🆒
|
11
13
|
filtered_schema = JSON.parse(schema.to_json)
|
12
14
|
filtered_schema['definitions'].select! do |k|
|
13
|
-
|
15
|
+
Lacerda.underscore(k).start_with?(service_name_prefix)
|
14
16
|
end
|
15
17
|
filtered_schema
|
16
18
|
end
|
17
19
|
|
18
20
|
def object(name)
|
19
|
-
|
20
|
-
|
21
|
+
underscored_name = Lacerda.underscore(name)
|
22
|
+
schema = @schema[:definitions][underscored_name]
|
23
|
+
raise Lacerda::Service::InvalidObjectTypeError.new(underscored_name) unless schema
|
21
24
|
Lacerda::ConsumedObject.new(service, name, schema)
|
22
25
|
end
|
23
26
|
end
|
@@ -6,7 +6,9 @@ module Lacerda
|
|
6
6
|
PRIMITIVES = %w{boolean string number array enum object}
|
7
7
|
|
8
8
|
def self.scope(scope, string)
|
9
|
-
|
9
|
+
Lacerda.underscore(
|
10
|
+
[scope, string.to_s].compact.join(Lacerda::SCOPE_SEPARATOR)
|
11
|
+
)
|
10
12
|
end
|
11
13
|
|
12
14
|
def initialize(id, data, scope = nil)
|
@@ -41,7 +43,7 @@ module Lacerda
|
|
41
43
|
type = type_definition['typeSpecification']['name']
|
42
44
|
|
43
45
|
spec = {}
|
44
|
-
name = content['name']['literal']
|
46
|
+
name = Lacerda.underscore(content['name']['literal'])
|
45
47
|
|
46
48
|
# This is either type: primimtive or $ref: reference_name
|
47
49
|
spec.merge!(primitive_or_reference(type))
|
@@ -14,11 +14,11 @@ module Lacerda
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def object(name)
|
17
|
-
scoped_name = name.to_s
|
17
|
+
scoped_name = Lacerda.underscore(name.to_s)
|
18
18
|
|
19
19
|
# Add our own prefix automatically if necessary
|
20
|
-
unless scoped_name.start_with?(service.name
|
21
|
-
scoped_name = [service.name
|
20
|
+
unless scoped_name.start_with?(Lacerda.underscore(service.name))
|
21
|
+
scoped_name = [Lacerda.underscore(service.name), scoped_name].join(Lacerda::SCOPE_SEPARATOR)
|
22
22
|
end
|
23
23
|
|
24
24
|
schema = @schema[:definitions][scoped_name]
|
data/lib/lacerda/version.rb
CHANGED