avro-builder 0.15.0.rc0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +8 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +10 -7
  6. data/Appraisals +23 -4
  7. data/CHANGELOG.md +14 -0
  8. data/Gemfile +2 -0
  9. data/README.md +42 -4
  10. data/Rakefile +2 -0
  11. data/avro-builder.gemspec +8 -7
  12. data/gemfiles/{avro_official.gemfile → avro_1.10.0.gemfile} +2 -2
  13. data/gemfiles/avro_1.8.2.gemfile +7 -0
  14. data/gemfiles/avro_1.9.0.gemfile +7 -0
  15. data/gemfiles/avro_1.9.1.gemfile +7 -0
  16. data/gemfiles/avro_patches_0.x.gemfile +8 -0
  17. data/gemfiles/avro_patches_1.x.gemfile +7 -0
  18. data/lib/avro/builder.rb +2 -0
  19. data/lib/avro/builder/aliasable.rb +2 -0
  20. data/lib/avro/builder/anonymous_types.rb +2 -0
  21. data/lib/avro/builder/definition_cache.rb +4 -3
  22. data/lib/avro/builder/dsl.rb +12 -1
  23. data/lib/avro/builder/dsl_attributes.rb +2 -0
  24. data/lib/avro/builder/dsl_options.rb +2 -0
  25. data/lib/avro/builder/enum.rb +2 -0
  26. data/lib/avro/builder/errors.rb +2 -0
  27. data/lib/avro/builder/field.rb +3 -1
  28. data/lib/avro/builder/file_handler.rb +5 -1
  29. data/lib/avro/builder/fixed.rb +2 -0
  30. data/lib/avro/builder/namespaceable.rb +2 -0
  31. data/lib/avro/builder/railtie.rb +3 -1
  32. data/lib/avro/builder/rake/avro_generate_task.rb +3 -0
  33. data/lib/avro/builder/rake/rails_avro_generate_task.rake +3 -1
  34. data/lib/avro/builder/record.rb +2 -0
  35. data/lib/avro/builder/schema_serializer_reference_state.rb +2 -0
  36. data/lib/avro/builder/schema_store.rb +2 -0
  37. data/lib/avro/builder/type_factory.rb +4 -2
  38. data/lib/avro/builder/types.rb +2 -0
  39. data/lib/avro/builder/types/array_type.rb +2 -0
  40. data/lib/avro/builder/types/complex_type.rb +2 -0
  41. data/lib/avro/builder/types/enum_type.rb +11 -2
  42. data/lib/avro/builder/types/fixed_type.rb +2 -0
  43. data/lib/avro/builder/types/map_type.rb +2 -0
  44. data/lib/avro/builder/types/named_error_handling.rb +2 -0
  45. data/lib/avro/builder/types/named_type.rb +2 -0
  46. data/lib/avro/builder/types/record_type.rb +5 -3
  47. data/lib/avro/builder/types/top_level.rb +2 -0
  48. data/lib/avro/builder/types/type.rb +3 -3
  49. data/lib/avro/builder/types/type_referencer.rb +2 -0
  50. data/lib/avro/builder/types/union_type.rb +3 -1
  51. data/lib/avro/builder/version.rb +3 -1
  52. metadata +47 -37
  53. data/gemfiles/avro_salsify_fork.gemfile +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6bd5352172e109727099592f904b03ecfba50d48
4
- data.tar.gz: a729d03c744b064c9a9677c88c9c93225c9db52a
2
+ SHA256:
3
+ metadata.gz: a91ca8206639d20fe48b9ef6f634493a08af34afe223ad06d12c3e930f45bc91
4
+ data.tar.gz: 12ed60307f215d22416ffc2f2d33966ff4481e4cfadb4c011275e811dc6fcfa4
5
5
  SHA512:
