djatoka 0.2.4 → 0.3.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
2
  SHA1:
3
- metadata.gz: d9ab22b1d831e09f304d0107cb1e91e7a4adc318
4
- data.tar.gz: a81c7f50b8e90af06355602b39c83b3321719bf6
3
+ metadata.gz: 740300c47eff6616ff1596b35ee242ef1df34e0d
4
+ data.tar.gz: babda837e272e04a71298a47f36c0a14b8c64b92
5
5
  SHA512:
6
- metadata.gz: c46148e3303900dda666fee79a5ee70a70a768cb5aee434c56f9394223e4699ece98395eca560aa07f8313788c1b115e3c21a27b507fd8ceb5bb342a944e7320
7
- data.tar.gz: 6bcf63ac0f1b09cacc30eb72b6f651f4c64b1fcb10844ff37f0f855c15803ce711aa606767793499d338c972baaa94cffa16629263f574d0c8ca8ec5e3428865
6
+ metadata.gz: fe31d8abaa6ae8acf712640ebd165660248113e2f2e8f06d6cdd621db6292c3dbfdbc51a1587195463cdacad48b045eb27eae37d5a626b4f6b803e0d92f035a2
7
+ data.tar.gz: 9245d8e471aecd3b5efd3cf4005782899c17db9539061e24a5a6b7d707155a4467d3fd2b2741781b84c41393b2539449aa2c139c19e3ac7fe7cd354170a76d3f
@@ -2,8 +2,9 @@ language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
+ - "2.1.0"
6
+ - "2.1.1"
5
7
  - jruby-19mode # JRuby in 1.9 mode
6
- - rbx-19mode
7
8
  # uncomment this line if your project needs to run something other than `rake`:
8
- script: rake test
9
+ script: bundle exec rake test
9
10
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- djatoka (0.2.3)
4
+ djatoka (0.2.4)
5
5
  addressable
6
6
  hashie
7
7
  json
