lacerda 0.3.0 → 0.3.2

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: b9e353a73a35769ada04cc9efa1a32dfbedc1fee
4
- data.tar.gz: a18205aa09824893c34a3c861dff1995f92fd28a
3
+ metadata.gz: f22605d51fec41e57a8bb76e38621ef3fba87847
4
+ data.tar.gz: 186995c3c701f0a3ffaf6783eed3cbb85ee2b940
5
5
  SHA512:
6
- metadata.gz: 605e8d8df037122645b4a113180ab043cb7472ca35792696e570c9398510b2c4f2703600cce3c3fdceee6f3fe473bbba44c1d259b7dfe9842cac85b31cb4ab0b
7
- data.tar.gz: 4e9ad371ccb84ba3667c973011d216d0bddae5454a85a4aadfc638053d71c83ddb537cd1ae300561384b6e51c94e2929359c583dac46618b55d2a253f1f6b367
6
+ metadata.gz: f9527eab7980d2770748ce1382678111e992ab125e5918f0843ddc28d4d56071972d770082908630491836922eadef2a66cca8645b0643b145c1957cf98581d9
7
+ data.tar.gz: 6e76e0f5edc802737bcb0099b1886e5397fbcf8f7ed6835ad76d332279b4f1f014c349c80e1c110d5a8c613255ccb5fb1f16d417a6942f277f82d3d48c8d0cd6
data/.ruby-gemset CHANGED
@@ -1 +1 @@
1
- minimum-term
1
+ lacerda
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.3.2 (28-Oct-15)
2
+ - fix wrongly named rake task
3
+ - fix case where an infrastructure with a missing publishing service was reported as valid
4
+
5
+ # 0.3.0 (28-Oct-15)
6
+ - rename to Lacerda
7
+
1
8
  # 0.2.4 (23-Oct-15)
2
9
  - fix deep clone bug for schema scoping
3
10
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # Lacerda [![Circle CI](https://circleci.com/gh/moviepilot/minimum-term/tree/master.svg?style=svg)](https://circleci.com/gh/moviepilot/minimum-term/tree/master) [![Coverage Status](https://coveralls.io/repos/moviepilot/minimum-term/badge.svg?branch=master&service=github)](https://coveralls.io/github/moviepilot/minimum-term?branch=master) [![Code Climate](https://codeclimate.com/github/moviepilot/minimum-term/badges/gpa.svg)](https://codeclimate.com/github/moviepilot/minimum-term) [![Dependency Status](https://gemnasium.com/moviepilot/minimum-term.svg)](https://gemnasium.com/moviepilot/minimum-term)
1
+ # Lacerda [![Circle CI](https://circleci.com/gh/moviepilot/lacerda/tree/master.svg?style=svg)](https://circleci.com/gh/moviepilot/lacerda/tree/master) [![Coverage Status](https://coveralls.io/repos/moviepilot/lacerda/badge.svg?branch=master&service=github)](https://coveralls.io/github/moviepilot/lacerda?branch=master) [![Code Climate](https://codeclimate.com/github/moviepilot/lacerda/badges/gpa.svg)](https://codeclimate.com/github/moviepilot/lacerda) [![Dependency Status](https://gemnasium.com/moviepilot/lacerda.svg)](https://gemnasium.com/moviepilot/lacerda)
2
2
 
3
3
  ![](https://dl.dropboxusercontent.com/u/1953503/lacerda.jpg)
4
- > «We need total coverage»<sup>[1](http://www.dailyscript.com/scripts/fearandloathing.html)</sup>
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, pry = false)
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 @defined_in_service unless i
9
- @defined_in_service.infrastructure.services[@scoped_name[0...i].underscore.to_sym]
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
@@ -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}".green if verbose
46
+ print "#{consumer.name.camelize.green} "if verbose
47
47
  next
48
48
  end
49
- print "#{consumer.name.camelize}".red if verbose
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
@@ -5,7 +5,7 @@ module Lacerda
5
5
  include Rake::DSL if defined? Rake::DSL
6
6
 
7
7
  def install_tasks
8
- namespace :minimum_term do
8
+ namespace :lacerda do
9
9
  desc "Clean up intermediary json files"
10
10
  task :cleanup do
11
11
  path = File.expand_path("../contracts")
@@ -1,3 +1,3 @@
1
1
  module Lacerda
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lacerda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jannis Hermanns