6
- metadata.gz: 5f918eb9cbfb7afc951945162092b869819ef3ef3880fca68d49534afc0d3eda73bf0916a75f889c68e98db2a26f551de62e4e08acb3c94198fb92230ef63642
7
- data.tar.gz: 6f33b3efe33499c221769e744b5cccd3aa053012adef5f57b75ca12a89590044755a01f02072b1517a96f58449073aea07a134508b8a1bc5660a8968096d0324
6
+ metadata.gz: 2db9b4753353a9a1e8ecc4c90c5127d21fc4f13f985ce1ab6c5e387cc153691f5a27deb7f2784d92413dace0052c214c0f640779a296f6cfdcceb266c6ec9152
7
+ data.tar.gz: 96565b0a5bccb29930970c992e6f09dabb2c9af640a912ffaffe0c0e53f65820a1378fb7a4799585f9e45337d71c293476b87742c2ebd7060320f5bde8300ab3
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /gemfiles/*.lock
11
+ /gemfiles/.bundle
@@ -1,5 +1,13 @@
1
1
  inherit_gem:
2
2
  salsify_rubocop: conf/rubocop.yml
3
3
 
4
+ AllCops:
5
+ inherit_mode:
6
+ merge:
7
+ - Exclude
8
+ NewCops: disable
9
+ Exclude:
10
+ - "gemfiles/*"
11
+
4
12
  Style/RaiseArgs:
5
13
  EnforcedStyle: compact
@@ -1 +1 @@
1
- ruby-2.3.3
1
+ 2.5.8
@@ -1,13 +1,16 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.0
4
- - 2.3.3
5
- - 2.2.6
6
- before_install:
7
- - gem update --system
3
+ - 2.5.8
4
+ - 2.6.6
5
+ - 2.7.1
6
+ before_install: gem install bundler -v 2.0.1 --no-document
8
7
  before_script:
9
8
  - bundle exec appraisal install --jobs=3
10
9
  script:
11
10
  - bundle exec rubocop
12
- - bundle exec appraisal avro-official rspec
13
- - bundle exec appraisal avro-salsify-fork rspec
11
+ - bundle exec appraisal avro-1.8.2 rspec
12
+ - bundle exec appraisal avro-1.9.0 rspec
13
+ - bundle exec appraisal avro-1.9.1 rspec
14
+ - bundle exec appraisal avro-1.10.0 rspec
15
+ - bundle exec appraisal avro-patches-0.x rspec
16
+ - bundle exec appraisal avro-patches-1.x rspec
data/Appraisals CHANGED
@@ -1,7 +1,26 @@
1
- appraise 'avro-official' do
2
- gem 'avro', '1.8.1'
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'avro-1.8.2' do
4
+ gem 'avro', '1.8.2'
5
+ end
6
+
7
+ appraise 'avro-1.9.0' do
8
+ gem 'avro', '1.9.0'
9
+ end
10
+
11
+ appraise 'avro-1.9.1' do
12
+ gem 'avro', '1.9.1'
13
+ end
14
+
15
+ appraise 'avro-1.10.0' do
16
+ gem 'avro', '1.10.0'
17
+ end
18
+
19
+ appraise 'avro-patches-0.x' do
20
+ gem 'avro', '1.8.2'
21
+ gem 'avro-patches', '< 1.0.0'
3
22
  end
4
23
 
5
- appraise 'avro-salsify-fork' do
6
- gem 'avro-salsify-fork', '1.9.0.0', require: 'avro'
24
+ appraise 'avro-patches-1.x' do
25
+ gem 'avro-patches', '>= 1.0.0'
7
26
  end
@@ -1,5 +1,19 @@
1
1
  # avro-builder changelog
2
2
 
3
+ ## v0.17.0
4
+ - Add support for enum defaults introduced in Avro v1.10.0.
5
+
6
+ ## v0.16.2
7
+ - Allow avro version up to v1.10.x. Support will be added for new
8
+ functionality in Avro v1.10 in a later release.
9
+
10
+ ## v0.16.1
11
+ - Require avro version prior to v1.10.0.
12
+
13
+ ## v0.16.0
14
+ - Add support for providing an explicit `namespace` on `extend`.
15
+ - Default lookup to current namespace before falling back on global search.
16
+
3
17
  ## v0.15.0
4
18
  - Add support for declaring types as abstract.
5
19
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in avro-builder.gemspec
data/README.md CHANGED
@@ -165,6 +165,9 @@ fixed :g, size: 8
165
165
  enum :e, :X, :Y, :Z
166
166
  enum :d, symbols: [:A, :B]
167
167
 
168
+ # defaults can be set for enums with Ruby Avro v1.10.0
169
+ enum :c, symbols: [:A, :B], default: :A
170
+
168
171
  record :my_record_with_named do
169
172
  required :f_ref, :f
170
173
  required :fixed_inline, :fixed, size: 9
@@ -283,12 +286,13 @@ are more limited.
283
286
  The official Ruby `avro` gem does not yet support logical types:
284
287
  [AVRO-1695](https://issues.apache.org/jira/browse/AVRO-1695).
285
288
 
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:
289
+ There is a [avro-patches](https://github.com/salsify/avro-patches) gem that patches
290
+ the official Avro Ruby gem to support
291
+ encoding and decoding logical types. To use this gem, reference it in your Gemfile
292
+ instead of the official Avro gem:
289
293
 
290
294
  ```ruby
291
- gem 'avro-salsify-fork', require: 'avro'
295
+ gem 'avro-patches'
292
296
  ```
293
297
 
294
298
  A logical type can be specified for a field using the `logical_type` attribute:
@@ -381,6 +385,40 @@ record using `extends `. This adds all of the fields from
381
385
  the referenced record to the current record. The current record may override
382
386
  fields in the record that it extends.
383
387
 
388
+ ```
389
+ record :original do
390
+ required :first, :string
391
+ required :second, :int
392
+ end
393
+
394
+ record :extended do
395
+ extends :original
396
+ optional :first, :string
397
+ end
398
+ ```
399
+
400
+ Additionally you can provide a `namespace` to `extends` if necessary to remove ambiguity.
401
+
402
+ ```
403
+ namespace 'com.newbie'
404
+
405
+ record :original, namespace: 'com.og' do
406
+ required :first, :string
407
+ required :second, :int
408
+ end
409
+
410
+ record :original do
411
+ required :first, :string
412
+ required :second, :int
413
+ end
414
+
415
+ record :extended do
416
+ extends :original, namespace: 'com.og'
417
+ optional :first, :string
418
+ end
419
+ ```
420
+
421
+
384
422
  ## Schema Store
385
423
 
386
424
  The `Avro::Builder::SchemaStore` can be used to load DSL files and return cached
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
  require 'appraisal/task'
@@ -1,5 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'avro/builder/version'
5
6
 
@@ -19,15 +20,15 @@ Gem::Specification.new do |spec|
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
21
  spec.require_paths = ['lib']
21
22
 
22
- spec.add_runtime_dependency 'avro', '>= 1.7.0'
23
+ spec.add_runtime_dependency 'avro', '>= 1.7.0', '< 1.11'
23
24
 
24
25
  spec.add_development_dependency 'appraisal'
25
- spec.add_development_dependency 'bundler', '~> 1.11'
26
+ spec.add_development_dependency 'bundler', '~> 2.0'
27
+ spec.add_development_dependency 'json_spec'
28
+ spec.add_development_dependency 'overcommit'
26
29
  spec.add_development_dependency 'rake', '~> 10.0'
27
30
  spec.add_development_dependency 'rspec', '~> 3.0'
28
31
  spec.add_development_dependency 'rspec-its'
29
- spec.add_development_dependency 'json_spec'
32
+ spec.add_development_dependency 'salsify_rubocop', '~> 0.85.0'
30
33
  spec.add_development_dependency 'simplecov'
31
- spec.add_development_dependency 'salsify_rubocop', '~> 0.47.0'
32
- 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.10.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "avro", "1.8.2"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "avro", "1.9.0"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "avro", "1.9.1"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "avro", "1.8.2"
6
+ gem "avro-patches", "< 1.0.0"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "avro-patches", ">= 1.0.0"
6
+
7
+ gemspec path: "../"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/version'
2
4
  require 'avro/builder/dsl'
3
5
  require 'avro/builder/schema_store'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/dsl_attributes'
2
4
 
3
5
  module Avro
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -22,9 +24,7 @@ module Avro
22
24
  key_str = Avro::Name.make_fullname(key.to_s, namespace && namespace.to_s)
23
25
  object = schema_objects[key_str]
24
26
 
25
- if object.nil? && !schema_names.include?(key.to_s)
26
- object = builder.import(key)
27
- end
27
+ object = builder.import(key) if object.nil? && !schema_names.include?(key.to_s)
28
28
 
29
29
  raise DefinitionNotFoundError.new(key) if object.nil? && namespace.nil?
30
30
 
@@ -59,6 +59,7 @@ module Avro
59
59
 
60
60
  def store_by_fullname(object, fullname = object.fullname)
61
61
  raise DuplicateDefinitionError.new(fullname, object, schema_objects[fullname]) if schema_objects.key?(fullname)
62
+
62
63
  schema_objects.store(fullname, object)
63
64
  end
64
65
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro'
2
4
  require 'avro/builder/errors'
3
5
  require 'avro/builder/dsl_options'
@@ -96,6 +98,7 @@ module Avro
96
98
  def type_macro(name, type_object, options = {})
97
99
  raise "#{type_object.inspect} must be a type object" unless type_object.is_a?(Types::Type)
98
100
  raise "namespace cannot be included in name: #{name}" if name.to_s.index('.')
101
+
99
102
  type_clone = type_object.clone
100
103
  type_clone.send(:abstract=, true)
101
104
  cache.add_type_by_name(type_clone, name, options[:namespace] || namespace)
@@ -118,7 +121,15 @@ module Avro
118
121
  end
119
122
 
120
123
  def eval_file(name)
121
- file_path = find_file(name)
124
+ file_path = if namespace
125
+ begin
126
+ find_file([namespace, name].join('.'))
127
+ rescue FileNotFoundError
128
+ find_file(name)
129
+ end
130
+ else
131
+ find_file(name)
132
+ end
122
133
  instance_eval(File.read(file_path), file_path)
123
134
  end
124
135
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/type_factory'
2
4
  require 'avro/builder/aliasable'
3
5
 
@@ -12,7 +14,7 @@ module Avro
12
14
  include Avro::Builder::Aliasable
13
15
  include Avro::Builder::AnonymousTypes
14
16
 
15
- INTERNAL_ATTRIBUTES = %i(optional_field).to_set.freeze
17
+ INTERNAL_ATTRIBUTES = [:optional_field].to_set.freeze
16
18
 
17
19
  # These attributes may be set as options or via a block in the DSL
18
20
  dsl_attributes :doc, :default, :order
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  # TODO: eventually this should be refactored into something standalone
@@ -19,6 +21,8 @@ module Avro
19
21
  File.read(find_file(name))
20
22
  end
21
23
 
24
+ FileNotFoundError = Class.new(StandardError)
25
+
22
26
  def find_file(name)
23
27
  # Ensure that the file_name that is searched for begins with a slash (/)
24
28
  # and ends with a .rb extension. Additionally, if the name contains
@@ -31,7 +35,7 @@ module Avro
31
35
  end
32
36
  end.uniq
33
37
  raise "Multiple matches: #{matches}" if matches.size > 1
34
- raise "File not found #{file_name}" if matches.empty?
38
+ raise FileNotFoundError.new("File not found #{file_name}") if matches.empty?
35
39
 
36
40
  matches.first
37
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  class Railtie < Rails::Railtie
@@ -7,7 +9,7 @@ module Avro
7
9
  end
8
10
 
9
11
  rake_tasks do
10
- load File.expand_path('../rake/rails_avro_generate_task.rake', __FILE__)
12
+ load File.expand_path('rake/rails_avro_generate_task.rake', __dir__)
11
13
  end
12
14
  end
13
15
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/tasklib'
2
4
  require 'avro/builder'
3
5
 
@@ -31,6 +33,7 @@ module Avro
31
33
  desc task_desc
32
34
  task(name.to_sym => dependencies) do
33
35
  raise '"root" must be specified for Avro DSL files' unless root
36
+
34
37
  Avro::Builder.add_load_path(*[root, load_paths].flatten)
35
38
  Dir["#{root}/**/*.rb"].each do |dsl_file|