@@ -106,30 +106,26 @@ This gem can translate parameters from {International Image Interoperability Fra
106
106
 
107
107
  # Set IIIF parameters and create a Djatoka::Region
108
108
  # Note: All IIIF parameters are required before creating a Djatoka::Region
109
- djatoka_region = iiif_request.region('full').size('full').rotation('0').quality('native').format('jpg').djatoka_region
109
+ djatoka_region = iiif_request.region('full').size('full').rotation('0').quality('default').format('jpg').djatoka_region
110
110
 
111
111
  # Use the Djatoka::Region as normal
112
112
  djatoka_region.url
113
113
 
114
114
  # IIIF Info Request (Metadata)
115
+ # (See the 2.0 Info Request spec)}[http://iiif.io/api/image/2.0/#information-request]
115
116
  # First, create a Djatoka::Metadata object and perform the request to the server for metadata.
116
117
  metadata = resolver.metadata(identifier).perform
117
118
 
118
119
  # Create a IIIF Info json response string
119
120
  # Set values to optional fields by passing in a block and calling setters on the yielded Mash
120
- json = metadata.to_iiif_json do |info|
121
- info.tile_width = 512
122
- info.tile_height = 512
123
- info.formats = ['jpg', 'png']
124
- info.qualities = ['native', 'grey']
125
- info.profile = 'http://library.stanford.edu/iiif/image-api/compliance.html#level1'
126
- info.image_host = 'http://myserver.com/image'
121
+ json = metadata.to_iiif_json do |opts|
122
+ opts.tile_width = 512 # tile_* can be string or int
123
+ opts.tile_height = "512"
124
+ opts.compliance_level = 1
125
+ opts.formats = ["jpg", "png"]
126
+ opts.qualities = ["default", "gray"]
127
127
  end
128
128
 
129
- # If you want the xml flavor of a IIIF Info response, use
130
- xml = metadata.to_iiif_xml
131
- # It can be called with the same type of block as #to_iiif_json
132
-
133
129
  == Commandline
134
130
 
135
131
  There is also a little commandline utility for outputting the OpenURL.
@@ -153,4 +149,3 @@ Jason Ronallo, Willy Mene
153
149
  == Copyright
154
150
 
155
151
  Copyright (c) 2010 North Carolina State University. See LICENSE for details.
156
-
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{djatoka}
8
- s.version = "0.2.4"
8
+ s.version = "0.3.0"
9
9
  s.authors = ["Jason Ronallo", "Willy Mene"]
10
10
  s.email = %q{jronallo@gmail.com wmene@stanford.edu}
11
11
  s.homepage = %q{http://github.com/jronallo/djatoka}
@@ -39,7 +39,7 @@ module Djatoka
39
39
  # id = 'someImageId1234'
40
40
  #
41
41
  # request = Djatoka::IiifRequest.new(resolver, id)
42
- # djatoka_region = request.region('full').size('full').rotation('0').quality('native').format('jpg').djatoka_region
42
+ # djatoka_region = request.region('full').size('full').rotation('0').quality('default').format('jpg').djatoka_region
43
43
  class IiifRequest
44
44
 
45
45
  ALL_PARAMS = Set.new(['region', 'size', 'rotation', 'quality', 'format'])
@@ -105,7 +105,7 @@ module Djatoka
105
105
  raise IiifException.new(msg)
106
106
  end
107
107
 
108
- region = @resolver.region(@iiif_params[:id])
108
+ region = @resolver.region(@id)
109
109
 
110
110
  if(@iiif_params[:region] =~ /^(\d+),(\d+),(\d+),(\d+)$/)
111
111
  region.region("#{$2},#{$1},#{$4},#{$3}")
@@ -150,7 +150,7 @@ module Djatoka
150
150
  end
151
151
  region.format(type.to_s)
152
152
 
153
- unless(@iiif_params[:quality] =~ /^(native|color|grey|bitonal)$/i)
153
+ unless(@iiif_params[:quality] =~ /^(default|color|gray|bitonal)$/i)
154
154
  raise IiifInvalidParam.new 'quality', @iiif_params[:quality]
155
155
  end
156
156
 
@@ -160,4 +160,4 @@ module Djatoka
160
160
 
161
161
  end
162
162
 
163
- end
163
+ end
@@ -5,6 +5,10 @@ class Djatoka::Metadata
5
5
  :levels, :layer_count, :response, :resolver
6
6
  include Djatoka::Net
7
7
 
8
+ IIIF_20_CONTEXT_URI = 'http://iiif.io/api/image/2/context.json'
9
+ IIIF_20_PROTOCOL_URI = 'http://iiif.io/api/image'
10
+ IIIF_20_BASE_COMPLIANCE_URI = 'http://iiif.io/api/image/2'
11
+
8
12
  def initialize(resolver, rft_id)
9
13
  @resolver = resolver
10
14
  @rft_id = rft_id
@@ -76,90 +80,84 @@ class Djatoka::Metadata
76
80
  all_levels.keys.sort.last
77
81
  end
78
82
 
79
- # Builds a String containing the JSON response to a IIIF Image Information Request
83
+ # Builds a String containing the JSON-LD response to a IIIF Image Information Request
80
84
  #
81
- # * {Documentation about the Image Info Request}[http://www-sul.stanford.edu/iiif/image-api/#info]
85
+ # * {Documentation about the Image Info Request}[http://iiif.io/api/image/2.0/#information-request]
82
86
  #
83
- # It will fill in the required fields of identifier, width, and height. It will also fill in
84
- # the scale_factors as determined from Djatoka::Metadata#levels
85
- # The method yields a Mash where you can set the value of the optional fields. Here's an example:
87
+ # It will fill in the required @context, @id, protocol, width, height, and profile properties. It will also fill in
88
+ # sizes as determined from the Djatoka levels from Djatoka::Metadata#levels
89
+ # The method yields a Mash where you can set the value of the optional properties. Here's an example:
86
90
  #
87
- # metadata.to_iiif_xml do |info|
88
- # info.tile_width = 512
89
- # info.tile_height = 512
90
- # info.formats = ['jpg', 'png']
91
- # info.qualities = ['native', 'grey']
92
- # info.profile = 'http://library.stanford.edu/iiif/image-api/compliance.html#level1'
93
- # info.image_host = 'http://myserver.com/image'
91
+ # metadata.to_iiif_json do |opts|
92
+ # opts.tile_width = 512 # tile_* can be string or int
93
+ # opts.tile_height = "512"
94
+ # opts.compliance_level = 1
95
+ # opts.formats = ["jpg", "png"]
96
+ # opts.qualities = ["default", "gray"]
94
97
  # end
95
- def to_iiif_json(&block)
96
- info = Hashie::Mash.new
97
- info.identifier = @rft_id
98
- info.width = @width.to_i
99
- info.height = @height.to_i
100
- info.scale_factors = levels_as_i
101
- # optional fields map directly to json from the Mash
102
- yield(info)
103
-
104
- # convert strings to ints for tile width and height
105
- info.tile_width = info.tile_width.to_i if(info.tile_width?)
106
- info.tile_height = info.tile_height.to_i if(info.tile_height?)
107
- JSON.pretty_generate(info)
108
- end
98
+ def to_iiif_json(iiif_id, &block)
99
+ info = Hashie::Mash.new
100
+ info[:@context] = IIIF_20_CONTEXT_URI
101
+ info[:@id] = iiif_id
102
+ info.width = @width.to_i
103
+ info.height = @height.to_i
104
+ info.protocol = IIIF_20_PROTOCOL_URI
105
+
106
+ sizes = []
107
+ level_sizes = all_levels
108
+ levels_as_i.each do |l|
109
+ sizes << level_sizes[l]
110
+ end
111
+ info.sizes = sizes
109
112
 
110
- # Builds a String containing the xml response to a IIIF Image Information Request
111
- #
112
- # * {Documentation about the Image Info Request}[http://www-sul.stanford.edu/iiif/image-api/#info]
113
- #
114
- # It will fill in the required fields of identifier, width, and height. It will also fill in
115
- # the scale_factors as determined from Djatoka::Metadata#levels
116
- # The method yields a Mash where you can set the values of the optional fields. Here's an example:
117
- #
118
- # metadata.to_iiif_json do |info|
119
- # info.tile_width = 512
120
- # info.tile_height = 512
121
- # info.formats = ['jpg', 'png']
122
- # info.qualities = ['native', 'grey']
123
- # info.profile = 'http://library.stanford.edu/iiif/image-api/compliance.html#level1'
124
- # info.image_host = 'http://myserver.com/image'
125
- # end
126
- def to_iiif_xml(&block)
127
- builder = Nokogiri::XML::Builder.new do |xml|
128
- info = Hashie::Mash.new
129
- yield(info)
130
- xml.info('xmlns' => 'http://library.stanford.edu/iiif/image-api/ns/') {
131
- xml.identifier @rft_id
132
- xml.width @width
133
- xml.height @height
134
- xml.scale_factors {
135
- levels_as_i.each {|lvl| xml.scale_factor lvl}
136
- }
137
-
138
- #optional fields
139
- xml.tile_width info.tile_width if(info.tile_width?)
140
- xml.tile_height info.tile_height if(info.tile_height?)
141
- if(info.formats?)
142
- xml.formats {
143
- info.formats.each {|mt| xml.format mt}
144
- }
145
- end
146
- if(info.qualities?)
147
- xml.qualities {
148
- info.qualities.each {|q| xml.quality q}
149
- }
150
- end
151
- xml.profile info.profile if(info.profile?)
152
- xml.image_host info.image_host if(info.image_host?)
153
- }
113
+ if block_given?
114
+ opts = Hashie::Mash.new
115
+ yield(opts)
116
+ process_optional_iiif_fields info, opts
117
+ else
118
+ # Assume level 0 compliance if no options passed in
119
+ info.profile = [ "#{IIIF_20_BASE_COMPLIANCE_URI}/level0.json" ]
154
120
  end
155
- builder.to_xml
121
+
122
+ JSON.pretty_generate(info)
156
123
  end
157
124
 
158
125
  private
126
+
127
+ def process_optional_iiif_fields info, opts
128
+ tiles = {}
129
+ if opts.tile_width
130
+ tiles["width"] = opts.tile_width.to_i
131
+ end
132
+ if opts.tile_height
133
+ tiles["height"] = opts.tile_height.to_i
134
+ end
135
+ unless tiles.empty?
136
+ tiles["scaleFactors"] = levels_as_i
137
+ info.tiles = [tiles]
138
+ end
139
+
140
+ profile = []
141
+ if opts.compliance_level
142
+ c_level = opts.compliance_level
143
+ else
144
+ c_level = '0'
145
+ end
146
+ profile << "#{IIIF_20_BASE_COMPLIANCE_URI}/level#{c_level}.json"
147
+
148
+ profile_options = {}
149
+ if opts.formats
150
+ profile_options["formats"] = opts.formats
151
+ end
152
+ if opts.qualities
153
+ profile_options["qualities"] = opts.qualities
154
+ end
155
+ profile << profile_options unless profile_options.empty?
156
+ info.profile = profile
157
+ end
159
158
  # Just the levels themselves, as a sorted array of integers
160
159
  def levels_as_i
161
- all_levels.keys.map{ |l| l.to_i}.sort
160
+ all_levels.keys.map{ |l| l.to_i}.sort.reject{|l| l == 0}
162
161
  end
163
162
 
164
163
  end
165
-
@@ -11,6 +11,11 @@ module Djatoka
11
11
  # <tt>:resolver</tt> parameter when using one of these helpers.
12
12
  module ViewHelpers
13
13
 
14
+ def djatoka_image_url(rft_id, params={})
15
+ resolver, region = setup_djatoka_image_tag(rft_id, params)
16
+ region.url
17
+ end
18
+
14
19
  # Returns an image_tag. Unless params are passed in which constrain the
15
20
  # <tt>scale</tt> or <tt>level</tt> of the image, this will be the highest
16
21
  # resolution of the given image.
@@ -20,12 +25,13 @@ module Djatoka
20
25
  # djatoka_image_tag('info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3',
21
26
  # {:scale => 150, :region => [1400,500,1400,1500], :class => 'volleyball'})
22
27
  def djatoka_image_tag(rft_id, params={})
23
- resolver, region = setup_djatoka_image_tag(rft_id, params)
24
- if resolver and region
25
- image_tag region.url, clean_image_tag_params(params)
26
- else
28
+ url = djatoka_image_url(rft_id, params)
29
+ image_tag url, clean_image_tag_params(params)
30
+ end
27
31
 
28
- end
32
+ def djatoka_square_image_url(rft_id, params={})
33
+ resolver, region = setup_djatoka_image_tag(rft_id, params)
34
+ region.square.url
29
35
  end
30
36
 
31
37
  # Returns an image_tag for a square image. The long side is cropped.
@@ -35,42 +41,41 @@ module Djatoka
35
41
  # {:scale => 250, :class => 'djatoka_image_larger',
36
42
  # :resolver => 'http://african.lanl.gov/adore-djatoka/resolver' })
37
43
  def djatoka_square_image_tag(rft_id, params={})
38
- resolver, region = setup_djatoka_image_tag(rft_id, params)
39
- if resolver and region
40
- image_tag(region.square.url, clean_square_image_tag_params(params)) #+ debug(region)
41
- else
44
+ url = djatoka_square_image_url(rft_id, params)
45
+ image_tag(url, clean_square_image_tag_params(params)) #+ debug(region)
46
+ end
42
47
 
43
- end
48
+ def djatoka_top_left_square_image_url(rft_id, params={})
49
+ resolver, region = setup_djatoka_image_tag(rft_id, params)
50
+ region.top_left_square.url
44
51
  end
45
52
 
46
53
  # FIXME DRY
47
54
  def djatoka_top_left_square_image_tag(rft_id, params={})
48
- resolver, region = setup_djatoka_image_tag(rft_id, params)
49
- if resolver and region
50
- image_tag(region.top_left_square.url, clean_square_image_tag_params(params)) #+ debug(region)
51
- else
55
+ url = djatoka_top_left_square_image_url(rft_id, params)
56
+ image_tag(url, clean_square_image_tag_params(params))
57
+ end
52
58
 
53
- end
59
+ def djatoka_bottom_right_square_image_url(rft_id, params={})
60
+ resolver, region = setup_djatoka_image_tag(rft_id, params)
61
+ region.bottom_right_square.url
54
62
  end
55
63
 
56
64
  def djatoka_bottom_right_square_image_tag(rft_id, params={})
57
- resolver, region = setup_djatoka_image_tag(rft_id, params)
58
- if resolver and region
59
- image_tag(region.bottom_right_square.url, clean_square_image_tag_params(params)) #+ debug(region)
60
- else
65
+ url = djatoka_bottom_right_square_image_url(rft_id, params)
66
+ image_tag(url, clean_square_image_tag_params(params))
67
+ end
61
68
 
62
- end
69
+ def djatoka_smallbox_image_url(rft_id, params={})
70
+ resolver, region = setup_djatoka_image_tag(rft_id, params)
71
+ region.smallbox.url
63
72
  end
64
73
 
65
74
  # Returns an image tag for an image exactly 75x75
66
75
  # djatoka_smallbox_image_tag('info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3')
67
76
  def djatoka_smallbox_image_tag(rft_id, params={})
68
- resolver, region = setup_djatoka_image_tag(rft_id, params)
69
- if resolver and region
70
- image_tag region.smallbox.url, clean_square_image_tag_params(params)
71
- else
72
-
73
- end
77
+ url = djatoka_smallbox_image_url(rft_id, params)
78
+ image_tag url, clean_square_image_tag_params(params)
74
79
  end
75
80
 
76
81
  # Include djatoka_openlayers_script on any page you need pan and zoom to
@@ -123,19 +128,19 @@ module Djatoka
123
128
  nil
124
129
  end
125
130
  end
126
-
131
+
127
132
  def clean_image_tag_params(params)
128
133
  new_params = params.dup
129
- if new_params[:scale]
134
+ if new_params[:scale]
130
135
  new_params.delete(:scale)
131
136
  end
132
137
  new_params
133
138
  end
134
-
139
+
135
140
  def clean_square_image_tag_params(params)
136
141
  new_params = params.dup
137
- if new_params[:scale]
138
- new_params[:height] = new_params[:scale] unless new_params[:height]
142
+ if new_params[:scale]
143
+ new_params[:height] = new_params[:scale] unless new_params[:height]
139
144
  new_params[:width] = new_params[:scale] unless new_params[:width]
140
145
  new_params.delete(:scale)
141
146
  end
@@ -9,9 +9,13 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
9
9
 
10
10
  context 'from a IIIF request with all defaults' do
11
11
  setup do
12
- @region = @req.region('full').size('full').rotation('0').quality('native').format('jpg').djatoka_region
12
+ @region = @req.region('full').size('full').rotation('0').quality('default').format('jpg').djatoka_region
13
13
  end
14
14
 
15
+ should 'set id properly' do
16
+ assert_equal @identifier, @region.rft_id
17
+ end
18
+
15
19
  should 'set region to nil from full' do
16
20
  assert_nil @region.query.region
17
21
  end
@@ -32,7 +36,7 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
32
36
 
33
37
  context 'translates region parameters' do
34
38
  setup do
35
- @req.size('full').rotation('0').quality('native').format('jpg')
39
+ @req.size('full').rotation('0').quality('default').format('jpg')
36
40
  end
37
41
 
38
42
  should 'set x,y,w,h requests' do
@@ -49,7 +53,7 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
49
53
 
50
54
  context 'translates size parameters' do
51
55
  setup do
52
- @req.region('10,20,50,100').rotation('0').quality('native').format('jpg')
56
+ @req.region('10,20,50,100').rotation('0').quality('default').format('jpg')
53
57
  end
54
58
 
55
59
  should 'set "w," requests to the correct scale value' do
@@ -85,7 +89,7 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
85
89
 
86
90
  context 'translates rotation parameters' do
87
91
  setup do
88
- @req.region('10,20,50,100').size('800,').quality('native').format('jpg')
92
+ @req.region('10,20,50,100').size('800,').quality('default').format('jpg')
89
93
  end
90
94
 
91
95
  should 'set values that are numeric' do
@@ -105,7 +109,7 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
105
109
 
106
110
  context 'translates format parameters' do
107
111
  setup do
108
- @req.region('full').size('full').rotation('0').quality('native')
112
+ @req.region('full').size('full').rotation('0').quality('default')
109
113
  end
110
114
 
111
115
  should 'set the format from a valid extension as from the end of a URL' do
@@ -151,12 +155,12 @@ class TestDjatokaIiifRequest < Test::Unit::TestCase
151
155
 
152
156
  context '#all_params_present?' do
153
157
  should 'return true when all the valid params have been set' do
154
- @req.region('full').size('full').rotation('0').quality('native').format('jpg')
158
+ @req.region('full').size('full').rotation('0').quality('default').format('jpg')
155
159
  assert @req.all_params_present?
156
160
  end
157
161
 
158
162
  should 'return false when params are missing' do
159
- @req.region('full').size('full').quality('native').format('jpg')
163
+ @req.region('full').size('full').quality('default').format('jpg')
160
164
  assert_equal false, @req.all_params_present?
161
165
  end
162
166
  end
@@ -116,71 +116,74 @@ class TestDjatokaMetadata < Test::Unit::TestCase
116
116
  should 'create json responses' do
117
117
  iiif_json = <<-EOF
118
118
  {
119
- "identifier": "info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3",
119
+ "@context": "http://iiif.io/api/image/2/context.json",
120
+ "@id": "http://yourserver.edu/iiif/your%2Fimage_id",
120
121
  "width": 5120,
121
122
  "height": 3372,
122
- "scale_factors": [ 0,1,2,3,4,5,6 ],
123
- "tile_width": 512,
124
- "tile_height": 512,
125
- "formats": [ "jpg", "png" ],
126
- "qualities": [ "native", "grey" ],
127
- "profile": "http://library.stanford.edu/iiif/image-api/compliance.html#level1",
128
- "image_host": "http://myserver.com/image"
123
+ "protocol": "http://iiif.io/api/image",
124
+ "tiles" : [
125
+ {
126
+ "width": 512,
127
+ "height": 512,
128
+ "scaleFactors": [1, 2, 3, 4, 5, 6]
129
+ }
130
+ ],
131
+ "sizes": [
132
+ {"height": 106, "width": 160},
133
+ {"height": 211, "width": 320},
134
+ {"height": 422, "width": 640},
135
+ {"height": 843, "width": 1280},
136
+ {"height": 1686, "width": 2560},
137
+ {"height": 3372, "width": 5120}
138
+ ],
139
+ "profile": [
140
+ "http://iiif.io/api/image/2/level1.json",
141
+ {
142
+ "formats": [ "jpg", "png" ],
143
+ "qualities": [ "default", "gray" ]
144
+ }
145
+ ]
129
146
  }
130
147
  EOF
131
148
  expected = JSON.parse(iiif_json)
132
149
 
133
- str = @metadata.to_iiif_json do |info|
134
- info.tile_width = '512'
135
- info.tile_height = 512 # tile_* can be string or int
136
- info.formats = ['jpg', 'png']
137
- info.qualities = ['native', 'grey']
138
- info.profile = 'http://library.stanford.edu/iiif/image-api/compliance.html#level1'
139
- info.image_host = 'http://myserver.com/image'
150
+ str = @metadata.to_iiif_json('http://yourserver.edu/iiif/your%2Fimage_id') do |opts|
151
+ opts.tile_width = 512 # tile_* can be string or int
152
+ opts.tile_height = "512"
153
+ opts.compliance_level = 1
154
+ opts.formats = ["jpg", "png"]
155
+ opts.qualities = ["default", "gray"]
140
156
  end
141
157
  assert_equal expected, JSON.parse(str)
142
158
  end
143
159
 
144
- should 'create xml responses' do
145
- iiif_xml =<<-EOXML
146
- <info xmlns="http://library.stanford.edu/iiif/image-api/ns/">
147
- <identifier>info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3</identifier>
148
- <width>5120</width>
149
- <height>3372</height>
150
- <scale_factors>
151
- <scale_factor>0</scale_factor>
152
- <scale_factor>1</scale_factor>
153
- <scale_factor>2</scale_factor>
154
- <scale_factor>3</scale_factor>
155
- <scale_factor>4</scale_factor>
156
- <scale_factor>5</scale_factor>
157
- <scale_factor>6</scale_factor>
158
- </scale_factors>
159
- <tile_width>512</tile_width>
160
- <tile_height>512</tile_height>
161
- <formats>
162
- <format>jpg</format>
163
- <format>png</format>
164
- </formats>
165
- <qualities>
166
- <quality>native</quality>
167
- <quality>grey</quality>
168
- </qualities>
169
- <profile>http://library.stanford.edu/iiif/image-api/compliance.html#level1</profile>
170
- <image_host>http://myserver.com/image</image_host>
171
- </info>
172
- EOXML
173
-
174
- str = @metadata.to_iiif_xml do |info|
175
- info.tile_width = '512'
176
- info.tile_height = 512 # tile_* can be string or int
177
- info.formats = ['jpg', 'png']
178
- info.qualities = ['native', 'grey']
179
- info.profile = 'http://library.stanford.edu/iiif/image-api/compliance.html#level1'
180
- info.image_host = 'http://myserver.com/image'
181
- end
182
- assert EquivalentXml.equivalent?(str, iiif_xml)
160
+ should 'create a minimal json response with required properties if no options are passed in' do
161
+ iiif_json = <<-EOF
162
+ {
163
+ "@context": "http://iiif.io/api/image/2/context.json",
164
+ "@id": "http://yourserver.edu/iiif/your%2Fimage_id",
165
+ "width": 5120,
166
+ "height": 3372,
167
+ "protocol": "http://iiif.io/api/image",
168
+ "sizes": [
169
+ {"height": 106, "width": 160},
170
+ {"height": 211, "width": 320},
171
+ {"height": 422, "width": 640},
172
+ {"height": 843, "width": 1280},
173
+ {"height": 1686, "width": 2560},
174
+ {"height": 3372, "width": 5120}
175
+ ],
176
+ "profile": [
177
+ "http://iiif.io/api/image/2/level0.json"
178
+ ]
179
+ }
180
+ EOF
181
+ expected = JSON.parse(iiif_json)
182
+
183
+ str = @metadata.to_iiif_json('http://yourserver.edu/iiif/your%2Fimage_id')
184
+ assert_equal expected, JSON.parse(str)
183
185
  end
186
+
184
187
  end #IIIF Info Responses
185
188
 
186
189
  end #with_a_resolver
@@ -64,7 +64,7 @@ class TestDjatokaResolver < Test::Unit::TestCase
64
64
  :region => 'full',
65
65
  :size => 'full',
66
66
  :rotation => '0',
67
- :quality => 'native',
67
+ :quality => 'default',
68
68
  :format => 'jpg'
69
69
  }
70
70
  end
@@ -118,4 +118,3 @@ class TestDjatokaResolver < Test::Unit::TestCase
118
118
 
119
119
  end #with_a_resolver
120
120
  end
121
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djatoka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Ronallo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-24 00:00:00.000000000 Z
12
+ date: 2015-01-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -213,8 +213,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  requirements: []
215
215
  rubyforge_project: djatoka
216
- rubygems_version: 2.2.2
216
+ rubygems_version: 2.4.2
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Djatoka image server helpers for Ruby and Rails.
220
- test_files: []
220
+ test_files:
221
+ - test/fixtures/5aa182c2-c092-4596-af6e-e95d2e263de3.json
222
+ - test/fixtures/b820f537-26a1-4af8-b86a-e7a4cac6187a.json
223
+ - test/fixtures/empty-metadata.json
224
+ - test/fixtures/https_metadata_request.json
225
+ - test/fixtures/ping-5aa182c2-c092-4596-af6e-e95d2e263de3.json
226
+ - test/fixtures/ping-asdf.json
227
+ - test/fixtures/ua023_015-006-bx0003-014-075-metadata.json
228
+ - test/helper.rb
229
+ - test/test_common.rb
230
+ - test/test_djatoka.rb
231
+ - test/test_iiif_request.rb
232
+ - test/test_metadata.rb
233
+ - test/test_region.rb
234
+ - test/test_resolver.rb
235
+ - test/test_view_helpers.rb
236
+ has_rdoc: