iiif-presentation 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5d2ae4eba89da3249e90fd07899b0c959a2ad6d1
4
- data.tar.gz: 2b9d3fb56e25a15c4d66f1d8b44488a873a3adba
2
+ SHA256:
3
+ metadata.gz: 595091b364990a3c3c5119ad55629ad137b9f59ad2b59b5fd0ae763b12afc340
4
+ data.tar.gz: ad8be940ec5dd37006b619456d23eb0d410f201a36587a6045917739ba69c94f
5
5
  SHA512:
6
- metadata.gz: 30779f16f6794adfac654ea104a49a5d4970a28248fde2b93fdc941e55f2da3bb050fd046ea2fdcde639886ce3cc3a0a71550be74acbce139cd8c123928944a4
7
- data.tar.gz: 6c14f0bf0d3c3a5ea647372267634768f8a6ef9dde304c68a5ed0c598e22f937fcd4428d653cb73cd2871123f00f828cdeb56626d0a6bf8d37a786637df5cbdf
6
+ metadata.gz: 23600bbc87868cc9b7d0455228d0c7f8a1dca235a4e732b343e9dc0987f485f0dd4e59f64ae6434afec341ba8ae36add4ab48b91a0bc4d2be9e94596879b247e
7
+ data.tar.gz: ddd645e0cb9fd3464547826504b4078798e02cb06d766c6b9e10fb28d7b4999e0a643414f7ddb737bf91d2469e6693e7cbdbb556bd73d191d50063442c3dae18
@@ -1,11 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
4
- - 2.3.0
3
+ - 2.7.0
4
+
5
+ env:
6
+ - RAILS_VERSION='~> 5.2'
7
+ - RAILS_VERSION='~> 6.0'
8
+ - RAILS_VERSION='~> 6.0' FARADAY_VERSION='< 1.0'
5
9
  install:
6
10
  - "gem install bundler"
7
11
  - "bundle install --jobs=3 --retry=3"
8
-
9
- gemfile:
10
- - gemfiles/rails3.gemfile
11
- - gemfiles/rails4.gemfile
data/Gemfile CHANGED
@@ -1,2 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
  gemspec
3
+
4
+ if ENV['RAILS_VERSION']
5
+ gem 'activesupport', ENV['RAILS_VERSION']
6
+ end
7
+
8
+ if ENV['FARADAY_VERSION']
9
+ gem 'faraday', ENV['FARADAY_VERSION']
10
+ end
data/README.md CHANGED
@@ -82,7 +82,7 @@ puts manifest.to_json(pretty: true, force: true) # force: true skips validations
82
82
  ## Parsing Existing Objects
83
83
 
84
84
  Use `IIIF::Service#parse`. It will figure out what the object
85
- should be, based on `@type`, and fall back to `ActiveSupport::OrderedHash` when
85
+ should be, based on `@type`, and fall back to `Hash` when
86
86
  it can't e.g.:
87
87
 
88
88
  ```ruby
@@ -133,7 +133,7 @@ puts obj.class
133
133
  puts obj.see_also.class
134
134
 
135
135
  > IIIF::Presentation::Manifest
136
- > ActiveSupport::OrderedHash
136
+ > Hash
137
137
  ```
138
138
 
139
139
  ## Validation and Exceptions
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 1.0.0
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency 'coveralls'
21
21
  spec.add_development_dependency 'webmock'
22
22
  spec.add_development_dependency 'multi_json'
23
- spec.add_development_dependency 'vcr', '~> 2.9.3'
23
+ spec.add_development_dependency 'vcr', '~> 5'
24
24
 
25
25
  spec.add_dependency 'json'
26
26
  spec.add_dependency 'activesupport', '>= 3.2.18'
@@ -46,8 +46,7 @@ module IIIF
46
46
  end
47
47
 
48
48
  # Initialize a Presentation node
49
- # @param [Hash] hsh - Anything in this hash will be added to the Object.'
50
- # Order is only guaranteed if an ActiveSupport::OrderedHash is passed.
49
+ # @param [Hash] hsh - Anything in this hash will be added to the Object.
51
50
  # @param [boolean] include_context (default: false). Pass true if the'
52
51
  # context should be included.
53
52
  def initialize(hsh={})
