avro-builder 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -4
- data/Appraisals +3 -3
- data/CHANGELOG.md +4 -0
- data/README.md +39 -4
- data/avro-builder.gemspec +2 -1
- data/gemfiles/avro_official.gemfile +1 -1
- data/gemfiles/{avro_salsify_fork.gemfile → avro_patches.gemfile} +1 -1
- data/lib/avro/builder/dsl.rb +9 -1
- data/lib/avro/builder/file_handler.rb +3 -1
- data/lib/avro/builder/types/record_type.rb +2 -2
- data/lib/avro/builder/version.rb +1 -1
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9c0ae91d30be185125e91fccc2f02c08106f155a
         | 
| 4 | 
            +
              data.tar.gz: 99daec1be8f8027c10b264883988ff78ea58d68e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5f2c5a8e95c3a0cadce29089225169ab0f8656a0a96728f33e50428684de826e062ffbb89147d02fdf0008a815ef01f98eb7fd4a92b184e1c47b24fe4c2d1fd8
         | 
| 7 | 
            +
              data.tar.gz: 240cbf70f74ce19db34ac8ba17f1d5fe16bd6c6eda09b6df14139b580d4f03b487f7c6deedbf40abbd6579d6a67588691c5686cc376ff20c0a51d178584b6496
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            language: ruby
         | 
| 2 2 | 
             
            rvm:
         | 
| 3 | 
            -
              - 2.4. | 
| 4 | 
            -
              - 2.3. | 
| 5 | 
            -
              - 2.2. | 
| 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- | 
| 13 | 
            +
              - bundle exec appraisal avro-patches rspec
         | 
    
        data/Appraisals
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        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  | 
| 287 | 
            -
             | 
| 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- | 
| 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
         | 
    
        data/avro-builder.gemspec
    CHANGED
    
    | @@ -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. | 
| 32 | 
            +
              spec.add_development_dependency 'salsify_rubocop', '~> 0.48.0'
         | 
| 32 33 | 
             
              spec.add_development_dependency 'overcommit'
         | 
| 33 34 | 
             
            end
         | 
    
        data/lib/avro/builder/dsl.rb
    CHANGED
    
    | @@ -118,7 +118,15 @@ module Avro | |
| 118 118 | 
             
                  end
         | 
| 119 119 |  | 
| 120 120 | 
             
                  def eval_file(name)
         | 
| 121 | 
            -
                    file_path =  | 
| 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)
         | 
    
        data/lib/avro/builder/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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. | 
| 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. | 
| 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/ | 
| 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
         |