36
39
  puts "Generating Avro schema from #{dsl_file}"
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/rake/avro_generate_task'
2
- Avro::Builder::Rake::AvroGenerateTask.new(dependencies: %i(environment))
4
+ Avro::Builder::Rake::AvroGenerateTask.new(dependencies: [:environment])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  # This class implements a schema store that loads Avro::Builder
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
 
4
6
  # This concern is used by classes that create new Type instances.
5
7
  module TypeFactory
6
8
 
7
- NAMED_TYPES = %w(enum fixed record).map(&:freeze).to_set.freeze
8
- COMPLEX_TYPES = %w(array enum fixed map record union).map(&:freeze).to_set.freeze
9
+ NAMED_TYPES = ['enum', 'fixed', 'record'].map(&:freeze).to_set.freeze
10
+ COMPLEX_TYPES = ['array', 'enum', 'fixed', 'map', 'record', 'union'].map(&:freeze).to_set.freeze
9
11
  BUILTIN_TYPES = Avro::Schema::PRIMITIVE_TYPES.union(COMPLEX_TYPES).freeze
10
12
 
11
13
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/types/type'
2
4
  require 'avro/builder/types/complex_type'
3
5
  require 'avro/builder/types/type_referencer'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
4
6
  class EnumType < NamedType
5
7
 