@@ -103,7 +103,12 @@ module IIIF
103
103
  def get_info(svc_id)
104
104
  conn = Faraday.new("#{svc_id}/info.json") do |c|
105
105
  c.use Faraday::Response::RaiseError
106
- c.use Faraday::Adapter::NetHttp
106
+
107
+ if c.respond_to? :adapter
108
+ c.adapter Faraday.default_adapter
109
+ else
110
+ c.use Faraday::Adapter::NetHttp
111
+ end
107
112
  end
108
113
  resp = conn.get # raises exceptions that indicate HTTP problems
109
114
  JSON.parse(resp.body)
@@ -206,17 +206,13 @@ module IIIF
206
206
 
207
207
  hsh.keys.each do |key|
208
208
  new_key = key.underscore == key ? key : key.underscore
209
- if new_key == 'service'
210
- new_object[new_key] = IIIF::Service.from_ordered_hash(hsh[key], IIIF::Service)
211
- elsif new_key == 'resource'
212
- new_object[new_key] = IIIF::Service.from_ordered_hash(hsh[key], IIIF::Presentation::Resource)
213
- elsif hsh[key].kind_of?(Hash)
214
- new_object[new_key] = IIIF::Service.from_ordered_hash(hsh[key])
215
- elsif hsh[key].kind_of?(Array)
209
+ if hsh[key].kind_of?(Array)
216
210
  new_object[new_key] = []
217
211
  hsh[key].each do |member|
218
212
  if new_key == 'service'
219
213
  new_object[new_key] << IIIF::Service.from_ordered_hash(member, IIIF::Service)
214
+ elsif new_key == 'resource'
215
+ new_object[new_key] << IIIF::Service.from_ordered_hash(hsh[key], IIIF::Presentation::Resource)
220
216
  elsif member.kind_of?(Hash)
221
217
  new_object[new_key] << IIIF::Service.from_ordered_hash(member)
222
218
  else
@@ -224,6 +220,12 @@ module IIIF
224
220
  # Again, no nested arrays, right?
225
221
  end
226
222
  end
223
+ elsif new_key == 'service'
224
+ new_object[new_key] = IIIF::Service.from_ordered_hash(hsh[key], IIIF::Service)
225
+ elsif new_key == 'resource'
226
+ new_object[new_key] = IIIF::Service.from_ordered_hash(hsh[key], IIIF::Presentation::Resource)
227
+ elsif hsh[key].kind_of?(Hash)
228
+ new_object[new_key] = IIIF::Service.from_ordered_hash(hsh[key])
227
229
  else
228
230
  new_object[new_key] = hsh[key]
229
231
  end
