blacklight_marc 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +12 -0
- data/Gemfile +15 -0
- data/README.md +7 -7
- data/Rakefile +67 -0
- data/app/views/catalog/_marc_view.html.erb +32 -0
- data/app/views/catalog/librarian_view.html.erb +10 -0
- data/blacklight_marc.gemspec +4 -2
- data/config/jetty.yml +4 -0
- data/config/locales/blacklight.en.yml +13 -0
- data/config/locales/blacklight.fr.yml +13 -0
- data/config/routes.rb +17 -0
- data/lib/blacklight/solr/document/marc.rb +1 -0
- data/lib/blacklight/solr/document/marc_export.rb +7 -22
- data/lib/blacklight_marc.rb +10 -9
- data/lib/blacklight_marc/catalog.rb +12 -0
- data/lib/blacklight_marc/engine.rb +8 -0
- data/lib/blacklight_marc/railtie.rb +17 -0
- data/lib/blacklight_marc/routes.rb +41 -0
- data/lib/blacklight_marc/version.rb +1 -1
- data/lib/generators/blacklight_marc/marc_generator.rb +17 -21
- data/spec/features/librarian_view_spec.rb +13 -0
- data/spec/integration/solr_document_spec.rb +59 -0
- data/spec/lib/blacklight_solr_document_marc_spec.rb +89 -0
- data/spec/lib/marc_export_spec.rb +743 -0
- data/spec/lib/tasks/solr_marc_task_spec.rb +60 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/test_app_templates/Gemfile.extra +26 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +34 -0
- data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +14 -0
- metadata +77 -12
@@ -6,28 +6,11 @@ module BlacklightMarc
|
|
6
6
|
source_root File.expand_path('../templates', __FILE__)
|
7
7
|
|
8
8
|
desc """
|
9
|
-
1.
|
10
|
-
2. Creates
|
11
|
-
3.
|
12
|
-
4. Injects MARC-specific behaviors into the
|
9
|
+
1. Creates config/SolrMarc/... with settings for SolrMarc
|
10
|
+
2. Creates a CatalogController with some some demo fields for MARC-like data
|
11
|
+
3. Injects MARC-specific behaviors into the SolrDocument
|
12
|
+
4. Injects MARC-specific behaviors into the CatalogController
|
13
13
|
"""
|
14
|
-
|
15
|
-
# Content types used by Marc Document extension, possibly among others.
|
16
|
-
# Registering a unique content type with 'register' (rather than
|
17
|
-
# register_alias) will allow content-negotiation for the format.
|
18
|
-
def add_mime_types
|
19
|
-
puts "Updating Mime Types"
|
20
|
-
insert_into_file "config/initializers/mime_types.rb", :after => "# Be sure to restart your server when you modify this file." do <<EOF
|
21
|
-
Mime::Type.register_alias "text/plain", :refworks_marc_txt
|
22
|
-
Mime::Type.register_alias "text/plain", :openurl_kev
|
23
|
-
Mime::Type.register "application/x-endnote-refer", :endnote
|
24
|
-
Mime::Type.register "application/marc", :marc
|
25
|
-
Mime::Type.register "application/marcxml+xml", :marcxml,
|
26
|
-
["application/x-marc+xml", "application/x-marcxml+xml",
|
27
|
-
"application/marc+xml"]
|
28
|
-
EOF
|
29
|
-
end
|
30
|
-
end
|
31
14
|
|
32
15
|
# Copy all files in templates/config directory to host config
|
33
16
|
def create_configuration_files
|
@@ -57,5 +40,18 @@ EOF
|
|
57
40
|
end
|
58
41
|
end
|
59
42
|
|
43
|
+
# Add MARC behaviors to the catalog controller
|
44
|
+
def inject_blacklight_controller_behavior
|
45
|
+
# prepend_file("app/controllers/application_controller.rb", "require 'blacklight/controller'\n\n")
|
46
|
+
inject_into_class "app/controllers/catalog_controller.rb", "CatalogController", :after => "include Blacklight::Catalog" do
|
47
|
+
" include BlacklightMarc::Catalog\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def inject_blacklight_marc_routes
|
53
|
+
route('BlacklightMarc.add_routes(self)')
|
54
|
+
end
|
55
|
+
|
60
56
|
end
|
61
57
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Librarian view" do
|
4
|
+
it "should show marc fields" do
|
5
|
+
visit catalog_path('2009373513')
|
6
|
+
click_link "Librarian View"
|
7
|
+
expect(page).to have_content "Librarian View"
|
8
|
+
expect(page).to have_content "LEADER 01213nam a22003614a 4500"
|
9
|
+
expect(page).to have_content "100"
|
10
|
+
expect(page).to have_content "Lin, Xingzhi."
|
11
|
+
expect(page).to have_content "6|"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
# WARNING!!!
|
6
|
+
# If you set any values in Blacklight here, you must reset them to the original
|
7
|
+
# values in an after() block so other tests get expected results.
|
8
|
+
# Blacklight is a Singleton for application configuration.
|
9
|
+
|
10
|
+
## TODO: ALL these specs probably really ought to be on the modules
|
11
|
+
# being tested, not on the bare SolrDocument class that has no logic
|
12
|
+
# of it's own, it just includes modules. No? jrochkind 29 Mar 2010
|
13
|
+
|
14
|
+
def get_hash_with_marcxml
|
15
|
+
{'responseHeader'=>{'status'=>0,'QTime'=>0,'params'=>{'q'=>'id:00282214','wt'=>'ruby'}},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'00282214', "marc_display" =>'<record xmlns=\'http://www.loc.gov/MARC21/slim\'><leader>00799cam a2200241 a 4500</leader><controlfield tag=\'001\'> 00282214 </controlfield><controlfield tag=\'003\'>DLC</controlfield><controlfield tag=\'005\'>20090120022042.0</controlfield><controlfield tag=\'008\'>000417s1998 pk 000 0 urdo </controlfield><datafield tag=\'010\' ind1=\' \' ind2=\' \'><subfield code=\'a\'> 00282214 </subfield></datafield><datafield tag=\'025\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>P-U-00282214; 05; 06</subfield></datafield><datafield tag=\'040\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>DLC</subfield><subfield code=\'c\'>DLC</subfield><subfield code=\'d\'>DLC</subfield></datafield><datafield tag=\'041\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>urd</subfield><subfield code=\'h\'>snd</subfield></datafield><datafield tag=\'042\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>lcode</subfield></datafield><datafield tag=\'050\' ind1=\'0\' ind2=\'0\'><subfield code=\'a\'>PK2788.9.A9</subfield><subfield code=\'b\'>F55 1998</subfield></datafield><datafield tag=\'100\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>Ayaz, Shaikh,</subfield><subfield code=\'d\'>1923-1997.</subfield></datafield><datafield tag=\'245\' ind1=\'1\' ind2=\'0\'><subfield code=\'a\'>Fikr-i Ayāz /</subfield><subfield code=\'c\'>murattibīn, Āṣif Farruk̲h̲ī, Shāh Muḥammad Pīrzādah.</subfield></datafield><datafield tag=\'260\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>Karācī :</subfield><subfield code=\'b\'>Dāniyāl,</subfield><subfield code=\'c\'>[1998]</subfield></datafield><datafield tag=\'300\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>375 p. ;</subfield><subfield code=\'c\'>23 cm.</subfield></datafield><datafield tag=\'546\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>In Urdu.</subfield></datafield><datafield tag=\'520\' ind1=\' \' ind2=\' \'><subfield code=\'a\'>Selected poems and articles from the works of renowned Sindhi poet; chiefly translated from Sindhi.</subfield></datafield><datafield tag=\'700\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>Farruk̲h̲ī, Āṣif,</subfield><subfield code=\'d\'>1959-</subfield></datafield><datafield tag=\'700\' ind1=\'1\' ind2=\' \'><subfield code=\'a\'>Pīrzādah, Shāh Muḥammad.</subfield></datafield></record>','timestamp'=>'2009-03-26T18:15:31.074Z','material_type_display'=>['375 p'],'title_display'=>['Fikr-i Ayāz'],'author_display'=>['Farruk̲h̲ī, Āṣif','Pīrzādah, Shāh Muḥammad'],'language_facet'=>['Urdu'],'format'=>['Book'],'published_display'=>['Karācī']}]}}
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_hash_without_marcxml
|
19
|
+
{'responseHeader'=>{'status'=>0,'QTime'=>0,'params'=>{'q'=>'id:00282214','wt'=>'ruby'}},'response'=>{'numFound'=>1,'start'=>0,'docs'=>[{'id'=>'00282214','timestamp'=>'2009-03-26T18:15:31.074Z','material_type_display'=>['375 p'],'title_display'=>['Fikr-i Ayāz'],'author_display'=>['Farruk̲h̲ī, Āṣif','Pīrzādah, Shāh Muḥammad'],'language_facet'=>['Urdu'],'format'=>['Book'],'published_display'=>['Karācī']}]}}
|
20
|
+
end
|
21
|
+
|
22
|
+
describe SolrDocument do
|
23
|
+
|
24
|
+
before(:each) do
|
25
|
+
@hash_with_marcxml = get_hash_with_marcxml['response']['docs'][0]
|
26
|
+
SolrDocument.extension_parameters[:marc_source_field] = :marc_display
|
27
|
+
SolrDocument.extension_parameters[:marc_format_type] = :marcxml
|
28
|
+
|
29
|
+
# rsolr seems to reload SolrDocument from time to time, so we can't
|
30
|
+
# count on the initializer to register the extension, need to re-register
|
31
|
+
# it.
|
32
|
+
SolrDocument.registered_extensions = nil
|
33
|
+
SolrDocument.use_extension( Blacklight::Solr::Document::Marc ) { |document| document.has_key?(:marc_display)}
|
34
|
+
|
35
|
+
@solrdoc = SolrDocument.new(@hash_with_marcxml)
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "ruby marc creation" do
|
40
|
+
|
41
|
+
it "should have a valid to_marc" do
|
42
|
+
@solrdoc = SolrDocument.new(@hash_with_marcxml)
|
43
|
+
|
44
|
+
@solrdoc.should respond_to(:to_marc)
|
45
|
+
@solrdoc.to_marc.should be_kind_of(MARC::Record)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not try to create marc for objects w/out stored marc (marcxml test only at this time)" do
|
49
|
+
# TODO: Create another double object that does not have marc-xml in it and make
|
50
|
+
# sure everything fails gracefully
|
51
|
+
@hash_without_marcxml = get_hash_without_marcxml['response']['docs'][0]
|
52
|
+
@solrdoc_without_marc = SolrDocument.new(@hash_without_marcxml)
|
53
|
+
@solrdoc_without_marc.should_not respond_to(:to_marc)
|
54
|
+
# legacy check
|
55
|
+
# @solrdoc_without_marc.should respond_to(:marc)
|
56
|
+
# @solrdoc_without_marc.marc.should == nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'active_model'
|
4
|
+
|
5
|
+
describe "Blacklight::Solr::Document::Marc" do
|
6
|
+
before(:all) do
|
7
|
+
@mock_class = Class.new do
|
8
|
+
include Blacklight::Solr::Document
|
9
|
+
end
|
10
|
+
@mock_class.use_extension( Blacklight::Solr::Document::Marc )
|
11
|
+
@mock_class.extension_parameters[:marc_source_field] = :marc
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "marc binary mode" do
|
15
|
+
before(:each) do
|
16
|
+
@mock_class.extension_parameters[:marc_format_type] = :marc21
|
17
|
+
end
|
18
|
+
it "should read and parse a marc binary file" do
|
19
|
+
document = @mock_class.new(:marc => sample_marc_binary )
|
20
|
+
document.to_marc.should == marc_from_string(:binary => sample_marc_binary )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "marcxml mode" do
|
25
|
+
before(:each) do
|
26
|
+
@mock_class.extension_parameters[:marc_format_type] = :marcxml
|
27
|
+
end
|
28
|
+
it "should read and parse a marc xml file" do
|
29
|
+
document = @mock_class.new(:marc => sample_marc_xml)
|
30
|
+
document.to_marc.should == marc_from_string(:xml => sample_marc_xml)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should register all its export formats" do
|
35
|
+
document = @mock_class.new
|
36
|
+
Set.new(document.export_formats.keys).should be_superset(Set.new([:marc, :marcxml, :openurl_ctx_kev, :refworks_marc_txt, :endnote, :xml]))
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
def sample_marc_xml
|
42
|
+
"<record>
|
43
|
+
<leader>01182pam a22003014a 4500</leader>
|
44
|
+
<controlfield tag=\"001\">a4802615</controlfield>
|
45
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
46
|
+
<controlfield tag=\"008\">020828s2003 enkaf b 001 0 eng </controlfield>
|
47
|
+
|
48
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
49
|
+
<subfield code=\"a\">Apples :</subfield>
|
50
|
+
<subfield code=\"b\">botany, production, and uses /</subfield>
|
51
|
+
<subfield code=\"c\">edited by D.C. Ferree and I.J. Warrington.</subfield>
|
52
|
+
</datafield>
|
53
|
+
|
54
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
55
|
+
<subfield code=\"a\">Oxon, U.K. ;</subfield>
|
56
|
+
<subfield code=\"a\">Cambridge, MA :</subfield>
|
57
|
+
<subfield code=\"b\">CABI Pub.,</subfield>
|
58
|
+
<subfield code=\"c\">c2003.</subfield>
|
59
|
+
</datafield>
|
60
|
+
|
61
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
62
|
+
<subfield code=\"a\">Ferree, David C.</subfield>
|
63
|
+
<subfield code=\"q\">(David Curtis),</subfield>
|
64
|
+
<subfield code=\"d\">1943-</subfield>
|
65
|
+
</datafield>
|
66
|
+
|
67
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
68
|
+
<subfield code=\"a\">Warrington, I. J.</subfield>
|
69
|
+
<subfield code=\"q\">(Ian J.)</subfield>
|
70
|
+
</datafield>
|
71
|
+
</record>"
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def sample_marc_binary
|
76
|
+
"00386pam a22001094a 4500001000900000003000600009008004100015245008900056260005400145700004500199700003200244\036a4802615\036SIRSI\036020828s2003 enkaf b 001 0 eng \03600\037aApples :\037bbotany, production, and uses /\037cedited by D.C. Ferree and I.J. Warrington.\036 \037aOxon, U.K. ;\037aCambridge, MA :\037bCABI Pub.,\037cc2003.\0361 \037aFerree, David C.\037q(David Curtis),\037d1943-\0361 \037aWarrington, I. J.\037q(Ian J.)\036\035"
|
77
|
+
end
|
78
|
+
def marc_from_string(args = {})
|
79
|
+
if args[:binary]
|
80
|
+
reader = MARC::Reader.new(StringIO.new(args[:binary]))
|
81
|
+
reader.each {|rec| return rec }
|
82
|
+
elsif args[:xml]
|
83
|
+
reader = MARC::XMLReader.new(StringIO.new(args[:xml]))
|
84
|
+
reader.each {|rec| return rec }
|
85
|
+
end
|
86
|
+
return nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
@@ -0,0 +1,743 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
3
|
+
|
4
|
+
def marc_from_xml(string)
|
5
|
+
reader = MARC::XMLReader.new(StringIO.new(string))
|
6
|
+
reader.each {|rec| return rec }
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def standard_citation
|
11
|
+
"<record>
|
12
|
+
<leader>01182pam a22003014a 4500</leader>
|
13
|
+
<controlfield tag=\"001\">a4802615</controlfield>
|
14
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
15
|
+
<controlfield tag=\"008\">020828s2003 enkaf b 001 0 eng </controlfield>
|
16
|
+
|
17
|
+
<datafield tag=\"110\" ind1=\"1\" ind2=\" \">
|
18
|
+
<subfield code=\"a\">Bobs</subfield>
|
19
|
+
<subfield code=\"b\">Your Uncle</subfield>
|
20
|
+
</datafield>
|
21
|
+
|
22
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
23
|
+
<subfield code=\"a\">Apples :</subfield>
|
24
|
+
<subfield code=\"b\">botany, production, and uses /</subfield>
|
25
|
+
<subfield code=\"c\">edited by D.C. Ferree and I.J. Warrington.</subfield>
|
26
|
+
</datafield>
|
27
|
+
|
28
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
29
|
+
<subfield code=\"a\">Oxon, U.K. ;</subfield>
|
30
|
+
<subfield code=\"a\">Cambridge, MA :</subfield>
|
31
|
+
<subfield code=\"b\">CABI Pub.,</subfield>
|
32
|
+
<subfield code=\"c\">c2003.</subfield>
|
33
|
+
</datafield>
|
34
|
+
|
35
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
36
|
+
<subfield code=\"a\">Ferree, David C.</subfield>
|
37
|
+
<subfield code=\"q\">(David Curtis),</subfield>
|
38
|
+
<subfield code=\"d\">1943-</subfield>
|
39
|
+
</datafield>
|
40
|
+
|
41
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
42
|
+
<subfield code=\"a\">Warrington, I. J.</subfield>
|
43
|
+
<subfield code=\"q\">(Ian J.)</subfield>
|
44
|
+
</datafield>
|
45
|
+
</record>"
|
46
|
+
end
|
47
|
+
|
48
|
+
def music_record
|
49
|
+
"<record>
|
50
|
+
<leader>01828cjm a2200409 a 4500</leader>
|
51
|
+
<controlfield tag=\"001\">a4768316</controlfield>
|
52
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
53
|
+
<controlfield tag=\"007\">sd fungnnmmned</controlfield>
|
54
|
+
<controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
|
55
|
+
|
56
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
57
|
+
<subfield code=\"a\">Music for horn</subfield>
|
58
|
+
<subfield code=\"h\">[sound recording] /</subfield>
|
59
|
+
<subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
|
60
|
+
</datafield>
|
61
|
+
|
62
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
63
|
+
<subfield code=\"a\">[United States] :</subfield>
|
64
|
+
<subfield code=\"b\">Harmonia Mundi USA,</subfield>
|
65
|
+
<subfield code=\"c\">p2001.</subfield>
|
66
|
+
</datafield>
|
67
|
+
|
68
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
69
|
+
<subfield code=\"a\">Greer, Lowell.</subfield>
|
70
|
+
</datafield>
|
71
|
+
|
72
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
73
|
+
<subfield code=\"a\">Lubin, Steven.</subfield>
|
74
|
+
</datafield>
|
75
|
+
|
76
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
77
|
+
<subfield code=\"a\">Chase, Stephanie,</subfield>
|
78
|
+
<subfield code=\"d\">1957-</subfield>
|
79
|
+
</datafield>
|
80
|
+
|
81
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
82
|
+
<subfield code=\"a\">Brahms, Johannes,</subfield>
|
83
|
+
<subfield code=\"d\">1833-1897.</subfield>
|
84
|
+
<subfield code=\"t\">Trios,</subfield>
|
85
|
+
<subfield code=\"m\">piano, violin, horn,</subfield>
|
86
|
+
<subfield code=\"n\">op. 40,</subfield>
|
87
|
+
<subfield code=\"r\">E? major.</subfield>
|
88
|
+
</datafield>
|
89
|
+
|
90
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
91
|
+
<subfield code=\"a\">Beethoven, Ludwig van,</subfield>
|
92
|
+
<subfield code=\"d\">1770-1827.</subfield>
|
93
|
+
<subfield code=\"t\">Sonatas,</subfield>
|
94
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
95
|
+
<subfield code=\"n\">op. 17,</subfield>
|
96
|
+
<subfield code=\"r\">F major.</subfield>
|
97
|
+
</datafield>
|
98
|
+
|
99
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
100
|
+
<subfield code=\"a\">Krufft, Nikolaus von,</subfield>
|
101
|
+
<subfield code=\"d\">1779-1818.</subfield>
|
102
|
+
<subfield code=\"t\">Sonata,</subfield>
|
103
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
104
|
+
<subfield code=\"r\">F major.</subfield>
|
105
|
+
</datafield>
|
106
|
+
</record>"
|
107
|
+
end
|
108
|
+
|
109
|
+
def utf8_decomposed_record_xml
|
110
|
+
"<record>
|
111
|
+
<leader>01341nam 2200301 a 450 </leader>
|
112
|
+
<controlfield tag=\"005\">19971120234400.0</controlfield>
|
113
|
+
<controlfield tag=\"008\">890316s1988 caua b 101 0 eng </controlfield>
|
114
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
115
|
+
<subfield code=\"a\">Sharīʻat and ambiguity in South Asian Islam /</subfield>
|
116
|
+
<subfield code=\"c\">edited by Katherine P. Ewing.</subfield>
|
117
|
+
</datafield>
|
118
|
+
</record>"
|
119
|
+
end
|
120
|
+
|
121
|
+
# 1:100,1:700,245a,0:245b,
|
122
|
+
def record1_xml
|
123
|
+
"<record>
|
124
|
+
<leader>01021cam a2200277 a 4500</leader>
|
125
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
126
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
127
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
128
|
+
|
129
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
130
|
+
<subfield code=\"a\">Janetzky, Kurt.</subfield>
|
131
|
+
</datafield>
|
132
|
+
|
133
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
134
|
+
<subfield code=\"a\">The horn /</subfield>
|
135
|
+
<subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
|
136
|
+
</datafield>
|
137
|
+
|
138
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
139
|
+
<subfield code=\"a\">London :</subfield>
|
140
|
+
<subfield code=\"b\">Batsford,</subfield>
|
141
|
+
<subfield code=\"c\">1988.</subfield>
|
142
|
+
</datafield>
|
143
|
+
|
144
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
145
|
+
<subfield code=\"a\">Brüchle, Bernhard.</subfield>
|
146
|
+
</datafield>
|
147
|
+
</record>"
|
148
|
+
end
|
149
|
+
|
150
|
+
# 0:100,0:700,245a,0:245b
|
151
|
+
def record2_xml
|
152
|
+
"<record>
|
153
|
+
<leader>00903nam a2200253 4500</leader>
|
154
|
+
<controlfield tag=\"001\">a543347</controlfield>
|
155
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
156
|
+
<controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
|
157
|
+
|
158
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
159
|
+
<subfield code=\"a\">Final report to the Honorable John J. Gilligan, Governor.</subfield>
|
160
|
+
</datafield>
|
161
|
+
|
162
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
163
|
+
<subfield code=\"a\">[Columbus,</subfield>
|
164
|
+
<subfield code=\"b\">Printed by the State of Ohio, Dept. of Urban Affairs,</subfield>
|
165
|
+
<subfield code=\"c\">1971]</subfield>
|
166
|
+
</datafield>
|
167
|
+
</record>"
|
168
|
+
end
|
169
|
+
|
170
|
+
def year_range_xml
|
171
|
+
"<record>
|
172
|
+
<leader>01021cam a2200277 a 4500</leader>
|
173
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
174
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
175
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
176
|
+
|
177
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
178
|
+
<subfield code=\"a\">Schmoe, Joe</subfield>
|
179
|
+
</datafield>
|
180
|
+
|
181
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
182
|
+
<subfield code=\"a\">Main title /</subfield>
|
183
|
+
<subfield code=\"c\">Subtitle</subfield>
|
184
|
+
</datafield>
|
185
|
+
|
186
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
187
|
+
<subfield code=\"a\">London :</subfield>
|
188
|
+
<subfield code=\"b\">Batsford,</subfield>
|
189
|
+
<subfield code=\"c\">1988-2000</subfield>
|
190
|
+
</datafield>
|
191
|
+
|
192
|
+
</record>"
|
193
|
+
end
|
194
|
+
|
195
|
+
def no_date_xml
|
196
|
+
"<record>
|
197
|
+
<leader>01021cam a2200277 a 4500</leader>
|
198
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
199
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
200
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
201
|
+
|
202
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
203
|
+
<subfield code=\"a\">Schmoe, Joe</subfield>
|
204
|
+
</datafield>
|
205
|
+
|
206
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
207
|
+
<subfield code=\"a\">Main title /</subfield>
|
208
|
+
<subfield code=\"c\">Subtitle</subfield>
|
209
|
+
</datafield>
|
210
|
+
|
211
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
212
|
+
<subfield code=\"a\">London :</subfield>
|
213
|
+
<subfield code=\"b\">Batsford,</subfield>
|
214
|
+
<subfield code=\"c\">n.d.</subfield>
|
215
|
+
</datafield>
|
216
|
+
|
217
|
+
</record>"
|
218
|
+
end
|
219
|
+
|
220
|
+
def section_title_xml
|
221
|
+
"<record>
|
222
|
+
<leader>01021cam a2200277 a 4500</leader>
|
223
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
224
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
225
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
226
|
+
|
227
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
228
|
+
<subfield code=\"a\">Schmoe, Joe</subfield>
|
229
|
+
</datafield>
|
230
|
+
|
231
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
232
|
+
<subfield code=\"a\">Main title /</subfield>
|
233
|
+
<subfield code=\"b\">Subtitle</subfield>
|
234
|
+
<subfield code=\"n\">Number of part.</subfield>
|
235
|
+
<subfield code=\"p\">Name of part.</subfield>
|
236
|
+
</datafield>
|
237
|
+
|
238
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
239
|
+
<subfield code=\"a\">London :</subfield>
|
240
|
+
<subfield code=\"b\">Batsford,</subfield>
|
241
|
+
<subfield code=\"c\">2001</subfield>
|
242
|
+
</datafield>
|
243
|
+
|
244
|
+
</record>"
|
245
|
+
end
|
246
|
+
|
247
|
+
def dissertation_note_xml
|
248
|
+
"<record>
|
249
|
+
<leader>00903nam a2200253 4500</leader>
|
250
|
+
<controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
|
251
|
+
|
252
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
253
|
+
<subfield code=\"a\">Thesis on some subject.</subfield>
|
254
|
+
</datafield>
|
255
|
+
|
256
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
257
|
+
<subfield code=\"c\">2009</subfield>
|
258
|
+
</datafield>
|
259
|
+
|
260
|
+
<datafield tag=\"502\" ind1=\"0\" ind2=\"0\">
|
261
|
+
<subfield code=\"a\">Phd Thesis -- Goodenough College, 2009</subfield>
|
262
|
+
</datafield>
|
263
|
+
</record>"
|
264
|
+
end
|
265
|
+
|
266
|
+
def special_contributor_with_author_xml
|
267
|
+
"<record>
|
268
|
+
<leader>00903nam a2200253 4500</leader>
|
269
|
+
<controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
|
270
|
+
|
271
|
+
<datafield tag=\"100\" ind1=\"0\" ind2=\"0\">
|
272
|
+
<subfield code=\"a\">Doe, John</subfield>
|
273
|
+
</datafield>
|
274
|
+
|
275
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
276
|
+
<subfield code=\"a\">Title of item.</subfield>
|
277
|
+
</datafield>
|
278
|
+
|
279
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
280
|
+
<subfield code=\"a\">Publisher</subfield>
|
281
|
+
<subfield code=\"b\">Place</subfield>
|
282
|
+
<subfield code=\"c\">2009</subfield>
|
283
|
+
</datafield>
|
284
|
+
|
285
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
286
|
+
<subfield code=\"a\">Schmoe, Joe</subfield>
|
287
|
+
<subfield code=\"e\">trl.</subfield>
|
288
|
+
</datafield>
|
289
|
+
|
290
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
291
|
+
<subfield code=\"a\">Schmoe, Bill</subfield>
|
292
|
+
<subfield code=\"4\">edt</subfield>
|
293
|
+
</datafield>
|
294
|
+
|
295
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
296
|
+
<subfield code=\"a\">Schmoe, Susie</subfield>
|
297
|
+
<subfield code=\"e\">com.</subfield>
|
298
|
+
</datafield>
|
299
|
+
|
300
|
+
</record>"
|
301
|
+
end
|
302
|
+
|
303
|
+
def three_authors_xml
|
304
|
+
"<record>
|
305
|
+
<leader>00903nam a2200253 4500</leader>
|
306
|
+
<controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
|
307
|
+
|
308
|
+
<datafield tag=\"100\" ind1=\"0\" ind2=\"0\">
|
309
|
+
<subfield code=\"a\">Doe, John</subfield>
|
310
|
+
</datafield>
|
311
|
+
|
312
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
313
|
+
<subfield code=\"a\">Title of item.</subfield>
|
314
|
+
</datafield>
|
315
|
+
|
316
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
317
|
+
<subfield code=\"a\">Publisher</subfield>
|
318
|
+
<subfield code=\"b\">Place</subfield>
|
319
|
+
<subfield code=\"c\">2009</subfield>
|
320
|
+
</datafield>
|
321
|
+
|
322
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
323
|
+
<subfield code=\"a\">Schmoe, Joe</subfield>
|
324
|
+
</datafield>
|
325
|
+
|
326
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
327
|
+
<subfield code=\"a\">Schmoe, Bill</subfield>
|
328
|
+
</datafield>
|
329
|
+
|
330
|
+
</record>"
|
331
|
+
end
|
332
|
+
|
333
|
+
def special_contributor_no_author_xml
|
334
|
+
"<record>
|
335
|
+
<leader>00903nam a2200253 4500</leader>
|
336
|
+
<controlfield tag=\"008\">730111s1971 ohu b 000 0 eng </controlfield>
|
337
|
+
|
338
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
339
|
+
<subfield code=\"a\">Title of item.</subfield>
|
340
|
+
</datafield>
|
341
|
+
|
342
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
343
|
+
<subfield code=\"a\">Publisher</subfield>
|
344
|
+
<subfield code=\"b\">Place</subfield>
|
345
|
+
<subfield code=\"c\">2009</subfield>
|
346
|
+
</datafield>
|
347
|
+
|
348
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
349
|
+
<subfield code=\"a\">Schmoe, Joe</subfield>
|
350
|
+
<subfield code=\"e\">trl.</subfield>
|
351
|
+
</datafield>
|
352
|
+
|
353
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
354
|
+
<subfield code=\"a\">Schmoe, Bill</subfield>
|
355
|
+
<subfield code=\"4\">edt</subfield>
|
356
|
+
</datafield>
|
357
|
+
|
358
|
+
<datafield tag=\"700\" ind1=\" \" ind2=\" \">
|
359
|
+
<subfield code=\"a\">Schmoe, Susie</subfield>
|
360
|
+
<subfield code=\"e\">com.</subfield>
|
361
|
+
</datafield>
|
362
|
+
|
363
|
+
</record>"
|
364
|
+
end
|
365
|
+
|
366
|
+
# 4+:athors
|
367
|
+
def record3_xml
|
368
|
+
"<record>
|
369
|
+
<leader>01828cjm a2200409 a 4500</leader>
|
370
|
+
<controlfield tag=\"001\">a4768316</controlfield>
|
371
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
372
|
+
<controlfield tag=\"007\">sd fungnnmmned</controlfield>
|
373
|
+
<controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
|
374
|
+
|
375
|
+
<datafield tag=\"245\" ind1=\"0\" ind2=\"0\">
|
376
|
+
<subfield code=\"a\">Music for horn</subfield>
|
377
|
+
<subfield code=\"h\">[sound recording] /</subfield>
|
378
|
+
<subfield code=\"c\">Brahms, Beethoven, von Krufft.</subfield>
|
379
|
+
</datafield>
|
380
|
+
|
381
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
382
|
+
<subfield code=\"a\">[United States] :</subfield>
|
383
|
+
<subfield code=\"b\">Harmonia Mundi USA,</subfield>
|
384
|
+
<subfield code=\"c\">p2001.</subfield>
|
385
|
+
</datafield>
|
386
|
+
|
387
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
388
|
+
<subfield code=\"a\">Greer, Lowell.</subfield>
|
389
|
+
</datafield>
|
390
|
+
|
391
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
392
|
+
<subfield code=\"a\">Lubin, Steven.</subfield>
|
393
|
+
</datafield>
|
394
|
+
|
395
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
396
|
+
<subfield code=\"a\">Chase, Stephanie,</subfield>
|
397
|
+
<subfield code=\"d\">1957-</subfield>
|
398
|
+
</datafield>
|
399
|
+
|
400
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
401
|
+
<subfield code=\"a\">Brahms, Johannes,</subfield>
|
402
|
+
<subfield code=\"d\">1833-1897.</subfield>
|
403
|
+
<subfield code=\"t\">Trios,</subfield>
|
404
|
+
<subfield code=\"m\">piano, violin, horn,</subfield>
|
405
|
+
<subfield code=\"n\">op. 40,</subfield>
|
406
|
+
<subfield code=\"r\">E? major.</subfield>
|
407
|
+
</datafield>
|
408
|
+
|
409
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
410
|
+
<subfield code=\"a\">Beethoven, Ludwig van,</subfield>
|
411
|
+
<subfield code=\"d\">1770-1827.</subfield>
|
412
|
+
<subfield code=\"t\">Sonatas,</subfield>
|
413
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
414
|
+
<subfield code=\"n\">op. 17,</subfield>
|
415
|
+
<subfield code=\"r\">F major.</subfield>
|
416
|
+
</datafield>
|
417
|
+
|
418
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
419
|
+
<subfield code=\"a\">Krufft, Nikolaus von,</subfield>
|
420
|
+
<subfield code=\"d\">1779-1818.</subfield>
|
421
|
+
<subfield code=\"t\">Sonata,</subfield>
|
422
|
+
<subfield code=\"m\">horn, piano,</subfield>
|
423
|
+
<subfield code=\"r\">F major.</subfield>
|
424
|
+
</datafield>
|
425
|
+
|
426
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
427
|
+
<subfield code=\"a\">Doe, John</subfield>
|
428
|
+
</datafield>
|
429
|
+
|
430
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
431
|
+
<subfield code=\"a\">Doe, Jane</subfield>
|
432
|
+
</datafield>
|
433
|
+
|
434
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
435
|
+
<subfield code=\"a\">Smith, John</subfield>
|
436
|
+
</datafield>
|
437
|
+
|
438
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
439
|
+
<subfield code=\"a\">Smith, Jane</subfield>
|
440
|
+
</datafield>
|
441
|
+
|
442
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\"2\">
|
443
|
+
<subfield code=\"a\">Smith, James</subfield>
|
444
|
+
</datafield>
|
445
|
+
</record>"
|
446
|
+
end
|
447
|
+
|
448
|
+
# No elements that can be put into a citation
|
449
|
+
def no_good_data_xml
|
450
|
+
"<record>
|
451
|
+
<leader>01828cjm a2200409 a 4500</leader>
|
452
|
+
<controlfield tag=\"001\">a4768316</controlfield>
|
453
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
454
|
+
<controlfield tag=\"007\">sd fungnnmmned</controlfield>
|
455
|
+
<controlfield tag=\"008\">020117p20011990xxuzz h d</controlfield>
|
456
|
+
|
457
|
+
<datafield tag=\"024\" ind1=\"1\" ind2=\" \">
|
458
|
+
<subfield code=\"a\">713746703721</subfield>
|
459
|
+
</datafield>
|
460
|
+
|
461
|
+
<datafield tag=\"028\" ind1=\"0\" ind2=\"0\">
|
462
|
+
<subfield code=\"a\">HCX 3957037</subfield>
|
463
|
+
<subfield code=\"b\">Harmonia Mundi USA</subfield>
|
464
|
+
</datafield>
|
465
|
+
|
466
|
+
<datafield tag=\"033\" ind1=\"2\" ind2=\"0\">
|
467
|
+
<subfield code=\"a\">19901203</subfield>
|
468
|
+
<subfield code=\"a\">19901206</subfield>
|
469
|
+
</datafield>
|
470
|
+
|
471
|
+
<datafield tag=\"035\" ind1=\" \" ind2=\" \">
|
472
|
+
<subfield code=\"a\">(OCoLC-M)48807235</subfield>
|
473
|
+
</datafield>
|
474
|
+
|
475
|
+
<datafield tag=\"040\" ind1=\" \" ind2=\" \">
|
476
|
+
<subfield code=\"a\">WC4</subfield>
|
477
|
+
<subfield code=\"c\">WC4</subfield>
|
478
|
+
<subfield code=\"d\">CSt</subfield>
|
479
|
+
</datafield>
|
480
|
+
|
481
|
+
<datafield tag=\"041\" ind1=\"0\" ind2=\" \">
|
482
|
+
<subfield code=\"g\">engfre</subfield>
|
483
|
+
</datafield>
|
484
|
+
</record>"
|
485
|
+
end
|
486
|
+
|
487
|
+
# Bad author name
|
488
|
+
def bad_author_xml
|
489
|
+
"<record>
|
490
|
+
<leader>01021cam a2200277 a 4500</leader>
|
491
|
+
<controlfield tag=\"001\">a1711966</controlfield>
|
492
|
+
<controlfield tag=\"003\">SIRSI</controlfield>
|
493
|
+
<controlfield tag=\"008\">890421s1988 enka 001 0 eng d</controlfield>
|
494
|
+
|
495
|
+
<datafield tag=\"100\" ind1=\"1\" ind2=\" \">
|
496
|
+
<subfield code=\"a\"></subfield>
|
497
|
+
</datafield>
|
498
|
+
|
499
|
+
<datafield tag=\"245\" ind1=\"1\" ind2=\"4\">
|
500
|
+
<subfield code=\"a\">The horn /</subfield>
|
501
|
+
<subfield code=\"c\">Kurt Janetzky and Bernhard Bruchle ; translated from the German by James Chater.</subfield>
|
502
|
+
</datafield>
|
503
|
+
|
504
|
+
<datafield tag=\"260\" ind1=\" \" ind2=\" \">
|
505
|
+
<subfield code=\"a\">London :</subfield>
|
506
|
+
<subfield code=\"b\">Batsford,</subfield>
|
507
|
+
<subfield code=\"c\">1988.</subfield>
|
508
|
+
</datafield>
|
509
|
+
|
510
|
+
<datafield tag=\"700\" ind1=\"1\" ind2=\" \">
|
511
|
+
<subfield code=\"a\">Brüchle, Bernhard.</subfield>
|
512
|
+
</datafield>
|
513
|
+
</record>"
|
514
|
+
end
|
515
|
+
|
516
|
+
describe Blacklight::Solr::Document::MarcExport do
|
517
|
+
|
518
|
+
before(:all) do
|
519
|
+
dclass = Class.new do
|
520
|
+
include Blacklight::Solr::Document::MarcExport
|
521
|
+
attr_accessor :to_marc
|
522
|
+
def initialize(marc_xml_str)
|
523
|
+
self.to_marc = marc_from_xml(marc_xml_str)
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
@typical_record = dclass.new( standard_citation )
|
528
|
+
@music_record = dclass.new( music_record )
|
529
|
+
@dissertation_record = dclass.new( dissertation_note_xml )
|
530
|
+
@record_without_245b = dclass.new( record1_xml )
|
531
|
+
@three_authors_record = dclass.new( three_authors_xml )
|
532
|
+
@record_without_authors = dclass.new( record2_xml )
|
533
|
+
@record_with_10plus_authors = dclass.new( record3_xml )
|
534
|
+
@year_range_record = dclass.new( year_range_xml )
|
535
|
+
@no_date_record = dclass.new( no_date_xml )
|
536
|
+
@section_title_record = dclass.new( section_title_xml )
|
537
|
+
@special_contributor_record = dclass.new( special_contributor_with_author_xml )
|
538
|
+
@record_without_citable_data = dclass.new( no_good_data_xml )
|
539
|
+
@record_with_bad_author = dclass.new( bad_author_xml )
|
540
|
+
@special_contributor_no_auth_record = dclass.new( special_contributor_no_author_xml )
|
541
|
+
@record_utf8_decomposed = dclass.new( utf8_decomposed_record_xml )
|
542
|
+
|
543
|
+
end
|
544
|
+
|
545
|
+
describe "export_as_chicago_citation_txt" do
|
546
|
+
it "should handle a typical record correclty" do
|
547
|
+
@typical_record.export_as_chicago_citation_txt.should == "Ferree, David C., and I. J Warrington. <i>Apples: Botany, Production, and Uses.</i> Oxon, U.K.: CABI Pub., 2003."
|
548
|
+
end
|
549
|
+
it "should format a record w/o authors correctly" do
|
550
|
+
@record_without_authors.export_as_chicago_citation_txt.should == "<i>Final Report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs, 1971."
|
551
|
+
end
|
552
|
+
it "should format a citation without a 245b field correctly" do
|
553
|
+
@record_without_245b.export_as_chicago_citation_txt.should == "Janetzky, Kurt., and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988."
|
554
|
+
end
|
555
|
+
it "should format a citation with 4+ authors correctly" do
|
556
|
+
chicago_text = @record_with_10plus_authors.export_as_chicago_citation_txt
|
557
|
+
chicago_text.should == "Greer, Lowell., Steven Lubin, Stephanie Chase, Johannes Brahms, Ludwig van Beethoven, Nikolaus von Krufft, John Doe, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001."
|
558
|
+
chicago_text.should match(/John Doe, et al\./)
|
559
|
+
chicago_text.should_not match(/Jane Doe/)
|
560
|
+
end
|
561
|
+
it "should handle dissertation data correctly" do
|
562
|
+
@dissertation_record.export_as_chicago_citation_txt.should == "<i>Thesis On Some Subject.</i> Phd Thesis -- Goodenough College, 2009."
|
563
|
+
end
|
564
|
+
it "should handle 3 authors correctly" do
|
565
|
+
@three_authors_record.export_as_chicago_citation_txt.should match(/^Doe, John, Joe Schmoe, and Bill Schmoe\./)
|
566
|
+
end
|
567
|
+
it "should handle editors, translators, and compilers correctly" do
|
568
|
+
@special_contributor_record.export_as_chicago_citation_txt.should == "Doe, John <i>Title of Item.</i> Translated by Joe Schmoe. Edited by Bill Schmoe. Compiled by Susie Schmoe. Publisher: Place, 2009."
|
569
|
+
end
|
570
|
+
it "should handle editors, translators, and compilers correctly when there is no author present" do
|
571
|
+
@special_contributor_no_auth_record.export_as_chicago_citation_txt.should == "Schmoe, Joe trans., Bill Schmoe ed., and Susie Schmoe comp. <i>Title of Item.</i> Publisher: Place, 2009."
|
572
|
+
end
|
573
|
+
it "should handle year ranges properly" do
|
574
|
+
@year_range_record.export_as_chicago_citation_txt.should_not match(/2000/)
|
575
|
+
end
|
576
|
+
it "should handle n.d. in the 260$c properly" do
|
577
|
+
@no_date_record.export_as_chicago_citation_txt.should match(/n\.d\.$/)
|
578
|
+
end
|
579
|
+
it "should handle section title appropriately" do
|
580
|
+
@section_title_record.export_as_chicago_citation_txt.should == "Schmoe, Joe <i>Main Title: Subtitle\.<\/i> Number of Part, <i>Name of Part\.<\/i> London: Batsford, 2001."
|
581
|
+
end
|
582
|
+
it "should not fail if there is no citation data" do
|
583
|
+
@record_without_citable_data.export_as_chicago_citation_txt.should == ""
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
describe "export_as_apa_citation_txt" do
|
588
|
+
it "should format a standard citation correctly" do
|
589
|
+
@typical_record.export_as_apa_citation_txt.should == "Ferree, D. C, & Warrington, I. J. (2003). <i>Apples : botany, production, and uses.</i> Oxon, U.K.: CABI Pub."
|
590
|
+
end
|
591
|
+
|
592
|
+
it "should format a citation without a 245b field correctly" do
|
593
|
+
@record_without_245b.export_as_apa_citation_txt.should == "Janetzky, K., & Brüchle, B. (1988). <i>The horn.</i> London: Batsford."
|
594
|
+
end
|
595
|
+
|
596
|
+
it "should format a citation without any authors correctly" do
|
597
|
+
@record_without_authors.export_as_apa_citation_txt.should == "(1971). <i>Final report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs."
|
598
|
+
end
|
599
|
+
|
600
|
+
it "should not fail if there is no citation data" do
|
601
|
+
@record_without_citable_data.export_as_apa_citation_txt.should == ""
|
602
|
+
end
|
603
|
+
|
604
|
+
it "should not bomb with a null pointer if there if author data is empty" do
|
605
|
+
@record_with_bad_author.export_as_apa_citation_txt.should == "Brüchle, B. (1988). <i>The horn.</i> London: Batsford."
|
606
|
+
end
|
607
|
+
|
608
|
+
end
|
609
|
+
|
610
|
+
describe "export_as_mla_citation_txt" do
|
611
|
+
it "should format a standard citation correctly" do
|
612
|
+
@typical_record.export_as_mla_citation_txt.should == "Ferree, David C, and I. J Warrington. <i>Apples : Botany, Production, and Uses.</i> Oxon, U.K.: CABI Pub., 2003."
|
613
|
+
end
|
614
|
+
|
615
|
+
it "should format a citation without a 245b field correctly" do
|
616
|
+
@record_without_245b.export_as_mla_citation_txt.should == "Janetzky, Kurt, and Bernhard Brüchle. <i>The Horn.</i> London: Batsford, 1988."
|
617
|
+
end
|
618
|
+
|
619
|
+
it "should format a citation without any authors correctly" do
|
620
|
+
@record_without_authors.export_as_mla_citation_txt.should == "<i>Final Report to the Honorable John J. Gilligan, Governor.</i> [Columbus: Printed by the State of Ohio, Dept. of Urban Affairs, 1971."
|
621
|
+
end
|
622
|
+
|
623
|
+
it "should format a citation with 4+ authors correctly" do
|
624
|
+
@record_with_10plus_authors.export_as_mla_citation_txt.should == "Greer, Lowell, et al. <i>Music for Horn.</i> [United States]: Harmonia Mundi USA, 2001."
|
625
|
+
end
|
626
|
+
|
627
|
+
it "should not fail if there is no citation data" do
|
628
|
+
@record_without_citable_data.export_as_mla_citation_txt.should == ""
|
629
|
+
end
|
630
|
+
end
|
631
|
+
|
632
|
+
describe "export_as_openurl_ctx_kev" do
|
633
|
+
it "should create the appropriate context object for books" do
|
634
|
+
record = @typical_record.export_as_openurl_ctx_kev('Book')
|
635
|
+
record.should match(/.*mtx%3Abook.*rft.genre=book.*rft.btitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.isbn=/) and
|
636
|
+
record.should_not match(/.*rft.genre=article.*rft.issn=.*/)
|
637
|
+
end
|
638
|
+
it "should create the appropriate context object for journals" do
|
639
|
+
record = @typical_record.export_as_openurl_ctx_kev('Journal')
|
640
|
+
record_journal_other = @typical_record.export_as_openurl_ctx_kev('Journal/Magazine')
|
641
|
+
record.should match(/.*mtx%3Ajournal.*rft.genre=article.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.atitle=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.issn=/) and
|
642
|
+
record_journal_other.should == record and
|
643
|
+
record.should_not match(/.*rft.genre=book.*rft.isbn=.*/)
|
644
|
+
end
|
645
|
+
it "should create the appropriate context object for other content" do
|
646
|
+
record = @typical_record.export_as_openurl_ctx_kev('NotARealFormat')
|
647
|
+
record.should match(/.*mtx%3Adc.*rft.title=Apples\+%3A\+botany%2C\+production%2C\+and\+uses.*rft.creator=.*rft.aucorp=Bobs\+Your\+Uncle.*rft.date=c2003.*rft.place=Oxon%2C\+U.K.*rft.pub=CABI\+Pub.*rft.format=notarealformat/) and
|
648
|
+
record.should_not match(/.*rft.isbn=.*/) and
|
649
|
+
record.should_not match(/.*rft.issn=.*/)
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
describe "export_as_marc binary" do
|
654
|
+
it "should export_as_marc" do
|
655
|
+
@typical_record.export_as_marc.should == @typical_record.to_marc.to_marc
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
describe "export_as_marcxml" do
|
660
|
+
it "should export_as_marcxml" do
|
661
|
+
marc_from_xml(@typical_record.export_as_marcxml).should == marc_from_xml(@typical_record.to_marc.to_xml.to_s)
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
describe "export_as_xml" do
|
666
|
+
it "should export marcxml as xml" do
|
667
|
+
marc_from_xml(@typical_record.export_as_xml).should == marc_from_xml(@typical_record.export_as_marcxml)
|
668
|
+
end
|
669
|
+
end
|
670
|
+
|
671
|
+
describe "export_as_refworks_marc_txt" do
|
672
|
+
it "should export correctly" do
|
673
|
+
@music_record.export_as_refworks_marc_txt.should == "LEADER 01828cjm a2200409 a 4500001 a4768316\n003 SIRSI\n007 sd fungnnmmned\n008 020117p20011990xxuzz h d\n245 00 Music for horn |h[sound recording] / |cBrahms, Beethoven, von Krufft.\n260 [United States] : |bHarmonia Mundi USA, |cp2001.\n700 1 Greer, Lowell.\n700 1 Lubin, Steven.\n700 1 Chase, Stephanie, |d1957-\n700 12 Brahms, Johannes, |d1833-1897. |tTrios, |mpiano, violin, horn, |nop. 40, |rE? major.\n700 12 Beethoven, Ludwig van, |d1770-1827. |tSonatas, |mhorn, piano, |nop. 17, |rF major.\n700 12 Krufft, Nikolaus von, |d1779-1818. |tSonata, |mhorn, piano, |rF major.\n"
|
674
|
+
end
|
675
|
+
describe "for UTF-8 record" do
|
676
|
+
it "should export in Unicode normalized C form" do
|
677
|
+
@utf8_exported = @record_utf8_decomposed.export_as_refworks_marc_txt
|
678
|
+
|
679
|
+
if defined? Unicode
|
680
|
+
@utf8_exported.should_not include("\314\204\312\273") # decomposed
|
681
|
+
@utf8_exported.should include("\304\253\312\273") # C-form normalized
|
682
|
+
end
|
683
|
+
end
|
684
|
+
end
|
685
|
+
end
|
686
|
+
|
687
|
+
describe "export_as_endnote" do
|
688
|
+
it "should export_correctly" do
|
689
|
+
endnote_file = @music_record.export_as_endnote
|
690
|
+
# We have to parse it a bit to check it.
|
691
|
+
endnote_entries = Hash.new {|hash, key| hash[key] = Set.new }
|
692
|
+
endnote_file.each_line do |line|
|
693
|
+
line =~ /\%(..?) (.*)$/
|
694
|
+
endnote_entries[$1] << $2
|
695
|
+
end
|
696
|
+
|
697
|
+
endnote_entries["0"].should == Set.new(["Generic"]) # I have no idea WHY this is correct, it is definitely not legal, but taking from earlier test for render_endnote in applicationhelper, the previous version of this. jrochkind.
|
698
|
+
endnote_entries["D"].should == Set.new(["p2001. "])
|
699
|
+
endnote_entries["C"].should == Set.new(["[United States] : "])
|
700
|
+
endnote_entries["E"].should == Set.new(["Greer, Lowell. ", "Lubin, Steven. ", "Chase, Stephanie, ", "Brahms, Johannes, ", "Beethoven, Ludwig van, ", "Krufft, Nikolaus von, "])
|
701
|
+
endnote_entries["I"].should == Set.new(["Harmonia Mundi USA, "])
|
702
|
+
endnote_entries["T"].should == Set.new(["Music for horn "])
|
703
|
+
|
704
|
+
#nothing extra
|
705
|
+
Set.new(endnote_entries.keys).should == Set.new(["0", "C", "D", "E", "I", "T"])
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
describe "Citation title transformation" do
|
710
|
+
before(:each) do
|
711
|
+
class CitationTitleTest
|
712
|
+
include Blacklight::Solr::Document::MarcExport
|
713
|
+
def transform_title(text)
|
714
|
+
citation_title(text)
|
715
|
+
end
|
716
|
+
end
|
717
|
+
@citation_title = CitationTitleTest.new
|
718
|
+
end
|
719
|
+
it "should tranform a normal title properlly" do
|
720
|
+
@citation_title.transform_title("This is just a test").should == "This Is Just a Test"
|
721
|
+
end
|
722
|
+
it "should not attempt to capatilize words in all-caps (e.g. acronyms)" do
|
723
|
+
@citation_title.transform_title("IBM PC applications").should == "IBM PC Applications"
|
724
|
+
end
|
725
|
+
it "should capitalize a preposition if it is the first word in a title" do
|
726
|
+
@citation_title.transform_title("of mice and men").should == "Of Mice and Men"
|
727
|
+
end
|
728
|
+
it "should handle hyphenated words properly" do
|
729
|
+
@citation_title.transform_title("Testing hyphenated-words and how they get capitalized").should == "Testing Hyphenated-Words and How They Get Capitalized"
|
730
|
+
end
|
731
|
+
it "should handle normal prepositions properly" do
|
732
|
+
@citation_title.transform_title("A little learning is a dangerous thing").should == "A Little Learning Is a Dangerous Thing"
|
733
|
+
@citation_title.transform_title("Four theories concerning the Gospel according to Matthew").should == "Four Theories Concerning the Gospel According to Matthew"
|
734
|
+
@citation_title.transform_title("Tired but happy").should == "Tired but Happy"
|
735
|
+
@citation_title.transform_title("Mnemonics that work are better than rules that do not").should == "Mnemonics That Work Are Better Than Rules That Do Not"
|
736
|
+
@citation_title.transform_title("This is just a test").should == "This Is Just a Test"
|
737
|
+
@citation_title.transform_title("the mind of the Renaissance").should == "The Mind of the Renaissance"
|
738
|
+
@citation_title.transform_title("Are you considering psychoanalysis?").should == "Are You Considering Psychoanalysis?"
|
739
|
+
@citation_title.transform_title("Not without laughter").should == "Not without Laughter"
|
740
|
+
end
|
741
|
+
end
|
742
|
+
|
743
|
+
end
|