lacerda 0.3.0 → 0.3.2
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/.ruby-gemset +1 -1
- data/CHANGELOG.markdown +7 -0
- data/README.md +6 -2
- data/lib/lacerda/compare/json_schema.rb +4 -3
- data/lib/lacerda/consumed_object.rb +7 -2
- data/lib/lacerda/infrastructure.rb +22 -0
- data/lib/lacerda/publish_contract.rb +1 -1
- data/lib/lacerda/service.rb +2 -2
- data/lib/lacerda/tasks.rb +1 -1
- 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: f22605d51fec41e57a8bb76e38621ef3fba87847
|
4
|
+
data.tar.gz: 186995c3c701f0a3ffaf6783eed3cbb85ee2b940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9527eab7980d2770748ce1382678111e992ab125e5918f0843ddc28d4d56071972d770082908630491836922eadef2a66cca8645b0643b145c1957cf98581d9
|
7
|
+
data.tar.gz: 6e76e0f5edc802737bcb0099b1886e5397fbcf8f7ed6835ad76d332279b4f1f014c349c80e1c110d5a8c613255ccb5fb1f16d417a6942f277f82d3d48c8d0cd6
|
data/.ruby-gemset
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
lacerda
|
data/CHANGELOG.markdown
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# Lacerda [](https://circleci.com/gh/moviepilot/lacerda/tree/master) [](https://coveralls.io/github/moviepilot/lacerda?branch=master) [](https://codeclimate.com/github/moviepilot/lacerda) [](https://gemnasium.com/moviepilot/lacerda)
|
2
2
|
|
3
3
|

|
4
|
-
> «We need total coverage
|
4
|
+
> «No, no -- we have to go on. We need total coverage.»<sup>[1](#references)</sup>
|
5
5
|
|
6
6
|
This gem can:
|
7
7
|
|
@@ -63,3 +63,7 @@ By converting all files in a directory this gem will build up the following rela
|
|
63
63
|
- PublishedObjects
|
64
64
|
- Consume contract
|
65
65
|
- ConsumedObjects
|
66
|
+
|
67
|
+
# References
|
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.
|
@@ -18,8 +18,9 @@ module Lacerda
|
|
18
18
|
@containing_schema = containing_schema
|
19
19
|
end
|
20
20
|
|
21
|
-
def contains?(contained_schema,
|
21
|
+
def contains?(contained_schema, initial_location = nil)
|
22
22
|
@errors = []
|
23
|
+
@initial_location = initial_location
|
23
24
|
@contained_schema = contained_schema
|
24
25
|
definitions_contained?
|
25
26
|
end
|
@@ -29,7 +30,7 @@ module Lacerda
|
|
29
30
|
def definitions_contained?
|
30
31
|
@contained_schema['definitions'].each do |property, contained_property|
|
31
32
|
containing_property = @containing_schema['definitions'][property]
|
32
|
-
return _e(:ERR_MISSING_DEFINITION, [property]) unless containing_property
|
33
|
+
return _e(:ERR_MISSING_DEFINITION, [@initial_location, property]) unless containing_property
|
33
34
|
return false unless schema_contains?(containing_property, contained_property, [property])
|
34
35
|
end
|
35
36
|
true
|
@@ -37,7 +38,7 @@ module Lacerda
|
|
37
38
|
|
38
39
|
def _e(error, location, extra = nil)
|
39
40
|
message = [ERRORS[error], extra].compact.join(": ")
|
40
|
-
@errors.push(error: error, message: message, location: location.join("/"))
|
41
|
+
@errors.push(error: error, message: message, location: location.compact.join("/"))
|
41
42
|
false
|
42
43
|
end
|
43
44
|
|
@@ -4,9 +4,14 @@ module Lacerda
|
|
4
4
|
class ConsumedObject < Lacerda::ObjectDescription
|
5
5
|
|
6
6
|
def publisher
|
7
|
+
return unless publisher_name
|
8
|
+
@defined_in_service.infrastructure.services[publisher_name]
|
9
|
+
end
|
10
|
+
|
11
|
+
def publisher_name
|
7
12
|
i = @scoped_name.index(Lacerda::SCOPE_SEPARATOR)
|
8
|
-
return
|
9
|
-
@
|
13
|
+
return unless i
|
14
|
+
@scoped_name[0...i].underscore
|
10
15
|
end
|
11
16
|
|
12
17
|
def consumer
|
@@ -18,11 +18,33 @@ module Lacerda
|
|
18
18
|
def contracts_fulfilled?
|
19
19
|
@mutex1.synchronize do
|
20
20
|
@errors = {}
|
21
|
+
|
22
|
+
# Check for incompatibility in published objects
|
21
23
|
publishers.each do |publisher|
|
22
24
|
publisher.satisfies_consumers?(verbose: @verbose)
|
23
25
|
next if publisher.errors.empty?
|
24
26
|
@errors.merge! publisher.errors
|
25
27
|
end
|
28
|
+
|
29
|
+
# Check for missing publishers
|
30
|
+
missing_publishers = {}
|
31
|
+
consumers.each do |consumer|
|
32
|
+
consumer.consumed_objects.each do |object|
|
33
|
+
next if object.publisher
|
34
|
+
missing_publishers[object.publisher_name.camelize] ||= []
|
35
|
+
missing_publishers[object.publisher_name.camelize] << consumer.name.camelize
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Report missing publishers
|
40
|
+
unless missing_publishers.empty?
|
41
|
+
missing = []
|
42
|
+
missing_publishers.each do |publisher, consumers|
|
43
|
+
missing << "#{publisher} (consumed by #{consumers.join(', ')})"
|
44
|
+
end
|
45
|
+
errors["Missing publishers: "] = missing
|
46
|
+
end
|
47
|
+
|
26
48
|
@errors.empty?
|
27
49
|
end
|
28
50
|
end
|
@@ -10,7 +10,7 @@ module Lacerda
|
|
10
10
|
|
11
11
|
def satisfies?(consumer)
|
12
12
|
@comparator = Compare::JsonSchema.new(@schema)
|
13
|
-
@comparator.contains?(consumer.consume.scoped_schema(service))
|
13
|
+
@comparator.contains?(consumer.consume.scoped_schema(service), consumer.name)
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
data/lib/lacerda/service.rb
CHANGED
@@ -43,10 +43,10 @@ module Lacerda
|
|
43
43
|
consumers.each do |consumer|
|
44
44
|
@publish.satisfies?(consumer)
|
45
45
|
if @publish.errors.empty?
|
46
|
-
print "#{consumer.name.camelize
|
46
|
+
print "#{consumer.name.camelize.green} "if verbose
|
47
47
|
next
|
48
48
|
end
|
49
|
-
print "#{consumer.name.camelize
|
49
|
+
print "#{consumer.name.camelize.red} "if verbose
|
50
50
|
@errors["#{name} -> #{consumer.name}"] = @publish.errors
|
51
51
|
end
|
52
52
|
print "\n" if verbose
|
data/lib/lacerda/tasks.rb
CHANGED
data/lib/lacerda/version.rb
CHANGED