riiif 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riiif
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-14 00:00:00.000000000 Z
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,19 +95,33 @@ dependencies:
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
- name: rails
98
+ name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">"
101
+ - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: 3.2.0
90
- type: :runtime
103
+ version: 0.41.2
104
+ type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">"
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 3.2.0
110
+ version: 0.41.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.5'
97
125
  description: A IIIF image server
98
126
  email:
99
127
  - justin@curationexperts.com
@@ -103,6 +131,8 @@ extra_rdoc_files: []
103
131
  files:
104
132
  - ".gitignore"
105
133
  - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".rubocop_todo.yml"
106
136
  - ".travis.yml"
107
137
  - CHANGELOG
108
138
  - Gemfile
@@ -114,6 +144,7 @@ files:
114
144
  - app/models/riiif/image.rb
115
145
  - config/routes.rb
116
146
  - lib/riiif.rb
147
+ - lib/riiif/abstract_file_system_resolver.rb
117
148
  - lib/riiif/akubra_system_file_resolver.rb
118
149
  - lib/riiif/engine.rb
119
150
  - lib/riiif/file_system_file_resolver.rb
@@ -123,11 +154,11 @@ files:
123
154
  - lib/riiif/routes.rb
124
155
  - lib/riiif/version.rb
125
156
  - riiif.gemspec
126
- - spec/controllers/images_controller_spec.rb
127
- - spec/models/akubra_system_file_resolver_spec.rb
128
- - spec/models/file_system_file_resolver_spec.rb
129
- - spec/models/http_file_resolver_spec.rb
130
- - spec/models/image_spec.rb
157
+ - spec/controllers/riiif/images_controller_spec.rb
158
+ - spec/models/riiif/akubra_system_file_resolver_spec.rb
159
+ - spec/models/riiif/file_system_file_resolver_spec.rb
160
+ - spec/models/riiif/http_file_resolver_spec.rb
161
+ - spec/models/riiif/image_spec.rb
131
162
  - spec/routing/redirect_spec.rb
132
163
  - spec/routing/resize_routes_spec.rb
133
164
  - spec/spec_helper.rb
@@ -158,11 +189,11 @@ signing_key:
158
189
  specification_version: 4
159
190
  summary: A rails engine that support IIIF requests
160
191
  test_files:
161
- - spec/controllers/images_controller_spec.rb
162
- - spec/models/akubra_system_file_resolver_spec.rb
163
- - spec/models/file_system_file_resolver_spec.rb
164
- - spec/models/http_file_resolver_spec.rb
165
- - spec/models/image_spec.rb
192
+ - spec/controllers/riiif/images_controller_spec.rb
193
+ - spec/models/riiif/akubra_system_file_resolver_spec.rb
194
+ - spec/models/riiif/file_system_file_resolver_spec.rb
195
+ - spec/models/riiif/http_file_resolver_spec.rb
196
+ - spec/models/riiif/image_spec.rb
166
197
  - spec/routing/redirect_spec.rb
167
198
  - spec/routing/resize_routes_spec.rb
168
199
  - spec/spec_helper.rb