6
- dsl_attribute :doc
8
+ dsl_attributes :doc, :default
7
9
 
8
10
  dsl_attribute :symbols do |*values|
9
11
  # Define symbols explicitly to support values as a splat or single array
@@ -25,12 +27,19 @@ module Avro
25
27
  def validate!
26
28
  super
27
29
  validate_required_attribute!(:symbols)
30
+ validate_enum_default!
28
31
  end
29
32
 
30
33
  private
31
34
 
35
+ def validate_enum_default!
36
+ if !default.nil? && !symbols.map(&:to_sym).include?(default.to_sym)
37
+ raise AttributeError.new("enum default '#{default}' must be one of the enum symbols: #{symbols}")
38
+ end
39
+ end
40
+
32
41
  def serialized_attributes
33
- { symbols: symbols, doc: doc }
42
+ { symbols: symbols, doc: doc, default: default }
34
43
  end
35
44
  end
36
45
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/namespaceable'
2
4
  require 'avro/builder/aliasable'
3
5
  require 'avro/builder/types/named_error_handling'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -6,7 +8,7 @@ module Avro
6
8
  class RecordType < Avro::Builder::Types::NamedType
7
9
  include Avro::Builder::AnonymousTypes
8
10
 
9
- DSL_METHODS = %i(required optional extends).to_set.freeze
11
+ DSL_METHODS = [:required, :optional, :extends].to_set.freeze
10
12
 