@@ -1,159 +1 @@
1
- {
2
- "http_interactions": [
3
- {
4
- "request": {
5
- "method": "get",
6
- "uri": "http://libimages.princeton.edu/loris2/pudl0001%2F4612422%2F00000001.jp2/info.json",
7
- "body": {
8
- "encoding": "US-ASCII",
9
- "string": ""
10
- },
11
- "headers": {
12
- "User-Agent": [
13
- "Faraday v0.9.0"
14
- ],
15
- "Accept-Encoding": [
16
- "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
17
- ],
18
- "Accept": [
19
- "*/*"
20
- ]
21
- }
22
- },
23
- "response": {
24
- "status": {
25
- "code": 200,
26
- "message": "OK"
27
- },
28
- "headers": {
29
- "Server": [
30
- "Apache/2.2.22 (Ubuntu)"
31
- ],
32
- "Link": [
33
- "<http://iiif.io/api/image/2/level2.json>;rel=\"profile\",<http://iiif.io/api/image/2/context.json>;rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\""
34
- ],
35
- "Access-Control-Allow-Origin": [
36
- "*"
37
- ],
38
- "Last-Modified": [
39
- "Wed, 26 Nov 2014 21:16:14 GMT"
40
- ],
41
- "Cache-Control": [
42
- "max-age=5184000"
43
- ],
44
- "Expires": [
45
- "Sun, 25 Jan 2015 21:16:14 GMT"
46
- ],
47
- "Content-Type": [
48
- "application/json"
49
- ],
50
- "Content-Length": [
51
- "737"
52
- ],
53
- "Accept-Ranges": [
54
- "bytes"
55
- ],
56
- "Date": [
57
- "Thu, 27 Nov 2014 00:55:14 GMT"
58
- ],
59
- "X-Varnish": [
60
- "1471998866 1471996229"
61
- ],
62
- "Age": [
63
- "13140"
64
- ],
65
- "Via": [
66
- "1.1 varnish"
67
- ],
68
- "Connection": [
69
- "keep-alive"
70
- ]
71
- },
72
- "body": {
73
- "encoding": "UTF-8",
74
- "string": "{\"profile\": [\"http://iiif.io/api/image/2/level2.json\", {\"supports\": [\"canonicalLinkHeader\", \"profileLinkHeader\", \"mirroring\", \"rotationArbitrary\", \"sizeAboveFull\"], \"qualities\": [\"default\", \"bitonal\", \"gray\", \"color\"], \"formats\": [\"jpg\", \"png\", \"gif\", \"webp\"]}], \"tiles\": [{\"width\": 1024, \"scaleFactors\": [1, 2, 4, 8, 16, 32]}], \"protocol\": \"http://iiif.io/api/image\", \"sizes\": [{\"width\": 96, \"height\": 225}, {\"width\": 191, \"height\": 450}, {\"width\": 381, \"height\": 900}, {\"width\": 762, \"height\": 1800}, {\"width\": 1524, \"height\": 3600}, {\"width\": 3047, \"height\": 7200}], \"height\": 7200, \"width\": 3047, \"@context\": \"http://iiif.io/api/image/2/context.json\", \"@id\": \"http://libimages.princeton.edu/loris2/pudl0001%2F4612422%2F00000001.jp2\"}"
75
- },
76
- "http_version": null
77
- },
78
- "recorded_at": "Thu, 27 Nov 2014 01:00:58 GMT"
79
- },
80
- {
81
- "request": {
82
- "method": "get",
83
- "uri": "http://libimages.princeton.edu/loris2/xxxx%2F4612422%2F00000001.jp2/info.json",
84
- "body": {
85
- "encoding": "US-ASCII",
86
- "string": ""
87
- },
88
- "headers": {
89
- "User-Agent": [
90
- "Faraday v0.9.0"
91
- ],
92
- "Accept-Encoding": [
93
- "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
94
- ],
95
- "Accept": [
96
- "*/*"
97
- ]
98
- }
99
- },
100
- "response": {
101
- "status": {
102
- "code": 404,
103
- "message": "NOT FOUND"
104
- },
105
- "headers": {
106
- "Server": [
107
- "Apache/2.2.22 (Ubuntu)"
108
- ],
109
- "Link": [
110
- "<http://iiif.io/api/image/2/level2.json>;rel=\"profile\""
111
- ],
112
- "Access-Control-Allow-Origin": [
113
- "*"
114
- ],
115
- "Cache-Control": [
116
- "max-age=5184000"
117
- ],
118
- "Expires": [
119
- "Mon, 26 Jan 2015 10:20:46 GMT"
120
- ],
121
- "Vary": [
122
- "Accept-Encoding"
123
- ],
124
- "Content-Type": [
125
- "text/plain"
126
- ],
127
- "Content-Length": [
128
- "88"
129
- ],
130
- "Accept-Ranges": [
131
- "bytes"
132
- ],
133
- "Date": [
134
- "Thu, 27 Nov 2014 10:20:46 GMT"
135
- ],
136
- "X-Varnish": [
137
- "1472002765"
138
- ],
139
- "Age": [
140
- "0"
141
- ],
142
- "Via": [
143
- "1.1 varnish"
144
- ],
145
- "Connection": [
146
- "keep-alive"
147
- ]
148
- },
149
- "body": {
150
- "encoding": "UTF-8",
151
- "string": "Not Found: could not resolve identifier: xxxx%2F4612422%2F00000001.jp2 (404)"
152
- },
153
- "http_version": null
154
- },
155
- "recorded_at": "Thu, 27 Nov 2014 10:26:31 GMT"
156
- }
157
- ],
158
- "recorded_with": "VCR 2.9.3"
159
- }
1
+ {"http_interactions":[{"request":{"method":"get","uri":"https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/info.json","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Faraday v1.0.1"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"date":["Wed, 17 Jun 2020 19:38:19 GMT"],"server":["Apache/2.4.18 (Ubuntu)"],"link":["<http://iiif.io/api/image/2/level2.json>;rel=\"profile\",<http://iiif.io/api/image/2/context.json>;rel=\"http://www.w3.org/ns/json-ld#context\";type=\"application/ld+json\""],"access-control-allow-origin":["*"],"access-control-allow-methods":["GET"],"access-control-allow-headers":["X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"],"last-modified":["Sat, 25 Jan 2020 18:37:32 GMT"],"content-length":["753"],"content-type":["application/json"]},"body":{"encoding":"UTF-8","string":"{\"profile\": [\"http://iiif.io/api/image/2/level2.json\", {\"supports\": [\"canonicalLinkHeader\", \"profileLinkHeader\", \"mirroring\", \"rotationArbitrary\", \"regionSquare\", \"sizeAboveFull\"], \"qualities\": [\"default\", \"bitonal\", \"gray\", \"color\"], \"formats\": [\"jpg\", \"png\", \"gif\", \"webp\"]}], \"tiles\": [{\"width\": 1024, \"scaleFactors\": [1, 2, 4, 8, 16, 32]}], \"protocol\": \"http://iiif.io/api/image\", \"sizes\": [{\"width\": 96, \"height\": 225}, {\"width\": 191, \"height\": 450}, {\"width\": 381, \"height\": 900}, {\"width\": 762, \"height\": 1800}, {\"width\": 1524, \"height\": 3600}, {\"width\": 3047, \"height\": 7200}], \"height\": 7200, \"width\": 3047, \"@context\": \"http://iiif.io/api/image/2/context.json\", \"@id\": \"https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2\"}"},"http_version":null},"recorded_at":"Wed, 17 Jun 2020 19:38:19 GMT"},{"request":{"method":"get","uri":"https://libimages.princeton.edu/loris/xxxx%2F4612422%2F00000001.jp2/info.json","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Faraday v1.0.1"]}},"response":{"status":{"code":404,"message":"NOT FOUND"},"headers":{"date":["Wed, 17 Jun 2020 19:38:20 GMT"],"server":["Apache/2.4.18 (Ubuntu)"],"link":["<http://iiif.io/api/image/2/level2.json>;rel=\"profile\""],"access-control-allow-origin":["*"],"access-control-allow-methods":["GET"],"access-control-allow-headers":["X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"],"content-length":["86"],"content-type":["text/plain"]},"body":{"encoding":"UTF-8","string":"Not Found: Source image not found for identifier: xxxx%2F4612422%2F00000001.jp2. (404)"},"http_version":null},"recorded_at":"Wed, 17 Jun 2020 19:38:20 GMT"}],"recorded_with":"VCR 5.1.0"}
@@ -7,7 +7,8 @@ describe IIIF::Presentation::ImageResource do
7
7
 
