openurl 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/openurl/context_object.rb +8 -4
- data/test/from_form_vars_test.rb +37 -0
- metadata +31 -23
- checksums.yaml +0 -15
@@ -441,11 +441,15 @@ module OpenURL
|
|
441
441
|
# if we don't have a referent format (most likely because we have a 0.1
|
442
442
|
# OpenURL), try to determine something from the genre. If that doesn't
|
443
443
|
# exist, just call it a journal since most 0.1 OpenURLs would be one,
|
444
|
-
# anyway.
|
445
|
-
|
444
|
+
# anyway. Case insensitive match, because some providers play fast and
|
445
|
+
# loose. (BorrowDirect sends 'Book', which can confuse us otherwise)
|
446
|
+
unless @referent.format
|
446
447
|
fmt = case @referent.metadata['genre']
|
447
|
-
when /article|journal|issue|proceeding|conference|preprint/ then 'journal'
|
448
|
-
when /book|bookitem|report|document/ then 'book'
|
448
|
+
when /article|journal|issue|proceeding|conference|preprint/i then 'journal'
|
449
|
+
when /book|bookitem|report|document/i then 'book'
|
450
|
+
# 'dissertation' is not a real 'genre', but some use it anyway, and should
|
451
|
+
# map to format 'dissertation' which is real.
|
452
|
+
when /dissertation/i then 'dissertation'
|
449
453
|
else 'journal'
|
450
454
|
end
|
451
455
|
@referent.set_format(fmt)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# This test is not complete, most of OpenURL was written without tests,
|
4
|
+
# just adding tests as we fix bugs or change things.
|
5
|
+
|
6
|
+
Encoding.default_external = "UTF-8" if defined? Encoding
|
7
|
+
|
8
|
+
class FromFormVarsTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_basic_0_1_book
|
11
|
+
co = OpenURL::ContextObject.new_from_form_vars("genre" => "book", "title" => "some book", "au" => "some author")
|
12
|
+
|
13
|
+
assert_equal "book", co.referent.format
|
14
|
+
assert_equal "book", co.referent.metadata['genre']
|
15
|
+
assert_equal "some author", co.referent.metadata['au']
|
16
|
+
assert_equal "some book", co.referent.metadata['title']
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_wrong_case_0_1_book
|
20
|
+
co = OpenURL::ContextObject.new_from_form_vars("genre" => "Book", "title" => "some book", "au" => "some author")
|
21
|
+
|
22
|
+
assert_equal "book", co.referent.format
|
23
|
+
assert_equal "Book", co.referent.metadata['genre']
|
24
|
+
assert_equal "some author", co.referent.metadata['au']
|
25
|
+
assert_equal "some book", co.referent.metadata['title']
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_0_1_dissertation
|
29
|
+
co = OpenURL::ContextObject.new_from_form_vars("genre" => "dissertation", "title" => "some book", "au" => "some author")
|
30
|
+
|
31
|
+
assert_equal "dissertation", co.referent.format
|
32
|
+
assert_equal "dissertation", co.referent.metadata['genre']
|
33
|
+
assert_equal "some author", co.referent.metadata['au']
|
34
|
+
assert_equal "some book", co.referent.metadata['title']
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openurl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Jonathan Rochkind
|
@@ -9,11 +10,12 @@ authors:
|
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: marc
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
17
19
|
requirements:
|
18
20
|
- - ! '>='
|
19
21
|
- !ruby/object:Gem::Version
|
@@ -21,6 +23,7 @@ dependencies:
|
|
21
23
|
type: :runtime
|
22
24
|
prerelease: false
|
23
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
24
27
|
requirements:
|
25
28
|
- - ! '>='
|
26
29
|
- !ruby/object:Gem::Version
|
@@ -28,6 +31,7 @@ dependencies:
|
|
28
31
|
- !ruby/object:Gem::Dependency
|
29
32
|
name: ensure_valid_encoding
|
30
33
|
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
31
35
|
requirements:
|
32
36
|
- - ! '>='
|
33
37
|
- !ruby/object:Gem::Version
|
@@ -35,6 +39,7 @@ dependencies:
|
|
35
39
|
type: :runtime
|
36
40
|
prerelease: false
|
37
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
38
43
|
requirements:
|
39
44
|
- - ! '>='
|
40
45
|
- !ruby/object:Gem::Version
|
@@ -48,61 +53,64 @@ extensions: []
|
|
48
53
|
extra_rdoc_files:
|
49
54
|
- README.md
|
50
55
|
files:
|
51
|
-
- lib/openurl.rb
|
56
|
+
- lib/openurl/context_object.rb
|
52
57
|
- lib/openurl/context_object_entity.rb
|
53
58
|
- lib/openurl/metadata_formats/book.rb
|
54
|
-
- lib/openurl/metadata_formats/
|
55
|
-
- lib/openurl/metadata_formats/scholarly_service_type.rb
|
59
|
+
- lib/openurl/metadata_formats/dissertation.rb
|
56
60
|
- lib/openurl/metadata_formats/dublin_core.rb
|
57
|
-
- lib/openurl/metadata_formats/
|
61
|
+
- lib/openurl/metadata_formats/journal.rb
|
58
62
|
- lib/openurl/metadata_formats/marc.rb
|
59
63
|
- lib/openurl/metadata_formats/patent.rb
|
60
|
-
- lib/openurl/metadata_formats/
|
64
|
+
- lib/openurl/metadata_formats/scholarly_common.rb
|
65
|
+
- lib/openurl/metadata_formats/scholarly_service_type.rb
|
61
66
|
- lib/openurl/transport.rb
|
62
|
-
- lib/openurl
|
63
|
-
- test/data/metalib_sap2_post_params.yml
|
64
|
-
- test/data/dc_ctx.xml
|
65
|
-
- test/data/yu.xml
|
66
|
-
- test/data/scholarly_au_ctx.xml
|
67
|
-
- test/data/marc_ctx.xml
|
67
|
+
- lib/openurl.rb
|
68
68
|
- test/context_object_entity_test.rb
|
69
|
-
- test/test.yml
|
70
69
|
- test/context_object_test.rb
|
70
|
+
- test/data/dc_ctx.xml
|
71
|
+
- test/data/marc_ctx.xml
|
72
|
+
- test/data/metalib_sap2_post_params.yml
|
73
|
+
- test/data/scholarly_au_ctx.xml
|
74
|
+
- test/data/yu.xml
|
71
75
|
- test/encoding_test.rb
|
76
|
+
- test/from_form_vars_test.rb
|
72
77
|
- test/scholarly_common_test.rb
|
78
|
+
- test/test.yml
|
73
79
|
- README.md
|
74
80
|
homepage: https://github.com/openurl/openurl
|
75
81
|
licenses: []
|
76
|
-
metadata: {}
|
77
82
|
post_install_message:
|
78
83
|
rdoc_options: []
|
79
84
|
require_paths:
|
80
85
|
- lib
|
81
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
82
88
|
requirements:
|
83
89
|
- - ! '>='
|
84
90
|
- !ruby/object:Gem::Version
|
85
91
|
version: '0'
|
86
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
87
94
|
requirements:
|
88
95
|
- - ! '>='
|
89
96
|
- !ruby/object:Gem::Version
|
90
97
|
version: '0'
|
91
98
|
requirements: []
|
92
99
|
rubyforge_project:
|
93
|
-
rubygems_version:
|
100
|
+
rubygems_version: 1.8.23
|
94
101
|
signing_key:
|
95
|
-
specification_version:
|
102
|
+
specification_version: 3
|
96
103
|
summary: a Ruby library to create, parse and use NISO Z39.88 OpenURLs
|
97
104
|
test_files:
|
98
|
-
- test/data/metalib_sap2_post_params.yml
|
99
|
-
- test/data/dc_ctx.xml
|
100
|
-
- test/data/yu.xml
|
101
|
-
- test/data/scholarly_au_ctx.xml
|
102
|
-
- test/data/marc_ctx.xml
|
103
105
|
- test/context_object_entity_test.rb
|
104
|
-
- test/test.yml
|
105
106
|
- test/context_object_test.rb
|
107
|
+
- test/data/dc_ctx.xml
|
108
|
+
- test/data/marc_ctx.xml
|
109
|
+
- test/data/metalib_sap2_post_params.yml
|
110
|
+
- test/data/scholarly_au_ctx.xml
|
111
|
+
- test/data/yu.xml
|
106
112
|
- test/encoding_test.rb
|
113
|
+
- test/from_form_vars_test.rb
|
107
114
|
- test/scholarly_common_test.rb
|
115
|
+
- test/test.yml
|
108
116
|
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
NWViZjIwOWQ1ODhmMzYzYzc1NTg5ZDI1MDQwODc2Y2FmNGNjMDk4Ng==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YmU1ODM5YTA4NzM1ZDk3MmUxMmJlYjBkZTg2YmQzM2ZhNTJhZTRjYQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
YzVhZDBiNzAwNGYyYThiZGM2NTk0NmU0NWExNjJiYjNhYTRhNmRmNWYxYzFm
|
10
|
-
ZGRjNjdlNjRlOTgwMWY0ODA1ZjFjMjY3MmJlMjRkY2M0NzFkNTZkNDE5ZmEx
|
11
|
-
YjlmYzgwMGMzY2Q0MDFlODI3M2JkOTc2OGQyNTFmMDVmOWM2ZDc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YjRjNDE2MjJmYzI1MDMyNDkyOGM2YzE3MDc5ZjczYTk2ZWMwNTY4YzNiYjc5
|
14
|
-
YWVkMGRmMWUwMTYyNDAwYWM0MWFmMzk2MTU4NTU2YTM2OTJkZTYxYTA4ZWEw
|
15
|
-
YzI2OWRlNzEwNmZkM2UxOTNiZjk2NzQ4MTBkZWEwOTFkYTBkYzI=
|