avro-builder 0.15.0 → 0.16.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: 357f3e243725cab3c4a9d595b9dc5354516a59c2
4
- data.tar.gz: 54c370ee125d1840cbba0bce0879e6f806655c69
3
+ metadata.gz: 9c0ae91d30be185125e91fccc2f02c08106f155a
4
+ data.tar.gz: 99daec1be8f8027c10b264883988ff78ea58d68e
5
5
  SHA512:
6
- metadata.gz: 6ab7ebf14ce0260287ca1bf23fb3b60ca13eeb276543bc67c391dc63be4b407f554133eec462b062336c715ad8b82bd09140e9eccebb1b4e824e2531607e5ed9
7
- data.tar.gz: cc50e28935cc9ff1c7d58ac6518e44ffcf02a225e32eb8d8b0b9f66cf47a2efd7e1171b78d060663ff26a7b015f07782997d349453d098cb0c243719ab7c9872
6
+ metadata.gz: 5f2c5a8e95c3a0cadce29089225169ab0f8656a0a96728f33e50428684de826e062ffbb89147d02fdf0008a815ef01f98eb7fd4a92b184e1c47b24fe4c2d1fd8
7
+ data.tar.gz: 240cbf70f74ce19db34ac8ba17f1d5fe16bd6c6eda09b6df14139b580d4f03b487f7c6deedbf40abbd6579d6a67588691c5686cc376ff20c0a51d178584b6496
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.0
4
- - 2.3.3
5
- - 2.2.6
3
+ - 2.4.1
4
+ - 2.3.4
5
+ - 2.2.7
6
6
  before_install:
7
7
  - gem update --system
8
8
  before_script:
@@ -10,4 +10,4 @@ before_script:
10
10
  script:
11
11
  - bundle exec rubocop
12
12
  - bundle exec appraisal avro-official rspec
13
- - bundle exec appraisal avro-salsify-fork rspec
13
+ - bundle exec appraisal avro-patches rspec
data/Appraisals CHANGED
@@ -1,7 +1,7 @@
1
1
  appraise 'avro-official' do
2
- gem 'avro', '1.8.1'
2
+ gem 'avro', '1.8.2'
3
3
  end
4
4
 
5
- appraise 'avro-salsify-fork' do
6
- gem 'avro-salsify-fork', '1.9.0.0', require: 'avro'
5
+ appraise 'avro-patches' do
6
+ gem 'avro-patches'
7
7
  end
@@ -1,5 +1,9 @@
1
1
  # avro-builder changelog
2
2
 
3
+ ## v0.16.0
4
+ - Add support for providing an explicit `namespace` on `extend`.
5
+ - Default lookup to current namespace before falling back on global search.
6
+
3
7
  ## v0.15.0
4
8
  - Add support for declaring types as abstract.
5
9
 
data/README.md CHANGED
@@ -283,12 +283,13 @@ are more limited.
283
283
  The official Ruby `avro` gem does not yet support logical types:
284
284
  [AVRO-1695](https://issues.apache.org/jira/browse/AVRO-1695).
285
285
 
286
- There is a `avro-salsify-fork` gem released from this
287
- [fork](https://github.com/salsify/avro) that includes changes to support
288
- encoding and decoding logical types. To use this gem, reference it in your Gemfile:
286
+ There is a [avro-patches](https://github.com/salsify/avro-patches) gem that patches
287
+ the official Avro Ruby gem to support
288
+ encoding and decoding logical types. To use this gem, reference it in your Gemfile
289
+ instead of the official Avro gem:
289
290
 
290
291
  ```ruby
291
- gem 'avro-salsify-fork', require: 'avro'
292
+ gem 'avro-patches'
292
293
  ```
293
294
 
294
295
  A logical type can be specified for a field using the `logical_type` attribute:
@@ -381,6 +382,40 @@ record using `extends <record_name>`. This adds all of the fields from
381
382
  the referenced record to the current record. The current record may override
382
383
  fields in the record that it extends.
383
384
 
385
+ ```
386
+ record :original do
387
+ required :first, :string
388
+ required :second, :int
389
+ end
390
+
391
+ record :extended do
392
+ extends :original
393
+ optional :first, :string
394
+ end
395
+ ```
396
+
397
+ Additionally you can provide a `namespace` to `extends` if necessary to remove ambiguity.
398
+
399
+ ```
400
+ namespace 'com.newbie'
401
+
402
+ record :original, namespace: 'com.og' do
403
+ required :first, :string
404
+ required :second, :int
405
+ end
406
+
407
+ record :original do
408
+ required :first, :string
409
+ required :second, :int
410
+ end
411
+
412
+ record :extended do
413
+ extends :original, namespace: 'com.og'
414
+ optional :first, :string
415
+ end
416
+ ```
417
+
418
+
384
419
  ## Schema Store
385
420
 
386
421
  The `Avro::Builder::SchemaStore` can be used to load DSL files and return cached
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'avro/builder/version'
@@ -28,6 +29,6 @@ Gem::Specification.new do |spec|
28
29
  spec.add_development_dependency 'rspec-its'
29
30
  spec.add_development_dependency 'json_spec'
30
31
  spec.add_development_dependency 'simplecov'
31
- spec.add_development_dependency 'salsify_rubocop', '~> 0.47.0'
32
+ spec.add_development_dependency 'salsify_rubocop', '~> 0.48.0'
32
33
  spec.add_development_dependency 'overcommit'
33
34
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "avro", "1.8.1"
5
+ gem "avro", "1.8.2"
6
6
 
7
7
  gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "avro-salsify-fork", "1.9.0.0", :require => "avro"
5
+ gem "avro-patches"
6
6
 
7
7
  gemspec :path => "../"
@@ -118,7 +118,15 @@ module Avro
118
118
  end
119
119
 
120
120
  def eval_file(name)
121
- file_path = find_file(name)
121
+ file_path = if namespace
122
+ begin
123
+ find_file([namespace, name].join('.'))
124
+ rescue FileNotFoundError
125
+ find_file(name)
126
+ end
127
+ else
128
+ find_file(name)
129
+ end
122
130
  instance_eval(File.read(file_path), file_path)
123
131
  end
124
132
  end
@@ -19,6 +19,8 @@ module Avro
19
19
  File.read(find_file(name))
20
20
  end
21
21
 
22
+ FileNotFoundError = Class.new(StandardError)
23
+
22
24
  def find_file(name)
23
25
  # Ensure that the file_name that is searched for begins with a slash (/)
24
26
  # and ends with a .rb extension. Additionally, if the name contains
@@ -31,7 +33,7 @@ module Avro
31
33
  end
32
34
  end.uniq
33
35
  raise "Multiple matches: #{matches}" if matches.size > 1
34
- raise "File not found #{file_name}" if matches.empty?
36
+ raise FileNotFoundError.new("File not found #{file_name}") if matches.empty?
35
37
 
36
38
  matches.first
37
39
  end
@@ -53,8 +53,8 @@ module Avro
53
53
 
54
54
  # Adds fields from the record with the specified name to the current
55
55
  # record.
56
- def extends(name)
57
- fields.merge!(cache.lookup_named_type(name, namespace).duplicated_fields)
56
+ def extends(name, options = {})
57
+ fields.merge!(cache.lookup_named_type(name, options.delete(:namespace) || namespace).duplicated_fields)
58
58
  end
59
59
 
60
60
  def to_h(reference_state = SchemaSerializerReferenceState.new)
@@ -1,5 +1,5 @@
1
1
  module Avro
2
2
  module Builder
3
- VERSION = '0.15.0'.freeze
3
+ VERSION = '0.16.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avro-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-27 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.47.0
131
+ version: 0.48.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.47.0
138
+ version: 0.48.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: overcommit
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -173,7 +173,7 @@ files:
173
173
  - bin/console
174
174
  - bin/setup
175
175
  - gemfiles/avro_official.gemfile
176
- - gemfiles/avro_salsify_fork.gemfile
176
+ - gemfiles/avro_patches.gemfile
177
177
  - lib/avro/builder.rb
178
178
  - lib/avro/builder/aliasable.rb
179
179
  - lib/avro/builder/anonymous_types.rb