met_museum 1.4.0 → 1.4.1
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/.github/workflows/ruby.yml +2 -1
- data/Gemfile.lock +3 -3
- data/LICENSE.txt +1 -1
- data/lib/met_museum/collection.rb +15 -11
- data/lib/met_museum/version.rb +1 -1
- data/lib/met_museum.rb +0 -3
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 747d015331b55f840aa0065fbfc3e2822fda2f2f52a5a6ddede4b7f62ade5735
         | 
| 4 | 
            +
              data.tar.gz: ac3158ff771e89fc1fb3d563920b02797c97c15be9dbd8a1ed5618649b53194b
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c02a1a47672656535464183e79b4129b0d4b12632b48382afe8a3aff36d24af355620b51097324157f04342c361dcf62d74396916b52edf05359de6a011a37b1
         | 
| 7 | 
            +
              data.tar.gz: 33eedda5f92fe536476dd03c0ba50aad36610f09440fcf15317b905baeac576108d3ac7993269a2619ed403c3ab5883a21193d87da2f72c3fb9e5358a67dd58f
         | 
    
        data/.github/workflows/ruby.yml
    CHANGED
    
    | @@ -15,7 +15,7 @@ jobs: | |
| 15 15 | 
             
                runs-on: ubuntu-latest
         | 
| 16 16 | 
             
                strategy:
         | 
| 17 17 | 
             
                  matrix:
         | 
