met_museum 1.3.2 → 1.3.3
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/Gemfile.lock +3 -3
- data/README.md +10 -6
- data/lib/met_museum/collection.rb +10 -6
- data/lib/met_museum/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e78d1ef3d724c81c274a2b009c09df3f296e319de8da098ffe466f5546c54667
|
|
4
|
+
data.tar.gz: abf44fecf0f446fb111a5df5730509b55c2dc9fc22aaa74f3e4ff2047da410d7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b71d5ec05575b2e26e4e75bed317aa73399d552f769ea2c816f120b9098ac86e8798d76ade64a1b0685124e7cfa495b77b09aeef4053b152684c5b2f32afea6e
|
|
7
|
+
data.tar.gz: 36df1c3a70cf2c806a0a5cf74c21dbccc946062cc9f56dc4f9b5a0bf6060662c37565841946678b954318d6d1192f445232a987c3ed9757bde89e8a32ec0bc2e
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
met_museum (1.3.
|
|
4
|
+
met_museum (1.3.3)
|
|
5
5
|
faraday
|
|
6
6
|
oj
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ GEM
|
|
|
14
14
|
multipart-post (>= 1.2, < 3)
|
|
15
15
|
method_source (0.9.2)
|
|
16
16
|
multipart-post (2.1.1)
|
|
17
|
-
oj (3.
|
|
17
|
+
oj (3.9.0)
|
|
18
18
|
pry (0.12.2)
|
|
19
19
|
coderay (~> 1.1.0)
|
|
20
20
|
method_source (~> 0.9.0)
|
|
@@ -47,4 +47,4 @@ DEPENDENCIES
|
|
|
47
47
|
rspec-retry
|
|
48
48
|
|
|
49
49
|
BUNDLED WITH
|
|
50
|
-
2.0.
|
|
50
|
+
2.0.2
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<img src="https://img.shields.io/travis/hyuraku/met_museum.svg"> <img src="https://img.shields.io/github/license/hyuraku/met_museum.svg">
|
|
2
|
-
<img src="https://img.shields.io/gem/v/met_museum.svg">
|
|
2
|
+
<img src="https://img.shields.io/gem/v/met_museum.svg">
|
|
3
3
|
# MetMuseum
|
|
4
4
|
|
|
5
5
|
The Metropolitan Museum of Art Collection API Ruby wrapper
|
|
@@ -92,8 +92,7 @@ collection.objects(metadataDate: Date.new(2018,10,10),departmentIds: 1)
|
|
|
92
92
|
<div>
|
|
93
93
|
|
|
94
94
|
```rb
|
|
95
|
-
|
|
96
|
-
collection.object(1000)
|
|
95
|
+
MetMuseum::Collection.new.object(1000)
|
|
97
96
|
=> {"objectID"=>1000,
|
|
98
97
|
"isHighlight"=>false,
|
|
99
98
|
"accessionNumber"=>"10.149.99",
|
|
@@ -155,7 +154,7 @@ MetMuseum::Collection.department
|
|
|
155
154
|
|
|
156
155
|
```rb
|
|
157
156
|
# show object_ids size and themselves
|
|
158
|
-
|
|
157
|
+
MetMuseum::Collection.new.department
|
|
159
158
|
=> {"departments"=>
|
|
160
159
|
[{"departmentId"=>1, "displayName"=>"American Decorative Arts"},
|
|
161
160
|
{"departmentId"=>3, "displayName"=>"Ancient Near Eastern Art"},
|
|
@@ -177,7 +176,7 @@ MetMuseum::Collection.search
|
|
|
177
176
|
|
|
178
177
|
```rb
|
|
179
178
|
# show object_ids size and themselves
|
|
180
|
-
|
|
179
|
+
MetMuseum::Collection.new.search('ocean')
|
|
181
180
|
=> {"total"=>189,
|
|
182
181
|
"objectIDs"=>
|
|
183
182
|
[250487,
|
|
@@ -189,7 +188,7 @@ collection.search('ocean')
|
|
|
189
188
|
--< omit >--
|
|
190
189
|
|
|
191
190
|
# show specified number of objects
|
|
192
|
-
MetMuseum::Collection.search('akasaka', 1)
|
|
191
|
+
MetMuseum::Collection.new.search('akasaka', {limit: 1})
|
|
193
192
|
=> [{"objectID"=>37231,
|
|
194
193
|
"isHighlight"=>false,
|
|
195
194
|
"accessionNumber"=>"JP787",
|
|
@@ -239,6 +238,11 @@ MetMuseum::Collection.search('akasaka', 1)
|
|
|
239
238
|
"repository"=>"Metropolitan Museum of Art, New York, NY",
|
|
240
239
|
"objectURL"=>"https://www.metmuseum.org/art/collection/search/37231",
|
|
241
240
|
"tags"=>["Buildings", "Men", "Women"]}]
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
# show specified number of objects
|
|
244
|
+
MetMuseum::Collection.new.search('akasaka', {isHighlight: true})
|
|
245
|
+
=> {"total"=>9, "objectIDs"=>[36572, 37231, 37023, 29953, 55713, 56937, 36708, 36958, 55684]}
|
|
242
246
|
```
|
|
243
247
|
</div>
|
|
244
248
|
</details>
|
|
@@ -10,11 +10,10 @@ module MetMuseum
|
|
|
10
10
|
# @return [Hash<total, Integer>] The total number of publicly-available objects
|
|
11
11
|
# @return [Hash<objectIDs, Array<Integer>>] An array containing the object ID of publicly-available object
|
|
12
12
|
def objects(options = {})
|
|
13
|
-
|
|
13
|
+
options = {
|
|
14
14
|
metadataDate: nil,
|
|
15
15
|
departmentIds: nil
|
|
16
|
-
}
|
|
17
|
-
options = default_options.merge(options)
|
|
16
|
+
}.merge(options)
|
|
18
17
|
options[:metadataDate] = check_date(options[:metadataDate]) unless options[:metadataDate].nil?
|
|
19
18
|
response = Faraday.new(:url => API_ENDPOINT).get PUBLIC_URI, {:metadataDate => options[:metadataDate], :departmentIds => options[:departmentIds]}
|
|
20
19
|
return_response(response)
|
|
@@ -89,14 +88,19 @@ module MetMuseum
|
|
|
89
88
|
# returns a listing of all Object IDs for objects that contain the search query within the object’s data
|
|
90
89
|
# @param [String] query search term e.g. sunflowers
|
|
91
90
|
# @param [Interger] limit number of objects zthat contain the search query within the object’s data
|
|
91
|
+
# @param [Boolean] Returns objects that match the query and are designated as highlights. Highlights are selected works of art from The Met Museum’s permanent collection representing different cultures and time periods.
|
|
92
92
|
# @return [Integer] total The total number of publicly-available objects
|
|
93
93
|
# @return [Array<Integer>] objectIDs An array containing the object ID of publicly-available object
|
|
94
94
|
# @return [Array<Object>] objects An array containing the objects that contain the search query within the object’s data
|
|
95
|
-
def search(query,
|
|
95
|
+
def search(query, options = {})
|
|
96
|
+
options = {
|
|
97
|
+
limit: 0,
|
|
98
|
+
isHighlight: false
|
|
99
|
+
}.merge(options)
|
|
96
100
|
response = Faraday.new(:url => API_ENDPOINT).get SEARCH_URI, {:q => query}
|
|
97
101
|
origin_response = return_response(response)
|
|
98
|
-
return origin_response if limit <= 0
|
|
99
|
-
origin_response["objectIDs"][0..limit - 1].map{|id| MetMuseum::Collection.new.object(id)}
|
|
102
|
+
return origin_response if options[:limit] <= 0
|
|
103
|
+
origin_response["objectIDs"][0..options[:limit] - 1].map{|id| MetMuseum::Collection.new.object(id)}
|
|
100
104
|
end
|
|
101
105
|
|
|
102
106
|
private
|
data/lib/met_museum/version.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.3.
|
|
4
|
+
version: 1.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- hyuraku
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-08-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|