djatoka 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/djatoka/common.rb +9 -9
- data/lib/djatoka/metadata.rb +3 -3
- data/test/helper.rb +14 -6
- data/test/test_common.rb +11 -0
- data/test/test_metadata.rb +13 -0
- metadata +36 -22
data/Rakefile
CHANGED
@@ -13,6 +13,7 @@ begin
|
|
13
13
|
gem.add_development_dependency "shoulda", ">= 0"
|
14
14
|
#gem.add_development_dependency "ruby-debug", ">= 0"
|
15
15
|
gem.add_development_dependency "hanna", ">= 0"
|
16
|
+
gem.add_development_dependency "fakeweb", ">= 0"
|
16
17
|
gem.add_dependency "addressable", "2.1.2"
|
17
18
|
gem.add_development_dependency "curb", ">= 0"
|
18
19
|
gem.add_dependency "json", ">= 0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/djatoka/common.rb
CHANGED
@@ -60,11 +60,11 @@ module Djatoka::Common
|
|
60
60
|
end
|
61
61
|
# Here we try to compensate for when the dwtLevels does not match the
|
62
62
|
# djatoka levels.
|
63
|
-
if metadata.dwt_levels.to_i > metadata.levels.to_i
|
64
|
-
best_level.to_i - 2
|
65
|
-
elsif metadata.dwt_levels.to_i == metadata.levels.to_i
|
63
|
+
# if metadata.dwt_levels.to_i > metadata.levels.to_i
|
64
|
+
# best_level.to_i - 2
|
65
|
+
# elsif metadata.dwt_levels.to_i == metadata.levels.to_i
|
66
66
|
best_level.to_i
|
67
|
-
end
|
67
|
+
# end
|
68
68
|
end
|
69
69
|
|
70
70
|
private
|
@@ -88,13 +88,13 @@ module Djatoka::Common
|
|
88
88
|
# we try to compensate for when there is a difference between the
|
89
89
|
# dwtLevels and the djatoka levels. So far the only case seen is where
|
90
90
|
# the dwtLevels are greater than the djatoka levels.
|
91
|
-
if metadata.dwt_levels.to_i > metadata.levels.to_i
|
92
|
-
difference = metadata.dwt_levels.to_i - metadata.levels.to_i
|
93
|
-
good_query_level = query.level.to_i + difference
|
91
|
+
# if metadata.dwt_levels.to_i > metadata.levels.to_i
|
92
|
+
# difference = metadata.dwt_levels.to_i - metadata.levels.to_i
|
93
|
+
# good_query_level = query.level.to_i + difference
|
94
94
|
# dwtLevels in the cases seen so far almost always match the djatoka levels.
|
95
|
-
elsif metadata.dwt_levels.to_i == metadata.levels.to_i
|
95
|
+
# elsif metadata.dwt_levels.to_i == metadata.levels.to_i
|
96
96
|
good_query_level = query.level.to_i
|
97
|
-
end
|
97
|
+
# end
|
98
98
|
height = metadata.all_levels[good_query_level].height
|
99
99
|
width = metadata.all_levels[good_query_level].width
|
100
100
|
else
|
data/lib/djatoka/metadata.rb
CHANGED
@@ -56,12 +56,12 @@ class Djatoka::Metadata
|
|
56
56
|
def all_levels
|
57
57
|
perform if !response # if we haven't already performed the metadata query do it now
|
58
58
|
levels_hash = Hashie::Mash.new
|
59
|
-
|
60
|
-
(0..
|
59
|
+
levels_i = levels.to_i
|
60
|
+
(0..levels_i).each do |level_num|
|
61
61
|
level_height = height.to_i
|
62
62
|
level_width = width.to_i
|
63
63
|
|
64
|
-
times_to_halve =
|
64
|
+
times_to_halve = levels_i - level_num
|
65
65
|
times_to_halve.times do
|
66
66
|
level_height = level_height / 2
|
67
67
|
level_width = level_width / 2
|
data/test/helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
|
+
require 'fakeweb'
|
4
5
|
|
5
6
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
7
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -21,13 +22,20 @@ class Test::Unit::TestCase
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def set_testing_curb
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
Djatoka.use_curb = false
|
26
|
+
# begin
|
27
|
+
# require 'curb'
|
28
|
+
# Djatoka.use_curb = true
|
29
|
+
# rescue LoadError
|
30
|
+
# Djatoka.use_curb = false
|
31
|
+
# end
|
30
32
|
end
|
31
33
|
|
32
34
|
end
|
33
35
|
|
36
|
+
|
37
|
+
#curl -is -H 'Accept: application/json' -d "url_ver=Z39.88-2004&rft_id=ua023_015-006-bx0003-014-075&svc_id=info%3Alanl-repo%2Fsvc%2FgetMetadata" http://scrc.lib.ncsu.edu/adore-djatoka/resolver > test/fixtures/ua023_015-006-bx0003-014-075-metadata.json
|
38
|
+
|
39
|
+
FakeWeb.register_uri(:get, "http://african.lanl.gov/adore-djatoka/resolver?rft_id=ua023_015-006-bx0003-014-075&svc_id=info%3Alanl-repo%2Fsvc%2FgetMetadata&url_ver=Z39.88-2004",
|
40
|
+
:response => File.read('test/fixtures/ua023_015-006-bx0003-014-075-metadata.json'))
|
41
|
+
|
data/test/test_common.rb
CHANGED
@@ -57,6 +57,17 @@ context 'A Djatoka Resolver' do
|
|
57
57
|
assert_equal '513,0,4093,4093', @region.square.query.region
|
58
58
|
end
|
59
59
|
end
|
60
|
+
|
61
|
+
context 'an image where the dwt_levels do not match the djatoka levels' do
|
62
|
+
setup do
|
63
|
+
@region2 = Djatoka::Region.new(@resolver, 'ua023_015-006-bx0003-014-075')
|
64
|
+
end
|
65
|
+
should 'be able to scale properly' do
|
66
|
+
@region2.scale('300').square
|
67
|
+
assert @region2.url
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
60
71
|
end
|
61
72
|
|
62
73
|
end
|
data/test/test_metadata.rb
CHANGED
@@ -76,6 +76,19 @@ class TestDjatokaMetadata < Test::Unit::TestCase
|
|
76
76
|
"6"=>{"height"=>3372, "width"=>5120},}
|
77
77
|
assert_equal levels, @levels
|
78
78
|
end
|
79
|
+
should 'return appropriate height and width for all levels when levels and dwt_levels do not match' do
|
80
|
+
levels = {"0"=>{"height"=>57, "width"=>37},
|
81
|
+
"1"=>{"height"=>114, "width"=>74},
|
82
|
+
"2"=>{"height"=>228, "width"=>148},
|
83
|
+
"3"=>{"height"=>457, "width"=>296},
|
84
|
+
"4"=>{"height"=>915, "width"=>592}}
|
85
|
+
metadata = @resolver.metadata('ua023_015-006-bx0003-014-075').perform
|
86
|
+
returned_levels = metadata.all_levels
|
87
|
+
assert_equal levels, returned_levels
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
|
79
92
|
end # levels
|
80
93
|
|
81
94
|
end #with_a_resolver
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: djatoka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason Ronallo
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-28 00:00:00 -04:00
|
19
19
|
default_executable: djatoka_url
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,9 +47,23 @@ dependencies:
|
|
47
47
|
type: :development
|
48
48
|
version_requirements: *id002
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
50
|
+
name: fakeweb
|
51
51
|
prerelease: false
|
52
52
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :development
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: addressable
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
67
|
none: false
|
54
68
|
requirements:
|
55
69
|
- - "="
|
@@ -61,11 +75,11 @@ dependencies:
|
|
61
75
|
- 2
|
62
76
|
version: 2.1.2
|
63
77
|
type: :runtime
|
64
|
-
version_requirements: *
|
78
|
+
version_requirements: *id004
|
65
79
|
- !ruby/object:Gem::Dependency
|
66
80
|
name: curb
|
67
81
|
prerelease: false
|
68
|
-
requirement: &
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
69
83
|
none: false
|
70
84
|
requirements:
|
71
85
|
- - ">="
|
@@ -75,11 +89,11 @@ dependencies:
|
|
75
89
|
- 0
|
76
90
|
version: "0"
|
77
91
|
type: :development
|
78
|
-
version_requirements: *
|
92
|
+
version_requirements: *id005
|
79
93
|
- !ruby/object:Gem::Dependency
|
80
94
|
name: json
|
81
95
|
prerelease: false
|
82
|
-
requirement: &
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
83
97
|
none: false
|
84
98
|
requirements:
|
85
99
|
- - ">="
|
@@ -89,11 +103,11 @@ dependencies:
|
|
89
103
|
- 0
|
90
104
|
version: "0"
|
91
105
|
type: :runtime
|
92
|
-
version_requirements: *
|
106
|
+
version_requirements: *id006
|
93
107
|
- !ruby/object:Gem::Dependency
|
94
108
|
name: trollop
|
95
109
|
prerelease: false
|
96
|
-
requirement: &
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
97
111
|
none: false
|
98
112
|
requirements:
|
99
113
|
- - ">="
|
@@ -103,11 +117,11 @@ dependencies:
|
|
103
117
|
- 0
|
104
118
|
version: "0"
|
105
119
|
type: :runtime
|
106
|
-
version_requirements: *
|
120
|
+
version_requirements: *id007
|
107
121
|
- !ruby/object:Gem::Dependency
|
108
122
|
name: hashie
|
109
123
|
prerelease: false
|
110
|
-
requirement: &
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
111
125
|
none: false
|
112
126
|
requirements:
|
113
127
|
- - ">="
|
@@ -117,7 +131,7 @@ dependencies:
|
|
117
131
|
- 0
|
118
132
|
version: "0"
|
119
133
|
type: :runtime
|
120
|
-
version_requirements: *
|
134
|
+
version_requirements: *id008
|
121
135
|
description: The djatoka library provides some simple methods for creation of the OpenURLs needed to communicate with the Djatoka image server.
|
122
136
|
email: jronallo@gmail.com
|
123
137
|
executables:
|
@@ -153,13 +167,13 @@ files:
|
|
153
167
|
- lib/djatoka/region.rb
|
154
168
|
- lib/djatoka/resolver.rb
|
155
169
|
- lib/djatoka/view_helpers.rb
|
156
|
-
- test/test_common.rb
|
157
|
-
- test/test_region.rb
|
158
|
-
- test/helper.rb
|
159
170
|
- test/test_metadata.rb
|
171
|
+
- test/test_djatoka.rb
|
160
172
|
- test/test_resolver.rb
|
161
173
|
- test/test_view_helpers.rb
|
162
|
-
- test/
|
174
|
+
- test/test_region.rb
|
175
|
+
- test/helper.rb
|
176
|
+
- test/test_common.rb
|
163
177
|
has_rdoc: true
|
164
178
|
homepage: http://github.com/jronallo/djatoka
|
165
179
|
licenses: []
|
@@ -195,10 +209,10 @@ signing_key:
|
|
195
209
|
specification_version: 3
|
196
210
|
summary: Djatoka image server helpers for Ruby and Rails.
|
197
211
|
test_files:
|
198
|
-
- test/test_common.rb
|
199
|
-
- test/test_region.rb
|
200
|
-
- test/helper.rb
|
201
212
|
- test/test_metadata.rb
|
213
|
+
- test/test_djatoka.rb
|
202
214
|
- test/test_resolver.rb
|
203
215
|
- test/test_view_helpers.rb
|
204
|
-
- test/
|
216
|
+
- test/test_region.rb
|
217
|
+
- test/helper.rb
|
218
|
+
- test/test_common.rb
|