djatoka 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,25 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ .redcar
23
+ .rvmrc
24
+
25
+ .rbx
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-19mode
7
+ # uncomment this line if your project needs to run something other than `rake`:
8
+ script: rake test
9
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rdoc', ">= 2.4.2"
6
+ gem 'rake'
7
+ gem 'pry'
8
+ gem 'rb-readline'
@@ -0,0 +1,68 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ djatoka (0.2.0)
5
+ addressable
6
+ hashie
7
+ json
8
+ trollop
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (3.2.13)
14
+ i18n (= 0.6.1)
15
+ multi_json (~> 1.0)
16
+ addressable (2.3.3)
17
+ bourne (1.4.0)
18
+ mocha (~> 0.13.2)
19
+ coderay (1.0.9)
20
+ fakeweb (1.3.0)
21
+ ffi (1.6.0-java)
22
+ hashie (2.0.3)
23
+ i18n (0.6.1)
24
+ json (1.7.7)
25
+ json (1.7.7-java)
26
+ metaclass (0.0.1)
27
+ method_source (0.8.1)
28
+ mocha (0.13.3)
29
+ metaclass (~> 0.0.1)
30
+ multi_json (1.7.2)
31
+ pry (0.9.12)
32
+ coderay (~> 1.0.5)
33
+ method_source (~> 0.8)
34
+ slop (~> 3.4)
35
+ pry (0.9.12-java)
36
+ coderay (~> 1.0.5)
37
+ method_source (~> 0.8)
38
+ slop (~> 3.4)
39
+ spoon (~> 0.0)
40
+ rake (10.0.4)
41
+ rb-readline (0.4.2)
42
+ rdoc (4.0.1)
43
+ json (~> 1.4)
44
+ shoulda (3.4.0)
45
+ shoulda-context (~> 1.0, >= 1.0.1)
46
+ shoulda-matchers (~> 1.0, >= 1.4.1)
47
+ shoulda-context (1.0.2)
48
+ shoulda-matchers (1.5.4)
49
+ activesupport (>= 3.0.0)
50
+ bourne (~> 1.3)
51
+ slop (3.4.4)
52
+ spoon (0.0.3)
53
+ ffi
54
+ trollop (2.0)
55
+
56
+ PLATFORMS
57
+ java
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ djatoka!
62
+ fakeweb
63
+ mocha
64
+ pry
65
+ rake
66
+ rb-readline
67
+ rdoc (>= 2.4.2)
68
+ shoulda
@@ -4,6 +4,8 @@ Simple library for use with the {Djatoka JPEG2000 image server}[http://sourcefor
4
4
  It helps ease creation of the {OpenURLs}[http://sourceforge.net/apps/mediawiki/djatoka/index.php?title=Djatoka_OpenURL_Services#djatoka_OpenURL_Service_Types]
5
5
  used by Djatoka.
6
6
 
7
+ {<img src="https://travis-ci.org/jronallo/djatoka.png" />}[https://travis-ci.org/jronallo/djatoka]
8
+
7
9
  == Installation
8
10
 
9
11
  {Install the Djatoka image server}[http://sourceforge.net/apps/mediawiki/djatoka/index.php?title=Installation]
data/Rakefile CHANGED
@@ -1,32 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "djatoka"
8
- gem.summary = %Q{Djatoka image server helpers for Ruby and Rails.}
9
- gem.description = %Q{The djatoka library provides some simple methods for creation of the OpenURLs needed to communicate with the Djatoka image server.}
10
- gem.email = "jronallo@gmail.com"
11
- gem.homepage = "http://github.com/jronallo/djatoka"
12
- gem.authors = ["Jason Ronallo"]
13
- gem.add_development_dependency "shoulda", ">= 0"
14
- #gem.add_development_dependency "ruby-debug", ">= 0"
15
- gem.add_development_dependency "hanna", ">= 0"
16
- gem.add_development_dependency "fakeweb", ">= 0"
17
- gem.add_dependency "addressable"
18
- gem.add_development_dependency "curb", ">= 0"
19
- gem.add_dependency "json", ">= 0"
20
- gem.add_dependency 'trollop', '>= 0'
21
- gem.add_dependency 'hashie', '>= 0'
22
- gem.files = FileList["[A-Z]*", "{bin,generators,lib}/**/*"]
23
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
24
- end
25
- Jeweler::GemcutterTasks.new
26
- rescue LoadError
27
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
28
- end
29
-
30
4
  require 'rake/testtask'
31
5
  Rake::TestTask.new(:test) do |test|
32
6
  test.libs << 'lib' << 'test'
@@ -47,16 +21,11 @@ rescue LoadError
47
21
  end
48
22
  end
49
23
 
50
- task :test => :check_dependencies
51
-
52
24
  task :default => :test
53
25
 
54
- begin
55
- require 'hanna/rdoctask'
56
- rescue LoadError
57
- require 'rake/rdoctask'
58
- end
59
- Rake::RDocTask.new do |rdoc|
26
+ require 'rdoc/task'
27
+
28
+ RDoc::Task.new do |rdoc|
60
29
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
61
30
 
62
31
  rdoc.rdoc_dir = 'rdoc'
@@ -0,0 +1,30 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{djatoka}
8
+ s.version = "0.2.0"
9
+ s.authors = ["Jason Ronallo"]
10
+ s.email = %q{jronallo@gmail.com}
11
+ s.homepage = %q{http://github.com/jronallo/djatoka}
12
+ s.summary = %q{Djatoka image server helpers for Ruby and Rails.}
13
+ s.description = %q{The djatoka library provides some simple methods for creation of the OpenURLs needed to communicate with the Djatoka image server.}
14
+ s.rubyforge_project = "djatoka"
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "addressable"
21
+ s.add_dependency "hashie"
22
+ s.add_dependency "json"
23
+
24
+ s.add_dependency "trollop"
25
+
26
+ s.add_development_dependency "mocha"
27
+ s.add_development_dependency "fakeweb"
28
+ s.add_development_dependency "shoulda"
29
+ end
30
+
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://african.lanl.gov/adore-djatoka/resolver?rft_id=ua023_015-006-bx0003-014-075&svc_id=info:lanl-repo/svc/getMetadata&url_ver=Z39.88-2004
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - african.lanl.gov
18
+ response:
19
+ status:
20
+ code: 404
21
+ message: Not Found
22
+ headers:
23
+ Date:
24
+ - Sat, 30 Mar 2013 00:39:45 GMT
25
+ Server:
26
+ - Apache
27
+ Set-Cookie:
28
+ - JSESSIONID=51591DC81C68ACA60BFE0D714C98FE93; Path=/adore-djatoka
29
+ Content-Length:
30
+ - '952'
31
+ Connection:
32
+ - close
33
+ Content-Type:
34
+ - text/html;charset=utf-8
35
+ body:
36
+ encoding: UTF-8
37
+ string: '<html><head><title>Apache Tomcat/6.0.18 - Error report</title><style><!--H1
38
+ {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
39
+ H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
40
+ H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
41
+ BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
42
+ B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
43
+ P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
44
+ {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP
45
+ Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b>
46
+ <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR
47
+ size="1" noshade="noshade"><h3>Apache Tomcat/6.0.18</h3></body></html>'
48
+ http_version:
49
+ recorded_at: Sat, 30 Mar 2013 00:39:45 GMT
50
+ recorded_with: VCR 2.4.0
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'djatoka'
2
+
@@ -58,7 +58,6 @@ require 'djatoka/metadata'
58
58
  require 'djatoka/common'
59
59
  require 'djatoka/region'
60
60
 
61
- require 'rubygems'
62
61
  require 'addressable/uri'
63
62
  require 'addressable/template'
64
63
  require 'json'
@@ -3,12 +3,13 @@
3
3
  # and Djatoka::Metadata objects.
4
4
  class Djatoka::Resolver
5
5
  include Djatoka::Net
6
- attr_accessor :base_url, :host, :path, :port
6
+ attr_accessor :base_url, :scheme, :host, :path, :port
7
7
 
8
8
  def initialize(base_url='http://african.lanl.gov/adore-djatoka/resolver')
9
9
  #if base_url.to_s =~ /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix
10
10
  uri = Addressable::URI.parse(base_url)
11
11
  @base_url = uri.to_s
12
+ @scheme = uri.scheme
12
13
  @host = uri.host
13
14
  @path = uri.path
14
15
  @port = uri.port
@@ -63,7 +64,7 @@ class Djatoka::Resolver
63
64
  end
64
65
 
65
66
  def base_uri_params
66
- params = {:host => host, :path => path, :scheme => 'http'}
67
+ params = {:host => host, :path => path, :scheme => scheme}
67
68
  params[:port] = port if port
68
69
  params
69
70
  end
@@ -76,7 +77,7 @@ class Djatoka::Resolver
76
77
  private
77
78
 
78
79
  def ping_url_template
79
- Addressable::Template.new("#{base_url}?url_ver=Z39.88-2004&svc_id=info:lanl-repo/svc/ping&rft_id={rft_id}")
80
+ Addressable::Template.new("#{base_url}?url_ver=Z39.88-2004&svc_id=info%3Alanl-repo%2Fsvc%2Fping&rft_id={rft_id}")
80
81
  end
81
82
 
82
83
  end
@@ -0,0 +1,16 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Sat, 30 Mar 2013 01:08:53 GMT
3
+ Server: Apache
4
+ Set-Cookie: JSESSIONID=F35F3F94F2C099D755C1A769EA502607; Path=/adore-djatoka
5
+ Connection: close
6
+ Content-Type: application/json
7
+
8
+ {
9
+ "identifier": "info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3",
10
+ "imagefile": "/lanl/data/loc/cc5fc4f7-e50a-455f-b3ce-a6a8b54824e6/WEJLNXSBWO7LPLC7Z6DITFX7A45XR3GS.jp2",
11
+ "width": "5120",
12
+ "height": "3372",
13
+ "dwtLevels": "6",
14
+ "levels": "6",
15
+ "compositingLayerCount": "1"
16
+ }
@@ -0,0 +1,16 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Sat, 30 Mar 2013 00:56:24 GMT
3
+ Server: Apache
4
+ Set-Cookie: JSESSIONID=086B6175C0316D0303537438B30FDD0F; Path=/adore-djatoka
5
+ Connection: close
6
+ Content-Type: application/json
7
+
8
+ {
9
+ "identifier": "info:lanl-repo/ds/b820f537-26a1-4af8-b86a-e7a4cac6187a",
10
+ "imagefile": "/lanl/data/loc/cc5fc4f7-e50a-455f-b3ce-a6a8b54824e6/VQCPNSNDKZKKNBTISHN6MJ6WGSQFNZKP.jp2",
11
+ "width": "4093",
12
+ "height": "5120",
13
+ "dwtLevels": "6",
14
+ "levels": "6",
15
+ "compositingLayerCount": "1"
16
+ }
@@ -0,0 +1,8 @@
1
+ HTTP/1.1 404 Not Found
2
+ Date: Mon, 15 Nov 2010 14:47:20 GMT
3
+ Server: Apache-Coyote/1.1
4
+ Content-Type: text/html;charset=utf-8
5
+ Content-Length: 950
6
+ Set-Cookie: JSESSIONID=0104D2734B09430B6085AC81E28F3B20; Path=/adore-djatoka; HttpOnly
7
+
8
+ <html><head><title>Apache Tomcat/7.0.0 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.0</h3></body></html>
@@ -0,0 +1,11 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Sat, 30 Mar 2013 01:16:37 GMT
3
+ Server: Apache
4
+ Set-Cookie: JSESSIONID=41D9E6B865CE04849F262F9FD8AE0FDF; Path=/adore-djatoka
5
+ Connection: close
6
+ Content-Type: application/json
7
+
8
+ {
9
+ "identifier": "info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3",
10
+ "status": "OK"
11
+ }
@@ -0,0 +1,9 @@
1
+ HTTP/1.1 404 Not Found
2
+ Date: Sat, 30 Mar 2013 01:25:08 GMT
3
+ Server: Apache
4
+ Set-Cookie: JSESSIONID=EADCA5FFAC35D0940853DA3132554440; Path=/adore-djatoka
5
+ Content-Length: 952
6
+ Connection: close
7
+ Content-Type: text/html;charset=utf-8
8
+
9
+ <html><head><title>Apache Tomcat/6.0.18 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource () is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.18</h3></body></html>
@@ -0,0 +1,16 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Thu, 28 Oct 2010 12:28:14 GMT
3
+ Server: Apache-Coyote/1.1
4
+ Content-Type: application/json
5
+ Content-Length: 210
6
+ Set-Cookie: JSESSIONID=609FDF8E99BF39EE3803A501CFEF1C9B; Path=/adore-djatoka; HttpOnly
7
+
8
+ {
9
+ "identifier": "ua023_015-006-bx0003-014-075",
10
+ "imagefile": "/storage/ua023_0/ua023_015-006-bx0003-014-075.jp2",
11
+ "width": "592",
12
+ "height": "915",
13
+ "dwtLevels": "7",
14
+ "levels": "4",
15
+ "compositingLayerCount": "1"
16
+ }
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'fakeweb'
5
+ require 'pry'
6
+
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'djatoka'
10
+ #require 'ruby-debug'
11
+
12
+ class Test::Unit::TestCase
13
+ def self.with_a_resolver(&block)
14
+ context 'resolver setup' do
15
+ setup do
16
+ @resolver = Djatoka::Resolver.new('http://african.lanl.gov/adore-djatoka/resolver')
17
+ @identifier = 'info:lanl-repo/ds/5aa182c2-c092-4596-af6e-e95d2e263de3'
18
+ @url_encoded_identifier = 'info%3Alanl-repo%2Fds%2F5aa182c2-c092-4596-af6e-e95d2e263de3'
19
+ end
20
+
21
+ merge_block(&block) if block_given?
22
+ end
23
+ end
24
+
25
+ def set_testing_curb
26
+ Djatoka.use_curb = false
27
+ # begin
28
+ # require 'curb'
29
+ # Djatoka.use_curb = true
30
+ # rescue LoadError
31
+ # Djatoka.use_curb = false
32
+ # end
33
+ end
34
+
35
+ end
36
+
37
+
38
+ #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
39
+
40
+ 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",
41
+ :response => File.read('test/fixtures/ua023_015-006-bx0003-014-075-metadata.json'))
42
+
43
+ FakeWeb.register_uri(:get, "http://african.lanl.gov/adore-djatoka/resolver?rft_id=asdf&svc_id=info%3Alanl-repo%2Fsvc%2FgetMetadata&url_ver=Z39.88-2004",
44
+ :response => File.read('test/fixtures/empty-metadata.json'))
45
+ FakeWeb.register_uri(:get, "http://african.lanl.gov/adore-djatoka/resolver?url_ver=Z39.88-2004&svc_id=info%3Alanl-repo%2Fsvc%2Fping&rft_id=asdf",
46
+ :response => File.read('test/fixtures/ping-asdf.json'))
47
+
48
+ FakeWeb.register_uri(:get, "http://african.lanl.gov/adore-djatoka/resolver?rft_id=info%3Alanl-repo%2Fds%2Fb820f537-26a1-4af8-b86a-e7a4cac6187a&svc_id=info%3Alanl-repo%2Fsvc%2FgetMetadata&url_ver=Z39.88-2004",
49
+ :response => File.read('test/fixtures/b820f537-26a1-4af8-b86a-e7a4cac6187a.json'))
50
+
51
+ FakeWeb.register_uri(:get, "http://african.lanl.gov/adore-djatoka/resolver?rft_id=info%3Alanl-repo%2Fds%2F5aa182c2-c092-4596-af6e-e95d2e263de3&svc_id=info%3Alanl-repo%2Fsvc%2FgetMetadata&url_ver=Z39.88-2004",
52
+ :response => File.read('test/fixtures/5aa182c2-c092-4596-af6e-e95d2e263de3.json'))
53
+
54
+ FakeWeb.register_uri(:get, "http://african.lanl.gov/adore-djatoka/resolver?url_ver=Z39.88-2004&svc_id=info%3Alanl-repo%2Fsvc%2Fping&rft_id=info%3Alanl-repo%2Fds%2F5aa182c2-c092-4596-af6e-e95d2e263de3",
55
+ :response => File.read('test/fixtures/ping-5aa182c2-c092-4596-af6e-e95d2e263de3.json'))