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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a79a7c355d8200cfccab7fdb7fbd01f37a74ee82a555de9a4697a6800616d2e4
4
- data.tar.gz: 647315d7446816af5ce68035edcbedf32593a89aad70c511632f8ce3abe652c5
3
+ metadata.gz: 747d015331b55f840aa0065fbfc3e2822fda2f2f52a5a6ddede4b7f62ade5735
4
+ data.tar.gz: ac3158ff771e89fc1fb3d563920b02797c97c15be9dbd8a1ed5618649b53194b
5
5
  SHA512:
6
- metadata.gz: e31f31134b22d04612fdc5ef4f303cbfe2f25a1da5b9e0b2784b0fc3415daa8b876afba041f1747dd407dbab0cf57ca29e0a7350c6dfb0c0c0215b1fca655816
7
- data.tar.gz: 28828344996f33389508a8664939a18fd3f182800dfe81bb3bf14d7b68864ecaa56d94698d73c93df6592af98be7f631d896aaf648b9d10b730fa9f3eb864fc5
6
+ metadata.gz: c02a1a47672656535464183e79b4129b0d4b12632b48382afe8a3aff36d24af355620b51097324157f04342c361dcf62d74396916b52edf05359de6a011a37b1
7
+ data.tar.gz: 33eedda5f92fe536476dd03c0ba50aad36610f09440fcf15317b905baeac576108d3ac7993269a2619ed403c3ab5883a21193d87da2f72c3fb9e5358a67dd58f
@@ -15,7 +15,7 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: [ '2.5', '2.6', '2.7', '3.0' ]
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.0)
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.4)
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.2)
57
+ ruby2_keywords (0.0.5)
58
58
  unicode-display_width (1.7.0)
59
59
 
60
60
  PLATFORMS
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 hyuraku
3
+ Copyright (c) 2021 hyuraku
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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 = new_faraday(API_ENDPOINT, PUBLIC_URI, query)
21
- return_response(response)
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 = new_faraday(API_ENDPOINT, "#{PUBLIC_URI}/#{object_id}")
84
- return_response(response)
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 = new_faraday(API_ENDPOINT, DEPARTMENTS_URI)
93
- return_response(response)
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 = new_faraday(API_ENDPOINT, SEARCH_URI, args)
106
- origin_response = return_response(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"][0..limit - 1].map { |id| MetMuseum::Collection.new.object(id) }
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 new_faraday(url, dir, params = nil)
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 return_response(response)
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}"
@@ -1,3 +1,3 @@
1
1
  module MetMuseum
2
- VERSION = "1.4.0".freeze
2
+ VERSION = "1.4.1".freeze
3
3
  end
data/lib/met_museum.rb CHANGED
@@ -1,6 +1,3 @@
1
- require "faraday"
2
- require "oj"
3
-
4
1
  require "met_museum/collection"
5
2
  require "met_museum/version"
6
3
 
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.0
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: 2020-12-29 00:00:00.000000000 Z
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.0.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: []