rubyMorphbank 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +28 -9
- data/VERSION +1 -1
- data/lib/request.rb +4 -0
- data/test/test_rubyMorphbank.rb +2 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -1,17 +1,36 @@
|
|
1
1
|
= rubyMorphbank
|
2
2
|
|
3
|
-
|
3
|
+
== Description
|
4
4
|
|
5
|
-
|
5
|
+
rubyMorphbank is a request/response Ruby gem library for the Morphbank (http://morphbank.net) API.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
gem install rubyMorphbank
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
See the tests (test/test_rubyMorphbank.rb) for usage.
|
14
|
+
|
15
|
+
=== Basic pattern
|
16
|
+
|
17
|
+
request = Rmb.new.request
|
18
|
+
response = request.get_response
|
19
|
+
|
20
|
+
=== Return the request URL
|
6
21
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
(
|
13
|
-
|
22
|
+
request = Rmb.new.request
|
23
|
+
request.request_url # => "http://services.morphbank.net/mb3/request?method=search&depth=1&firstResult=0&format=id&keywords=&limit=10&objecttype=Image"
|
24
|
+
|
25
|
+
=== Return a link to a thumbnail in a call for a single image
|
26
|
+
|
27
|
+
foo = Rmb.new.request(:format => 'svc', :id => 195815, :method => 'id')
|
28
|
+
uri = foo.get_response.get_text('thumbUrl')
|
14
29
|
|
15
30
|
== Copyright
|
16
31
|
|
17
32
|
Copyright (c) 2010 mjy. See LICENSE for details.
|
33
|
+
|
34
|
+
== More information
|
35
|
+
|
36
|
+
* The Morphbank Services page is at http://services.morphbank.net/mb3/.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/lib/request.rb
CHANGED
@@ -33,6 +33,10 @@ class Request
|
|
33
33
|
end
|
34
34
|
|
35
35
|
|
36
|
+
# TODO: add some proper sanitation?!
|
37
|
+
opt[:keywords].gsub!(/\s+/, '+') if opt[:keywords].length > 0
|
38
|
+
|
39
|
+
|
36
40
|
# create the request
|
37
41
|
@request_url = SERVICES_URI + "method=#{opt[:method]}" +
|
38
42
|
opt.keys.sort{|a,b| a.to_s <=> b.to_s}.collect{
|
data/test/test_rubyMorphbank.rb
CHANGED
@@ -24,7 +24,7 @@ class TestRequest < Test::Unit::TestCase
|
|
24
24
|
should "return a properly formatted request url with no options" do
|
25
25
|
@rmb = Rmb.new
|
26
26
|
assert @request = @rmb.request
|
27
|
-
assert_equal
|
27
|
+
assert_equal "http://services.morphbank.net/mb3/request?method=search&depth=1&firstResult=0&format=id&keywords=&limit=10&objecttype=Image", @request.request_url
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
@@ -77,7 +77,7 @@ class TestResponse < Test::Unit::TestCase
|
|
77
77
|
assert_equal 'Image', @request.get_response.get_text('objecttypes')
|
78
78
|
end
|
79
79
|
|
80
|
-
# return a link to a
|
80
|
+
# return a link to a thumbnail in a call for a single image
|
81
81
|
should "return a URI to a thumb for a single object query" do
|
82
82
|
foo = Rmb.new.request(:format => 'svc', :id => 195815, :method => 'id')
|
83
83
|
assert_equal 'http://images.morphbank.net/?id=195815&imgType=thumb', foo.get_response.get_text('thumbUrl')
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 5
|
9
|
+
version: 0.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- mjy
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-02-01 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|