@@ -1,138 +0,0 @@
1
- require 'spec_helper'
2
- require 'open-uri'
3
-
4
- describe Riiif::ImagesController do
5
- let(:filename) { File.expand_path('spec/samples/world.jp2') }
6
- routes { Riiif::Engine.routes }
7
-
8
- describe "#show" do
9
- it "sends images to the service" do
10
- image = double
11
- expect(Riiif::Image).to receive(:new).with('abcd1234').and_return(image)
12
- expect(image).to receive(:render).with("region" => 'full', "size" => 'full',
13
- "rotation" => '0', "quality" => 'default',
14
- "format" => 'jpg').and_return("IMAGEDATA")
15
- get :show, id: 'abcd1234', action: "show", region: 'full', size: 'full',
16
- rotation: '0', quality: 'default', format: 'jpg'
17
- expect(response).to be_successful
18
- expect(response.body).to eq 'IMAGEDATA'
19
- expect(response.headers['Link']).to eq '<http://iiif.io/api/image/2/level1.json>;rel="profile"'
20
- expect(response.headers['Access-Control-Allow-Origin']).to eq '*'
21
- end
22
-
23
- context "with an unauthorized image" do
24
- let(:auth) { double("no auth service", can?: false) }
25
- let(:not_found_image) { double("not_found_image", render: 'test data') }
26
- before do
27
- allow(controller).to receive(:authorization_service).and_return(auth)
28
- allow(controller).to receive(:not_found_image).and_return(not_found_image)
29
- end
30
- it "renders 401" do
31
- get :show, id: 'abcd1234', action: "show", region: 'full', size: 'full',
32
- rotation: '0', quality: 'default', format: 'jpg'
33
- expect(response.body).to eq "test data"
34
- expect(response.code).to eq "401"
35
- end
36
- end
37
-
38
- context "with a invalid region" do
39
- it "renders 400" do
40
- image = double("an image")
41
- allow(image).to receive(:render).and_raise Riiif::InvalidAttributeError
42
- allow(Riiif::Image).to receive(:new).with('abcd1234').and_return(image)
43
- get :show, id: 'abcd1234', action: "show", region: '`szoW0', size: 'full',
44
- rotation: '0', quality: 'default', format: 'jpg'
45
- expect(response.code).to eq "400"
46
- end
47
- end
48
-
49
- context "with a nonexistent image" do
50
- it "should error when a default image isn't sent" do
51
- expect(Riiif::Image).to receive(:new).with('bad_id').and_raise(OpenURI::HTTPError.new("fail", StringIO.new))
52
- expect do
53
- get :show, id: 'bad_id', action: "show", region: 'full', size: 'full',
54
- rotation: '0', quality: 'default', format: 'jpg'
55
- end.to raise_error(StandardError)
56
- end
57
-
58
- context "with a default image set" do
59
- around do |example|
60
- old_value = Riiif.not_found_image
61
- Riiif.not_found_image = filename
62
- example.run
63
- Riiif.not_found_image = old_value
64
- end
65
-
66
- it "should send the default 'not found' image for failed http files" do
67
- not_found_image = double
68
- expect(Riiif::Image).to receive(:new) do |id, file|
69
- if file.present?
70
- not_found_image
71
- else
72
- raise Riiif::ImageNotFoundError
73
- end
74
- end.twice
75
- expect(not_found_image).to receive(:render).with("region" => 'full', "size" => 'full',
76
- "rotation" => '0', "quality" => 'default',
77
- "format" => 'jpg').and_return("default-image-data")
78
-
79
- get :show, id: 'bad_id', action: "show", region: 'full', size: 'full',
80
- rotation: '0', quality: 'default', format: 'jpg'
81
- expect(response).to be_not_found
82
- expect(response.body).to eq 'default-image-data'
83
- end
84
-
85
- it "should send the default 'not found' image for failed files on the filesystem" do
86
- not_found_image = double
87
- expect(Riiif::Image).to receive(:new) do |id, file|
88
- if file.present?
89
- not_found_image
90
- else
91
- raise Riiif::ImageNotFoundError
92
- end
93
- end.twice
94
- expect(not_found_image).to receive(:render).with("region" => 'full', "size" => 'full',
95
- "rotation" => '0', "quality" => 'default',
96
- "format" => 'jpg').and_return("default-image-data")
97
-
98
- get :show, id: 'bad_id', action: "show", region: 'full', size: 'full',
99
- rotation: '0', quality: 'default', format: 'jpg'
100
- expect(response).to be_not_found
101
- expect(response.body).to eq 'default-image-data'
102
- end
103
- end
104
- end
105
- end
106
-
107
- describe "info" do
108
- it "returns info" do
109
- image = double
110
- expect(Riiif::Image).to receive(:new).with('abcd1234').and_return(image)
111
- expect(image).to receive(:info).and_return({width: 6000, height: 4000 })
112
- get :info, id: 'abcd1234', format: 'json'
113
- expect(response).to be_successful
114
- json = JSON.parse(response.body)
115
- expect(json).to eq "@context" => "http://iiif.io/api/image/2/context.json",
116
- "@id" =>"http://test.host/images/abcd1234",
117
- "width" =>6000,
118
- "height" =>4000,
119
- "profile" => ["http://iiif.io/api/image/2/level1.json", "formats" => ["jpg", "png"]],
120
- 'protocol' => 'http://iiif.io/api/image'
121
- expect(response.headers['Link']).to eq '<http://iiif.io/api/image/2/level1.json>;rel="profile"'
122
- expect(response.headers['Content-Type']).to eq 'application/ld+json; charset=utf-8'
123
- expect(response.headers['Access-Control-Allow-Origin']).to eq '*'
124
- end
125
-
126
- context "with an unauthorized image" do
127
- let(:auth) { double("no auth service", can?: false) }
128
- before do
129
- allow(controller).to receive(:authorization_service).and_return(auth)
130
- end
131
- it "renders 401" do
132
- get :info, id: 'abcd1234', format: 'json'
133
- expect(response.body).to eq "{\"error\":\"unauthorized\"}"
134
- expect(response.code).to eq "401"
135
- end
136
- end
137
- end
138
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riiif::AkubraSystemFileResolver do
4
- subject { Riiif::AkubraSystemFileResolver.new(Rails.root.join('../spec/samples/'),'jp2',[[0,2],[2,2],[4,1]]) }
5
- it "should raise an error when the file isn't found" do
6
- expect{subject.find('demo:2')}.to raise_error Riiif::ImageNotFoundError
7
- end
8
-
9
- it "should get the jpeg2000 file" do
10
- expect(subject.find('demo:1').path).to eq Riiif::File.new(Dir.glob(subject.pathroot + '22/7e/9/info%3Afedora%2Fdemo%3A1%2Fjp2%2Fjp2.0').first).path
11
- end
12
-
13
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Riiif::FileSystemFileResolver do
4
- subject { Riiif::FileSystemFileResolver.new }
5
- it "should raise an error when the file isn't found" do
6
- expect{subject.find('1234')}.to raise_error Riiif::ImageNotFoundError
7
- end
8
-
9
- it "should get the jpeg2000 file" do
10
- expect(subject.find('world').path).to eq subject.root + '/spec/samples/world.jp2'
11
- end
12
-
13
- it "should accept ids with dashes" do
14
- subject.pattern('foo-bar-baz')
15
- end
16
- it "should accept ids with colins" do
17
- subject.pattern('fo:baz')
18
- end
19
- end