lacerda 0.6.2 → 0.7.0

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: 6428616b8b151e935f781acb33f2035eeb80d005
4
- data.tar.gz: 794fb69705f42044d7429ebf3b655726af8b3312
3
+ metadata.gz: b79f31c341b389ee76539bade775431468b9bd50
4
+ data.tar.gz: 4cfc0aaf1282b2b0cfe6982c0f33299fafefeb6e
5
5
  SHA512:
6
- metadata.gz: 916d0c9a2b9fbcf502a5f0f9f5786cad20a8f9c09b5f7cc343b0712554fc554ad820062c8aefbf0965addc1caaa8db32a0817e9532b1fa562ab0bddbda2b9cca
7
- data.tar.gz: 0d583d8e1d7c67de052f470dfc28d11a24a48ae807ba2d760b8a1ae84e7c68c61ad1c99b400c5ce395495ad7073af27a3ccf12e6361d56daf603f14df831bcc0
6
+ metadata.gz: 7d5be7e36ab570f3a860a52a91d7006248ddbf48751e44f7b8cf2437e5db8dea4aeee63c5583d6b301e533c02b12cd6c4b7337f75b003b3822362d7e30370e43
7
+ data.tar.gz: 90847e492f4b7bbede6bc1ca00a09a008fd89cdb3f07e6e6ed0e462e72a44d57ee0a5734ff5250e05dd4f867474bcaaa4a5eda1891c9796fb6c8735337945b85
@@ -1,3 +1,6 @@
1
+ # 0.7.0 (30-Oct-15)
2
+ - change ServiceName:ObjectName to ServiceName::ObjectName
3
+
1
4
  # 0.6.2 (30-Oct-15)
2
5
  - fix some forgotten ruby 2.0 syntax
3
6
  - my name is Jannis and I am a compulsive obsessive rake releaser
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.
@@ -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
- k.underscore.start_with?(service.name.underscore+Lacerda::SCOPE_SEPARATOR)
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
- schema = @schema[:definitions][name.to_s.underscore]
20
- raise Lacerda::Service::InvalidObjectTypeError.new(name.to_s.underscore) unless schema
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
@@ -11,7 +11,7 @@ module Lacerda
11
11
  def publisher_name
12
12
  i = @scoped_name.index(Lacerda::SCOPE_SEPARATOR)
13
13
  return unless i
14
- @scoped_name[0...i].underscore
14
+ Lacerda.underscore(@scoped_name[0...i])
15
15
  end
16
16
 
17
17
  def consumer
@@ -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
- [scope, string.to_s].compact.join(Lacerda::SCOPE_SEPARATOR).underscore
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'].underscore
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))
@@ -31,7 +31,9 @@ module Lacerda
31
31
  private
32
32
 
33
33
  def remove_service_from_scoped_name(n)
34
- n[n.index(Lacerda::SCOPE_SEPARATOR)+1..-1]
34
+ i = n.index(Lacerda::SCOPE_SEPARATOR)
35
+ return n unless i
36
+ n[i+Lacerda::SCOPE_SEPARATOR.length..-1]
35
37
  end
36
38
 
37
39
  end
@@ -14,11 +14,11 @@ module Lacerda
14
14
  end
15
15
 
16
16
  def object(name)
17
- scoped_name = name.to_s.underscore
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.underscore)
21
- scoped_name = [service.name.underscore, scoped_name].join(Lacerda::SCOPE_SEPARATOR)
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]
@@ -1,3 +1,3 @@
1
1
  module Lacerda
2
- VERSION = '0.6.2'
2
+ VERSION = '0.7.0'
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.6.2
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jannis Hermanns