avro-builder 0.16.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +77 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +8 -0
  5. data/.ruby-version +1 -1
  6. data/Appraisals +6 -4
  7. data/CHANGELOG.md +21 -0
  8. data/Gemfile +2 -0
  9. data/README.md +5 -14
  10. data/Rakefile +2 -0
  11. data/avro-builder.gemspec +10 -7
  12. data/gemfiles/{avro_patches.gemfile → avro_1.10.gemfile} +2 -2
  13. data/gemfiles/{avro_official.gemfile → avro_1.9.gemfile} +2 -2
  14. data/lib/avro/builder.rb +2 -0
  15. data/lib/avro/builder/aliasable.rb +2 -0
  16. data/lib/avro/builder/anonymous_types.rb +2 -0
  17. data/lib/avro/builder/definition_cache.rb +4 -3
  18. data/lib/avro/builder/dsl.rb +4 -0
  19. data/lib/avro/builder/dsl_attributes.rb +2 -0
  20. data/lib/avro/builder/dsl_options.rb +2 -0
  21. data/lib/avro/builder/enum.rb +2 -0
  22. data/lib/avro/builder/errors.rb +2 -0
  23. data/lib/avro/builder/field.rb +3 -1
  24. data/lib/avro/builder/file_handler.rb +2 -0
  25. data/lib/avro/builder/fixed.rb +2 -0
  26. data/lib/avro/builder/namespaceable.rb +2 -0
  27. data/lib/avro/builder/railtie.rb +3 -1
  28. data/lib/avro/builder/rake/avro_generate_task.rb +4 -0
  29. data/lib/avro/builder/rake/rails_avro_generate_task.rake +3 -1
  30. data/lib/avro/builder/record.rb +2 -0
  31. data/lib/avro/builder/schema_serializer_reference_state.rb +2 -0
  32. data/lib/avro/builder/schema_store.rb +2 -0
  33. data/lib/avro/builder/type_factory.rb +4 -2
  34. data/lib/avro/builder/types.rb +2 -0
  35. data/lib/avro/builder/types/array_type.rb +2 -0
  36. data/lib/avro/builder/types/complex_type.rb +2 -0
  37. data/lib/avro/builder/types/enum_type.rb +11 -2
  38. data/lib/avro/builder/types/fixed_type.rb +2 -0
  39. data/lib/avro/builder/types/map_type.rb +2 -0
  40. data/lib/avro/builder/types/named_error_handling.rb +2 -0
  41. data/lib/avro/builder/types/named_type.rb +2 -0
  42. data/lib/avro/builder/types/record_type.rb +5 -2
  43. data/lib/avro/builder/types/top_level.rb +2 -0
  44. data/lib/avro/builder/types/type.rb +3 -3
  45. data/lib/avro/builder/types/type_referencer.rb +2 -0
  46. data/lib/avro/builder/types/union_type.rb +3 -1
  47. data/lib/avro/builder/version.rb +3 -1
  48. metadata +52 -33
  49. data/.travis.yml +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9c0ae91d30be185125e91fccc2f02c08106f155a
4
- data.tar.gz: 99daec1be8f8027c10b264883988ff78ea58d68e
2
+ SHA256:
3
+ metadata.gz: 2223e0a5e244cc9dc9e57be463e120b747fbaa9f3c9dc22bf8f7a7da43c2d4b9
4
+ data.tar.gz: 9e0129b8c9f1f0fd142beabe1dfda1f2fadc3de3e0105f4770995f4f15e323b7
5
5
  SHA512:
6
- metadata.gz: 5f2c5a8e95c3a0cadce29089225169ab0f8656a0a96728f33e50428684de826e062ffbb89147d02fdf0008a815ef01f98eb7fd4a92b184e1c47b24fe4c2d1fd8
7
- data.tar.gz: 240cbf70f74ce19db34ac8ba17f1d5fe16bd6c6eda09b6df14139b580d4f03b487f7c6deedbf40abbd6579d6a67588691c5686cc376ff20c0a51d178584b6496
6
+ metadata.gz: 591e9422ed7a64adaf2969a9fd069f805398d8edefd64545900ef9e5bfb6cab4dcc1c41d1655886d83026bedc0bd56c914a31f495b732788d9f043d7f397fba0
7
+ data.tar.gz: 0d1da2ec6ae6a024a59035150f9423663a1550de37701ff204b5a8812ac221332d4ffa90d5ddb48a9ace7d16166d2e4bb9835e8d9941bda0934c4441ec82f835
@@ -0,0 +1,77 @@
1
+ version: 2.1
2
+ jobs:
3
+ lint:
4
+ docker:
5
+ - image: salsify/ruby_ci:2.6.6
6
+ working_directory: ~/avro-builder
7
+ steps:
8
+ - checkout
9
+ - restore_cache:
10
+ keys:
11
+ - v2-gems-ruby-2.6.6-{{ checksum "avro-builder.gemspec" }}-{{ checksum "Gemfile" }}
12
+ - v2-gems-ruby-2.6.6-
13
+ - run:
14
+ name: Install Gems
15
+ command: |
16
+ if ! bundle check --path=vendor/bundle; then
17
+ bundle install --path=vendor/bundle --jobs=4 --retry=3
18
+ bundle clean
19
+ fi
20
+ - save_cache:
21
+ key: v2-gems-ruby-2.6.6-{{ checksum "avro-builder.gemspec" }}-{{ checksum "Gemfile" }}
22
+ paths:
23
+ - "vendor/bundle"
24
+ - "gemfiles/vendor/bundle"
25
+ - run:
26
+ name: Run Rubocop
27
+ command: bundle exec rubocop
28
+ test:
29
+ parameters:
30
+ gemfile:
31
+ type: string
32
+ ruby-version:
33
+ type: string
34
+ docker:
35
+ - image: salsify/ruby_ci:<< parameters.ruby-version >>
36
+ environment:
37
+ CIRCLE_TEST_REPORTS: "test-results"
38
+ BUNDLE_GEMFILE: << parameters.gemfile >>
39
+ working_directory: ~/avro-builder
40
+ steps:
41
+ - checkout
42
+ - restore_cache:
43
+ keys:
44
+ - v2-gems-ruby-<< parameters.ruby-version >>-{{ checksum "avro-builder.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
45
+ - v2-gems-ruby-<< parameters.ruby-version >>-
46
+ - run:
47
+ name: Install Gems
48
+ command: |
49
+ if ! bundle check --path=vendor/bundle; then
50
+ bundle install --path=vendor/bundle --jobs=4 --retry=3
51
+ bundle clean
52
+ fi
53
+ - save_cache:
54
+ key: v2-gems-ruby-<< parameters.ruby-version >>-{{ checksum "avro-builder.gemspec" }}-{{ checksum "<< parameters.gemfile >>" }}
55
+ paths:
56
+ - "vendor/bundle"
57
+ - "gemfiles/vendor/bundle"
58
+ - run:
59
+ name: Run Tests
60
+ command: |
61
+ bundle exec rspec --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec/junit.xml --format progress spec
62
+ - store_test_results:
63
+ path: "test-results"
64
+ workflows:
65
+ build:
66
+ jobs:
67
+ - lint
68
+ - test:
69
+ matrix:
70
+ parameters:
71
+ gemfile:
72
+ - "gemfiles/avro_1.9.gemfile"
73
+ - "gemfiles/avro_1.10.gemfile"
74
+ ruby-version:
75
+ - "2.6.6"
76
+ - "2.7.2"
77
+ - "3.0.0"
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  /gemfiles/*.lock
11
+ /gemfiles/.bundle
data/.rubocop.yml CHANGED
@@ -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
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.3
1
+ 2.6.6
data/Appraisals CHANGED
@@ -1,7 +1,9 @@
1
- appraise 'avro-official' do
2
- gem 'avro', '1.8.2'
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'avro-1.9' do
4
+ gem 'avro', '1.9.2'
3
5
  end
4
6
 
5
- appraise 'avro-patches' do
6
- gem 'avro-patches'
7
+ appraise 'avro-1.10' do
8
+ gem 'avro', '1.10.1'
7
9
  end
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # avro-builder changelog
2
2
 
3
+ ## v1.0.1
4
+ - Bug fix: Fix pretty formatting of schemas for Rails applications that don't
5
+ use oj or yajl by removing the dependency on multi_json.
6
+
7
+ ## v1.0.0
8
+ - Drop support for Avro < 1.9.
9
+ - Drop support for Ruby < 2.6.
10
+ - Add Ruby 3.0 support.
11
+ - Bug fix: Use multi_json to encode schemas and ensure that a JSON encoder
12
+ is always present.
13
+
14
+ ## v0.17.0
15
+ - Add support for enum defaults introduced in Avro v1.10.0.
16
+
17
+ ## v0.16.2
18
+ - Allow avro version up to v1.10.x. Support will be added for new
19
+ functionality in Avro v1.10 in a later release.
20
+
21
+ ## v0.16.1
22
+ - Require avro version prior to v1.10.0.
23
+
3
24
  ## v0.16.0
4
25
  - Add support for providing an explicit `namespace` on `extend`.
5
26
  - Default lookup to current namespace before falling back on global search.
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
@@ -1,9 +1,9 @@
1
1
  # Avro::Builder
2
2
 
3
- [![Build Status](https://travis-ci.org/salsify/avro-builder.svg?branch=master)][travis]
3
+ [![Build Status](https://circleci.com/gh/salsify/avro-builder.svg?style=svg)][circleci]
4
4
  [![Gem Version](https://badge.fury.io/rb/avro-builder.svg)](https://badge.fury.io/rb/avro-builder)
5
5
 
6
- [travis]: http://travis-ci.org/salsify/avro-builder
6
+ [circleci]: https://circleci.com/gh/salsify/avro-builder
7
7
 
8
8
  `Avro::Builder` provides a Ruby DSL to create [Apache Avro](https://avro.apache.org/docs/current/) Schemas.
9
9
 
@@ -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
@@ -280,18 +283,6 @@ The DSL supports setting a logical type on any type except a union. The logical
280
283
  types defined in the Avro [spec](https://avro.apache.org/docs/1.8.1/spec.html#Logical+Types)
281
284
  are more limited.
282
285
 
283
- The official Ruby `avro` gem does not yet support logical types:
284
- [AVRO-1695](https://issues.apache.org/jira/browse/AVRO-1695).
285
-
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:
290
-
291
- ```ruby
292
- gem 'avro-patches'
293
- ```
294
-
295
286
  A logical type can be specified for a field using the `logical_type` attribute:
296
287
 
297
288
  ```ruby
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'
data/avro-builder.gemspec CHANGED
@@ -1,6 +1,6 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'avro/builder/version'
6
6
 
@@ -20,15 +20,18 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_runtime_dependency 'avro', '>= 1.7.0'
23
+ spec.required_ruby_version = '>= 2.6'
24
+
25
+ spec.add_runtime_dependency 'avro', '>= 1.9.0', '< 1.11'
24
26
 
25
27
  spec.add_development_dependency 'appraisal'
26
- spec.add_development_dependency 'bundler', '~> 1.11'
28
+ spec.add_development_dependency 'bundler', '~> 2.0'
29
+ spec.add_development_dependency 'json_spec'
30
+ spec.add_development_dependency 'overcommit'
27
31
  spec.add_development_dependency 'rake', '~> 10.0'
28
32
  spec.add_development_dependency 'rspec', '~> 3.0'
29
33
  spec.add_development_dependency 'rspec-its'
30
- spec.add_development_dependency 'json_spec'
34
+ spec.add_development_dependency 'rspec_junit_formatter'
35
+ spec.add_development_dependency 'salsify_rubocop', '~> 1.0.1'
31
36
  spec.add_development_dependency 'simplecov'
32
- spec.add_development_dependency 'salsify_rubocop', '~> 0.48.0'
33
- spec.add_development_dependency 'overcommit'
34
37
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "avro-patches"
5
+ gem "avro", "1.10.1"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "avro", "1.8.2"
5
+ gem "avro", "1.9.2"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
data/lib/avro/builder.rb CHANGED
@@ -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,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avro'
4
+ require 'json'
2
5
  require 'avro/builder/errors'
3
6
  require 'avro/builder/dsl_options'
4
7
  require 'avro/builder/dsl_attributes'
@@ -96,6 +99,7 @@ module Avro
96
99
  def type_macro(name, type_object, options = {})
97
100
  raise "#{type_object.inspect} must be a type object" unless type_object.is_a?(Types::Type)
98
101
  raise "namespace cannot be included in name: #{name}" if name.to_s.index('.')
102
+
99
103
  type_clone = type_object.clone
100
104
  type_clone.send(:abstract=, true)
101
105
  cache.add_type_by_name(type_clone, name, options[:namespace] || namespace)
@@ -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
@@ -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
 
@@ -10,6 +12,7 @@ module Avro
10
12
  :load_paths, :dependencies, :filetype
11
13
 
12
14
  def initialize(name: :generate, dependencies: [])
15
+ super()
13
16
  @name = name
14
17
  @task_namespace = :avro
15
18
  @task_desc = 'Generate Avro schema files from Avro::Builder DSL'
@@ -31,6 +34,7 @@ module Avro
31
34
  desc task_desc
32
35
  task(name.to_sym => dependencies) do
33
36
  raise '"root" must be specified for Avro DSL files' unless root
37
+
34
38
  Avro::Builder.add_load_path(*[root, load_paths].flatten)
35
39
  Dir["#{root}/**/*.rb"].each do |dsl_file|
36
40
  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,12 +8,13 @@ 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
13
15
 
14
- def initialize(name = nil, options: {}, cache:, field: nil, &block)
16
+ def initialize(name = nil, cache:, options: {}, field: nil, &block) # rubocop:disable Lint/MissingSuper
17
+ # TODO: Fix missing call to super
15
18
  @avro_type_name = :record
16
19
  @name = name
17
20
  @cache = cache
@@ -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.16.0'.freeze
5
+ VERSION = '1.0.1'
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.16.0
4
+ version: 1.0.1
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-10-17 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avro
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.0
19
+ version: 1.9.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
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 1.7.0
29
+ version: 1.9.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,58 +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
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rake
71
91
  requirement: !ruby/object:Gem::Requirement
72
92
  requirements:
73
93
  - - "~>"
74
94
  - !ruby/object:Gem::Version
75
- version: '3.0'
95
+ version: '10.0'
76
96
  type: :development
77
97
  prerelease: false
78
98
  version_requirements: !ruby/object:Gem::Requirement
79
99
  requirements:
80
100
  - - "~>"
81
101
  - !ruby/object:Gem::Version
82
- version: '3.0'
102
+ version: '10.0'
83
103
  - !ruby/object:Gem::Dependency
84
- name: rspec-its
104
+ name: rspec
85
105
  requirement: !ruby/object:Gem::Requirement
86
106
  requirements:
87
- - - ">="
107
+ - - "~>"
88
108
  - !ruby/object:Gem::Version
89
- version: '0'
109
+ version: '3.0'
90
110
  type: :development
91
111
  prerelease: false
92
112
  version_requirements: !ruby/object:Gem::Requirement
93
113
  requirements:
94
- - - ">="
114
+ - - "~>"
95
115
  - !ruby/object:Gem::Version
96
- version: '0'
116
+ version: '3.0'
97
117
  - !ruby/object:Gem::Dependency
98
- name: json_spec
118
+ name: rspec-its
99
119
  requirement: !ruby/object:Gem::Requirement
100
120
  requirements:
101
121
  - - ">="
@@ -109,7 +129,7 @@ dependencies:
109
129
  - !ruby/object:Gem::Version
110
130
  version: '0'
111
131
  - !ruby/object:Gem::Dependency
112
- name: simplecov
132
+ name: rspec_junit_formatter
113
133
  requirement: !ruby/object:Gem::Requirement
114
134
  requirements:
115
135
  - - ">="
@@ -128,16 +148,16 @@ dependencies:
128
148
  requirements:
129
149
  - - "~>"
130
150
  - !ruby/object:Gem::Version
131
- version: 0.48.0
151
+ version: 1.0.1
132
152
  type: :development
133
153
  prerelease: false
134
154
  version_requirements: !ruby/object:Gem::Requirement
135
155
  requirements:
136
156
  - - "~>"
137
157
  - !ruby/object:Gem::Version
138
- version: 0.48.0
158
+ version: 1.0.1
139
159
  - !ruby/object:Gem::Dependency
140
- name: overcommit
160
+ name: simplecov
141
161
  requirement: !ruby/object:Gem::Requirement
142
162
  requirements:
143
163
  - - ">="
@@ -157,12 +177,12 @@ executables: []
157
177
  extensions: []
158
178
  extra_rdoc_files: []
159
179
  files:
180
+ - ".circleci/config.yml"
160
181
  - ".gitignore"
161
182
  - ".overcommit.yml"
162
183
  - ".rspec"
163
184
  - ".rubocop.yml"
164
185
  - ".ruby-version"
165
- - ".travis.yml"
166
186
  - Appraisals
167
187
  - CHANGELOG.md
168
188
  - Gemfile
@@ -172,8 +192,8 @@ files:
172
192
  - avro-builder.gemspec
173
193
  - bin/console
174
194
  - bin/setup
175
- - gemfiles/avro_official.gemfile
176
- - gemfiles/avro_patches.gemfile
195
+ - gemfiles/avro_1.10.gemfile
196
+ - gemfiles/avro_1.9.gemfile
177
197
  - lib/avro/builder.rb
178
198
  - lib/avro/builder/aliasable.rb
179
199
  - lib/avro/builder/anonymous_types.rb
@@ -212,7 +232,7 @@ homepage: https://github.com/salsify/avro-builder.git
212
232
  licenses:
213
233
  - MIT
214
234
  metadata: {}
215
- post_install_message:
235
+ post_install_message:
216
236
  rdoc_options: []
217
237
  require_paths:
218
238
  - lib
@@ -220,16 +240,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
240
  requirements:
221
241
  - - ">="
222
242
  - !ruby/object:Gem::Version
223
- version: '0'
243
+ version: '2.6'
224
244
  required_rubygems_version: !ruby/object:Gem::Requirement
225
245
  requirements:
226
246
  - - ">="
227
247
  - !ruby/object:Gem::Version
228
248
  version: '0'
229
249
  requirements: []
230
- rubyforge_project:
231
- rubygems_version: 2.6.10
232
- signing_key:
250
+ rubygems_version: 3.0.8
251
+ signing_key:
233
252
  specification_version: 4
234
253
  summary: Ruby DSL to create Avro schemas
235
254
  test_files: []
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.4.1
4
- - 2.3.4
5
- - 2.2.7
6
- before_install:
7
- - gem update --system
8
- before_script:
9
- - bundle exec appraisal install --jobs=3
10
- script:
11
- - bundle exec rubocop
12
- - bundle exec appraisal avro-official rspec
13
- - bundle exec appraisal avro-patches rspec