11
13
  dsl_attribute :doc
12
14
  dsl_attribute_alias :type_doc, :doc
@@ -53,8 +55,8 @@ module Avro
53
55
 
54
56
  # Adds fields from the record with the specified name to the current
55
57
  # record.
56
- def extends(name)
57
- fields.merge!(cache.lookup_named_type(name, namespace).duplicated_fields)
58
+ def extends(name, options = {})
59
+ fields.merge!(cache.lookup_named_type(name, options.delete(:namespace) || namespace).duplicated_fields)
58
60
  end
59
61
 
60
62
  def to_h(reference_state = SchemaSerializerReferenceState.new)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -82,9 +84,7 @@ module Avro
82
84
 
83
85
  def validate_required_attribute!(attribute_name)
84
86
  value = public_send(attribute_name)
85
- if value.nil? || value.respond_to?(:empty?) && value.empty?
86
- required_attribute_error!(attribute_name)
87
- end
87
+ required_attribute_error!(attribute_name) if value.nil? || value.respond_to?(:empty?) && value.empty?
88
88
  end
89
89
 
90
90
  attr_accessor :field, :cache
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro/builder/type_factory'
2
4
 
3
5
  module Avro
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
5
  module Types
@@ -5,7 +7,7 @@ module Avro
5
7
  include Avro::Builder::Types::ComplexType