| 18 | 
            -
                    ruby: [ '2. | 
| 18 | 
            +
                    ruby: [ '2.6', '2.7', '3.0', '3.1' ]
         | 
| 19 19 | 
             
                name: Ruby ${{ matrix.ruby }} spec
         | 
| 20 20 | 
             
                steps:
         | 
| 21 21 | 
             
                - uses: actions/checkout@v2
         | 
| @@ -26,6 +26,7 @@ jobs: | |
| 26 26 | 
             
                  # uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
         | 
| 27 27 | 
             
                  with:
         | 
| 28 28 | 
             
                    ruby-version: ${{ matrix.ruby }}
         | 
| 29 | 
            +
                    bundler-cache: true
         | 
| 29 30 | 
             
                - name: Install dependencies
         | 
| 30 31 | 
             
                  run: bundle install
         | 
| 31 32 | 
             
                - name: Run spec
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                met_museum (1.4. | 
| 4 | 
            +
                met_museum (1.4.1)
         | 
| 5 5 | 
             
                  faraday
         | 
| 6 6 | 
             
                  oj
         | 
| 7 7 |  | 
| @@ -26,7 +26,7 @@ GEM | |
| 26 26 | 
             
                rainbow (3.0.0)
         | 
| 27 27 | 
             
                rake (13.0.1)
         | 
| 28 28 | 
             
                regexp_parser (1.7.1)
         | 
| 29 | 
            -
                rexml (3.2. | 
| 29 | 
            +
                rexml (3.2.5)
         | 
| 30 30 | 
             
                rspec (3.8.0)
         | 
| 31 31 | 
             
                  rspec-core (~> 3.8.0)
         | 
| 32 32 | 
             
                  rspec-expectations (~> 3.8.0)
         | 
| @@ -54,7 +54,7 @@ GEM | |
| 54 54 | 
             
                rubocop-ast (0.1.0)
         | 
| 55 55 | 
             
                  parser (>= 2.7.0.1)
         | 
| 56 56 | 
             
                ruby-progressbar (1.10.1)
         | 
| 57 | 
            -
                ruby2_keywords (0.0. | 
| 57 | 
            +
                ruby2_keywords (0.0.5)
         | 
| 58 58 | 
             
                unicode-display_width (1.7.0)
         | 
| 59 59 |  | 
| 60 60 | 
             
            PLATFORMS
         | 
    
        data/LICENSE.txt
    CHANGED
    
    
| @@ -2,6 +2,9 @@ require "met_museum/api_expections" | |
| 2 2 | 
             
            require "met_museum/endpoint"
         | 
| 3 3 | 
             
            require "met_museum/http_status_code"
         | 
| 4 4 |  | 
| 5 | 
            +
            require "faraday"
         | 
| 6 | 
            +
            require "oj"
         | 
| 7 | 
            +
             | 
| 5 8 | 
             
            module MetMuseum
         | 
| 6 9 | 
             
              class Collection
         | 
| 7 10 | 
             
                # Return a listing of all valid Object IDs available to use
         | 
| @@ -15,10 +18,11 @@ module MetMuseum | |
| 15 18 | 
             
                    metadataDate: nil,
         | 
| 16 19 | 
             
                    departmentIds: nil
         | 
| 17 20 | 
             
                  }.merge(args)
         | 
| 21 | 
            +
             | 
| 18 22 | 
             
                  options[:metadataDate] = check_date(options[:metadataDate])
         | 
| 19 23 | 
             
                  query = { metadataDate: options[:metadataDate], departmentIds: options[:departmentIds] }
         | 
| 20 | 
            -
                  response =  | 
| 21 | 
            -
                   | 
| 24 | 
            +
                  response = create_request(API_ENDPOINT, PUBLIC_URI, query)
         | 
| 25 | 
            +
                  arrange_response(response)
         | 
| 22 26 | 
             
                end
         | 
| 23 27 |  | 
| 24 28 | 
             
                # returns a record for an object, containing all open access data about that object, including its image (if the image is available under Open Access)
         | 
| @@ -80,8 +84,8 @@ module MetMuseum | |
| 80 84 | 
             
                # @return [Hash<GalleryNumber, string>] Gallery number, where available
         | 
| 81 85 |  | 
| 82 86 | 
             
                def object(object_id)
         | 
| 83 | 
            -
                  response =  | 
| 84 | 
            -
                   | 
| 87 | 
            +
                  response = create_request(API_ENDPOINT, "#{PUBLIC_URI}/#{object_id}")
         | 
| 88 | 
            +
                  arrange_response(response)
         | 
| 85 89 | 
             
                end
         | 
| 86 90 |  | 
| 87 91 | 
             
                # returns a listing of all departments
         | 
| @@ -89,8 +93,8 @@ module MetMuseum | |
| 89 93 | 
             
                # @return [Integer] departments Department ID as an integer. The departmentId is to be used as a query parameter on the `/objects` endpoint
         | 
| 90 94 | 
             
                # @return [String] departments Display name for a department
         | 
| 91 95 | 
             
                def department
         | 
| 92 | 
            -
                  response =  | 
| 93 | 
            -
                   | 
| 96 | 
            +
                  response = create_request(API_ENDPOINT, DEPARTMENTS_URI)
         | 
| 97 | 
            +
                  arrange_response(response)
         | 
| 94 98 | 
             
                end
         | 
| 95 99 |  | 
| 96 100 | 
             
                # returns a listing of all Object IDs for objects that contain the search query within the object’s data
         | 
| @@ -102,17 +106,17 @@ module MetMuseum | |
| 102 106 | 
             
                # @return [Array<Object>] objects An array containing the objects that contain the search query within the object’s data
         | 
| 103 107 | 
             
                def search(query, **args)
         | 
| 104 108 | 
             
                  args.merge!({q: query})
         | 
| 105 | 
            -
                  response =  | 
| 106 | 
            -
                  origin_response =  | 
| 109 | 
            +
                  response = create_request(API_ENDPOINT, SEARCH_URI, args)
         | 
| 110 | 
            +
                  origin_response = arrange_response(response)
         | 
| 107 111 | 
             
                  limit = args[:limit].to_i
         | 
| 108 112 | 
             
                  return origin_response if limit <= 0
         | 
| 109 113 |  | 
| 110 | 
            -
                  origin_response["objectIDs"] | 
| 114 | 
            +
                  origin_response["objectIDs"].lazy.map { |id| MetMuseum::Collection.new.object(id) }.first(limit)
         | 
| 111 115 | 
             
                end
         | 
| 112 116 |  | 
| 113 117 | 
             
                private
         | 
| 114 118 |  | 
| 115 | 
            -
                def  | 
| 119 | 
            +
                def create_request(url, dir, params = nil)
         | 
| 116 120 | 
             
                  Faraday.new(url: url).get dir, params
         | 
| 117 121 | 
             
                end
         | 
| 118 122 |  | 
| @@ -127,7 +131,7 @@ module MetMuseum | |
| 127 131 | 
             
                  raise TypeError, "Write certain date"
         | 
| 128 132 | 
             
                end
         | 
| 129 133 |  | 
| 130 | 
            -
                def  | 
| 134 | 
            +
                def arrange_response(response)
         | 
| 131 135 | 
             
                  return Oj.load(response.body) if response_successful?(response)
         | 
| 132 136 |  | 
| 133 137 | 
             
                  raise MetMuseum.error_class(response), "Code: #{response.status}, response: #{response.body}"
         | 
    
        data/lib/met_museum/version.rb
    CHANGED
    
    
    
        data/lib/met_museum.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: met_museum
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.4. | 
| 4 | 
            +
              version: 1.4.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - hyuraku
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2022-02-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -140,7 +140,7 @@ licenses: | |
| 140 140 | 
             
            - MIT
         | 
| 141 141 | 
             
            metadata:
         | 
| 142 142 | 
             
              homepage_uri: https://github.com/hyuraku/met_museum
         | 
| 143 | 
            -
            post_install_message: | 
| 143 | 
            +
            post_install_message:
         | 
| 144 144 | 
             
            rdoc_options: []
         | 
| 145 145 | 
             
            require_paths:
         | 
| 146 146 | 
             
            - lib
         | 
| @@ -155,8 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 155 155 | 
             
                - !ruby/object:Gem::Version
         | 
| 156 156 | 
             
                  version: '0'
         | 
| 157 157 | 
             
            requirements: []
         | 
| 158 | 
            -
            rubygems_version: 3. | 
| 159 | 
            -
            signing_key: | 
| 158 | 
            +
            rubygems_version: 3.3.3
         | 
| 159 | 
            +
            signing_key:
         | 
| 160 160 | 
             
            specification_version: 4
         | 
| 161 161 | 
             
            summary: MET museum api wrapper
         | 
| 162 162 | 
             
            test_files: []
         |