8
8
  describe 'self#create_image_api_image_resource', vcr: vcr_options do
9
9
 
10
- let(:image_server) { 'http://libimages.princeton.edu/loris2' }
10
+ # 301 moved to https.../loris
11
+ let(:image_server) { 'https://libimages.princeton.edu/loris' }
11
12
 
12
13
  let(:valid_service_id) {
13
14
  id = 'pudl0001%2F4612422%2F00000001.jp2'
@@ -31,31 +32,31 @@ describe IIIF::Presentation::ImageResource do
31
32
  resource = described_class.create_image_api_image_resource(opts)
32
33
  # expect(resource['@context']).to eq 'http://iiif.io/api/presentation/2/context.json'
33
34
  # @context is only added when we call to_json...
34
- expect(resource['@id']).to eq 'http://libimages.princeton.edu/loris2/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg'
35
+ expect(resource['@id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg'
35
36
  expect(resource['@type']).to eq 'dctypes:Image'
36
37
  expect(resource.format).to eq "image/jpeg"
37
38
  expect(resource.width).to eq 3047
38
39
  expect(resource.height).to eq 7200
39
40
  expect(resource.service['@context']).to eq 'http://iiif.io/api/image/2/context.json'
40
- expect(resource.service['@id']).to eq 'http://libimages.princeton.edu/loris2/pudl0001%2F4612422%2F00000001.jp2'
41
+ expect(resource.service['@id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2'
41
42
  expect(resource.service['profile']).to eq 'http://iiif.io/api/image/2/level2.json'
42
43
  end
43
- it 'copies over all teh infos (when copy_info is true)' do
44
+ it 'copies over all the info (when copy_info is true)' do
44
45
  opts = { service_id: valid_service_id, copy_info: true }
45
46
  resource = described_class.create_image_api_image_resource(opts)
46
- expect(resource['@id']).to eq 'http://libimages.princeton.edu/loris2/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg'
47
+ expect(resource['@id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2/full/!200,200/0/default.jpg'
47
48
  expect(resource['@type']).to eq 'dctypes:Image'
48
49
  expect(resource.format).to eq "image/jpeg"
49
50
  expect(resource.width).to eq 3047
50
51
  expect(resource.height).to eq 7200
51
52
  expect(resource.service['@context']).to eq 'http://iiif.io/api/image/2/context.json'
52
- expect(resource.service['@id']).to eq 'http://libimages.princeton.edu/loris2/pudl0001%2F4612422%2F00000001.jp2'
53
+ expect(resource.service['@id']).to eq 'https://libimages.princeton.edu/loris/pudl0001%2F4612422%2F00000001.jp2'
53
54
  expect(resource.service['profile']).to eq [
54
55
  'http://iiif.io/api/image/2/level2.json',
55
56
  {
56
57
  'supports' => [
57
58
  'canonicalLinkHeader', 'profileLinkHeader', 'mirroring',
58
- 'rotationArbitrary', 'sizeAboveFull'
59
+ 'rotationArbitrary', 'regionSquare', 'sizeAboveFull'
59
60
  ],
60
61
  'qualities' => ['default', 'bitonal', 'gray', 'color'],
61
62
  'formats'=>['jpg', 'png', 'gif', 'webp']
@@ -78,7 +79,8 @@ describe IIIF::Presentation::ImageResource do
78
79
 
79
80
  describe 'respects the params we supply' do
80
81
  it ':resource_id' do
81
- r_id = 'http://example.edu/images/some.jpg'
82
+ r_id = 'http://example.edu/images/some.jpg'
83
+
82
84
  opts = { service_id: valid_service_id, resource_id: r_id}
83
85
  resource = described_class.create_image_api_image_resource(opts)
84
86
  expect(resource['@id']).to eq r_id
@@ -106,6 +106,13 @@ describe IIIF::Service do
106
106
  expect(parsed['service'].class).to be expected_klass
107
107
  end
108
108
 
109
+ it 'works with arrays of services' do
110
+ expected_klass = IIIF::Service
111
+ fixture['service'] = [fixture['service']]
112
+ parsed = described_class.from_ordered_hash(fixture)
113
+ expect(parsed['service'].first.class).to be expected_klass
114
+ end
115
+
109
116
  it 'round-trips' do
110
117
  fp = '/tmp/osullivan-spec.json'
111
118
  parsed = described_class.from_ordered_hash(fixture)
@@ -8,7 +8,7 @@ require 'vcr'
8
8
 
9
9
  VCR.configure do |c|
10
10
  c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
11
- c.hook_into :webmock
11
+ c.hook_into :faraday
12
12
  c.configure_rspec_metadata!
13
13
  end
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iiif-presentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Stroop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 2.9.3
103
+ version: '5'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 2.9.3
110
+ version: '5'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: json
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -165,8 +165,6 @@ files:
165
165
  - README.md
166
166
  - Rakefile
167
167
  - VERSION
168
- - gemfiles/rails3.gemfile
169
- - gemfiles/rails4.gemfile
170
168
  - iiif-presentation.gemspec
171
169
  - lib/iiif/hash_behaviours.rb
172
170
  - lib/iiif/ordered_hash.rb
@@ -228,8 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
226
  - !ruby/object:Gem::Version
229
227
  version: '0'
230
228
  requirements: []
231
- rubyforge_project:
232
- rubygems_version: 2.5.2
229
+ rubygems_version: 3.1.2
233
230
  signing_key:
234
231
  specification_version: 4
235
232
  summary: API for working with IIIF Presentation manifests.
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../"
4
-
5
- gem 'activesupport', '~> 3.2', '>= 3.2.18'
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path=>"../"
4
-
5
- gem 'activesupport', '~> 4.1'