6
8
  include Avro::Builder::Types::TypeReferencer
7
9
 
8
- NULL_TYPE = 'null'.freeze
10
+ NULL_TYPE = 'null'
9
11
 
10
12
  dsl_attribute :types do |*types|
11
13
  if !types.empty?
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avro
2
4
  module Builder
3
- VERSION = '0.15.0.rc0'.freeze
5
+ VERSION = '0.17.0'
4
6
  end
5
7
  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.rc0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salsify Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-26 00:00:00.000000000 Z
11
+ date: 2020-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.7.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.11'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 1.7.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.11'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: appraisal
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,72 +50,72 @@ dependencies:
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '1.11'
53
+ version: '2.0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '1.11'
60
+ version: '2.0'
55
61
  - !ruby/object:Gem::Dependency
56
- name: rake
62
+ name: json_spec
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - "~>"
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '10.0'
67
+ version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
- version: '10.0'
74
+ version: '0'
69
75
  - !ruby/object:Gem::Dependency
70
- name: rspec
76
+ name: overcommit
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - "~>"
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: '3.0'
81
+ version: '0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - "~>"
86
+ - - ">="
81
87
  - !ruby/object:Gem::Version
82
- version: '3.0'
88
+ version: '0'
83
89
  - !ruby/object:Gem::Dependency
84
- name: rspec-its
90
+ name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ">="
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '0'
95
+ version: '10.0'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ">="
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '0'
102
+ version: '10.0'
97
103
  - !ruby/object:Gem::Dependency
98
- name: json_spec
104
+ name: rspec
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ">="
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: '3.0'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ">="
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: '3.0'
111
117
  - !ruby/object:Gem::Dependency
112
- name: simplecov
118
+ name: rspec-its
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
121
  - - ">="
@@ -128,16 +134,16 @@ dependencies:
128
134
  requirements:
129
135
  - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: 0.47.0
137
+ version: 0.85.0
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
142
  - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: 0.47.0
144
+ version: 0.85.0
139
145
  - !ruby/object:Gem::Dependency
140
- name: overcommit
146
+ name: simplecov
141
147
  requirement: !ruby/object:Gem::Requirement
142
148
  requirements:
143
149
  - - ">="
@@ -172,8 +178,12 @@ files:
172
178
  - avro-builder.gemspec
173
179
  - bin/console
174
180
  - bin/setup
175
- - gemfiles/avro_official.gemfile
176
- - gemfiles/avro_salsify_fork.gemfile
181
+ - gemfiles/avro_1.10.0.gemfile
182
+ - gemfiles/avro_1.8.2.gemfile
183
+ - gemfiles/avro_1.9.0.gemfile
184
+ - gemfiles/avro_1.9.1.gemfile
185
+ - gemfiles/avro_patches_0.x.gemfile
186
+ - gemfiles/avro_patches_1.x.gemfile
177
187
  - lib/avro/builder.rb
178
188
  - lib/avro/builder/aliasable.rb
179
189
  - lib/avro/builder/anonymous_types.rb
@@ -212,7 +222,7 @@ homepage: https://github.com/salsify/avro-builder.git
212
222
  licenses:
213
223
  - MIT
214
224
  metadata: {}
215
- post_install_message:
225
+ post_install_message:
216
226
  rdoc_options: []
217
227
  require_paths:
218
228
  - lib
@@ -223,13 +233,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
233
  version: '0'
224
234
  required_rubygems_version: !ruby/object:Gem::Requirement
225
235
  requirements:
226
- - - ">"
236
+ - - ">="
227
237
  - !ruby/object:Gem::Version
228
- version: 1.3.1
238
+ version: '0'
229
239
  requirements: []
230
- rubyforge_project:
231
- rubygems_version: 2.6.10
232
- signing_key:
240
+ rubyforge_project:
241
+ rubygems_version: 2.7.6.2
242
+ signing_key:
233
243
  specification_version: 4
234
244
  summary: Ruby DSL to create Avro schemas
235
245
  test_files: []
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "avro-salsify-fork", "1.9.0.0", :require => "avro"
6
-
7
- gemspec :path => "../"