hana 1.3.4 → 1.3.5
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/lib/hana.rb +38 -4
- data/test/helper.rb +4 -0
- metadata +13 -8
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8967fc878a6eb09d469a2020f6dcef6d78dbced59b3432a7627a1d82064d1cab
         | 
| 4 | 
            +
              data.tar.gz: fe88760ea18ff82c272b737e6e7c366dbecda53a1248b6307fc461d056433070
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 196a984b465565c19efd2e0fe6e08aa718b3dd846d36059242bfc36455deb9f0871aa66c32d892fe7b7b0bae80ed75c471a35dab6f9bc35af4c57a9253fb48e5
         | 
| 7 | 
            +
              data.tar.gz: b483189d57bd549d4c6072a9bd0adc84a480367fd20720e26c51dd40a48c96dedaf5aced42b64e478dd6ecf4c8554a147efaab9710bd7ee23e20d49871c32507
         | 
    
        data/lib/hana.rb
    CHANGED
    
    | @@ -1,11 +1,17 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Hana
         | 
| 4 | 
            -
              VERSION = '1.3. | 
| 4 | 
            +
              VERSION = '1.3.5'
         | 
| 5 5 |  | 
| 6 6 | 
             
              class Pointer
         | 
| 7 7 | 
             
                include Enumerable
         | 
| 8 8 |  | 
| 9 | 
            +
                class Exception < StandardError
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                class FormatError < Exception
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 9 15 | 
             
                def initialize path
         | 
| 10 16 | 
             
                  @path = Pointer.parse path
         | 
| 11 17 | 
             
                end
         | 
| @@ -32,6 +38,11 @@ module Hana | |
| 32 38 |  | 
| 33 39 | 
             
                def self.parse path
         | 
| 34 40 | 
             
                  return [''] if path == '/'
         | 
| 41 | 
            +
                  return []   if path == ''
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  unless path.start_with? '/'
         | 
| 44 | 
            +
                    raise FormatError, "JSON Pointer should start with a slash"
         | 
| 45 | 
            +
                  end
         | 
| 35 46 |  | 
| 36 47 | 
             
                  parts = path.sub(/^\//, '').split(/(?<!\^)\//).each { |part|
         | 
| 37 48 | 
             
                    part.gsub!(/\^[\/^]|~[01]/) { |m| ESC[m] }
         | 
| @@ -68,6 +79,9 @@ module Hana | |
| 68 79 | 
             
                class MissingTargetException < Exception
         | 
| 69 80 | 
             
                end
         | 
| 70 81 |  | 
| 82 | 
            +
                class InvalidPath < Exception
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
             | 
| 71 85 | 
             
                def initialize is
         | 
| 72 86 | 
             
                  @is = is
         | 
| 73 87 | 
             
                end
         | 
| @@ -90,12 +104,22 @@ module Hana | |
| 90 104 | 
             
                OP    = 'op' # :nodoc:
         | 
| 91 105 |  | 
| 92 106 | 
             
                def add ins, doc
         | 
| 93 | 
            -
                   | 
| 107 | 
            +
                  unless ins.key?('path')
         | 
| 108 | 
            +
                    raise Hana::Patch::InvalidPath, "missing 'path' parameter"
         | 
| 109 | 
            +
                  end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
                  path = ins['path']
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  unless path
         | 
| 114 | 
            +
                    raise Hana::Patch::InvalidPath, "null is not valid value for 'path'"
         | 
| 115 | 
            +
                  end
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                  list = Pointer.parse path
         | 
| 94 118 | 
             
                  key  = list.pop
         | 
| 95 119 | 
             
                  dest = Pointer.eval list, doc
         | 
| 96 120 | 
             
                  obj  = ins.fetch VALUE
         | 
| 97 121 |  | 
| 98 | 
            -
                  raise(MissingTargetException, ins[ | 
| 122 | 
            +
                  raise(MissingTargetException, ins['path']) unless dest
         | 
| 99 123 |  | 
| 100 124 | 
             
                  if key
         | 
| 101 125 | 
             
                    add_op dest, key, obj
         | 
| @@ -117,6 +141,12 @@ module Hana | |
| 117 141 | 
             
                  src      = Pointer.eval from, doc
         | 
| 118 142 | 
             
                  dest     = Pointer.eval to, doc
         | 
| 119 143 |  | 
| 144 | 
            +
                  unless Array === src
         | 
| 145 | 
            +
                    unless src.key? from_key
         | 
| 146 | 
            +
                      raise Hana::Patch::MissingTargetException
         | 
| 147 | 
            +
                    end
         | 
| 148 | 
            +
                  end
         | 
| 149 | 
            +
             | 
| 120 150 | 
             
                  obj = rm_op src, from_key
         | 
| 121 151 | 
             
                  add_op dest, key, obj
         | 
| 122 152 | 
             
                  doc
         | 
| @@ -134,7 +164,11 @@ module Hana | |
| 134 164 | 
             
                    raise Patch::IndexError unless from_key =~ /\A\d+\Z/
         | 
| 135 165 | 
             
                    obj = src.fetch from_key.to_i
         | 
| 136 166 | 
             
                  else
         | 
| 137 | 
            -
                     | 
| 167 | 
            +
                    begin
         | 
| 168 | 
            +
                      obj = src.fetch from_key
         | 
| 169 | 
            +
                    rescue KeyError => e
         | 
| 170 | 
            +
                      raise Hana::Patch::MissingTargetException, e.message
         | 
| 171 | 
            +
                    end
         | 
| 138 172 | 
             
                  end
         | 
| 139 173 |  | 
| 140 174 | 
             
                  add_op dest, key, obj
         | 
    
        data/test/helper.rb
    CHANGED
    
    | @@ -67,8 +67,12 @@ module Hana | |
| 67 67 | 
             
                    [KeyError]
         | 
| 68 68 | 
             
                  when /Unrecognized op 'spam'/ then
         | 
| 69 69 | 
             
                    [Hana::Patch::Exception]
         | 
| 70 | 
            +
                  when /missing 'path'|null is not valid value for 'path'/ then
         | 
| 71 | 
            +
                    [Hana::Patch::InvalidPath]
         | 
| 70 72 | 
             
                  when /missing|non-existent/ then
         | 
| 71 73 | 
             
                    [Hana::Patch::MissingTargetException]
         | 
| 74 | 
            +
                  when /JSON Pointer should start with a slash/ then
         | 
| 75 | 
            +
                    [Hana::Pointer::FormatError]
         | 
| 72 76 | 
             
                  else
         | 
| 73 77 | 
             
                    [Hana::Patch::FailedTestException]
         | 
| 74 78 | 
             
                  end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: hana
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.3. | 
| 4 | 
            +
              version: 1.3.5
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Aaron Patterson
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2019-01-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: minitest
         | 
| @@ -28,30 +28,36 @@ dependencies: | |
| 28 28 | 
             
              name: rdoc
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - - " | 
| 31 | 
            +
                - - ">="
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 33 | 
             
                    version: '4.0'
         | 
| 34 | 
            +
                - - "<"
         | 
| 35 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 36 | 
            +
                    version: '7'
         | 
| 34 37 | 
             
              type: :development
         | 
| 35 38 | 
             
              prerelease: false
         | 
| 36 39 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 40 | 
             
                requirements:
         | 
| 38 | 
            -
                - - " | 
| 41 | 
            +
                - - ">="
         | 
| 39 42 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 43 | 
             
                    version: '4.0'
         | 
| 44 | 
            +
                - - "<"
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: '7'
         | 
| 41 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 48 | 
             
              name: hoe
         | 
| 43 49 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 50 | 
             
                requirements:
         | 
| 45 51 | 
             
                - - "~>"
         | 
| 46 52 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            -
                    version: '3. | 
| 53 | 
            +
                    version: '3.17'
         | 
| 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: '3. | 
| 60 | 
            +
                    version: '3.17'
         | 
| 55 61 | 
             
            description: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
         | 
| 56 62 | 
             
            email:
         | 
| 57 63 | 
             
            - aaron@tenderlovemaking.com
         | 
| @@ -96,8 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 96 102 | 
             
                - !ruby/object:Gem::Version
         | 
| 97 103 | 
             
                  version: '0'
         | 
| 98 104 | 
             
            requirements: []
         | 
| 99 | 
            -
             | 
| 100 | 
            -
            rubygems_version: 2.7.6
         | 
| 105 | 
            +
            rubygems_version: 3.0.1
         | 
| 101 106 | 
             
            signing_key: 
         | 
| 102 107 | 
             
            specification_version: 4
         | 
| 103 108 | 
             
            summary: Implementation of [JSON Patch][1] and [JSON Pointer][2] RFC.
         |