From 206dfa7dbdd72c2d071141887e3329ba3263ecad Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Tue, 17 Dec 2013 10:29:54 -0600 Subject: [PATCH] Updates frbr? to protect against false frbr groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'm not sure what frbrtype = 6 signifies… but it not a valid frbr group so this updates the detection to exclude type 6. There was a note about this in a discussion here: http://www.exlibrisgroup.org/display/PrimoOI/Brief+Search --- lib/exlibris/primo/pnx/frbr.rb | 11 +- test/pnx/frbr_test.rb | 7 ++ test/test_helper.rb | 178 +++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 3 deletions(-) diff --git a/lib/exlibris/primo/pnx/frbr.rb b/lib/exlibris/primo/pnx/frbr.rb index 3424de8..054e61a 100644 --- a/lib/exlibris/primo/pnx/frbr.rb +++ b/lib/exlibris/primo/pnx/frbr.rb @@ -1,15 +1,20 @@ module Exlibris module Primo module Pnx - # + # # Handle frbr records - # + # module Frbr # # Is this a frbr'd record # def frbr? - @frbr ||= (respond_to? :facets_frbrgroupid) + if (respond_to? :facets_frbrgroupid) && (facets_frbrtype != "6") + @frbr = true + else + @frbr = false + end + @frbr end # diff --git a/test/pnx/frbr_test.rb b/test/pnx/frbr_test.rb index a222a6c..adcee7d 100644 --- a/test/pnx/frbr_test.rb +++ b/test/pnx/frbr_test.rb @@ -8,5 +8,12 @@ def test_frbr assert((not record.frbr_id.blank?)) assert_equal "49340863", record.frbr_id end + + def test_invalid_frbr + record = Exlibris::Primo::Record.new(:raw_xml => record_invalid_frbr_xml) + assert_equal false,record.frbr? + assert_nil record.frbr_id + assert(record.frbr_id.blank?) + end end end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb index 03b8c3b..1d5a435 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -559,5 +559,183 @@ def record_xml ""+ "" end + + def record_invalid_frbr_xml + ""+ + ""+ + "000062856"+ + "nyu_aleph"+ + "nyu_aleph000062856"+ + "NYU01"+ + "NYU01000062856"+ + "MARC21"+ + "Aleph"+ + ""+ + ""+ + "book"+ + "Travels with my aunt"+ + "Graham Greene 1904-1991."+ + "Deluxe ed."+ + "New York : Penguin Books"+ + "2004"+ + "xvi, 254 p. ; 22 cm."+ + "$$Cisbn$$V0143039008; $$Cisbn$$V9780143039006"+ + "British -- Foreign countries -- Fiction; Women travelers -- Fiction; Older women -- Fiction; Travelers -- Fiction; Retirees -- Fiction; Aunts -- Fiction; Humorous stories"+ + "eng"+ + "$$Cseries $$VPenguin classics"+ + "nyu_aleph"+ + "$$INYU$$LBOBST$$1Main Collection$$2(PR6013.R44 T7 2004 )$$Sunavailable$$31$$41$$5N$$61$$XNYU50$$YBOBST$$ZMAIN"+ + "nyu_aleph000062856"+ + "NYU"+ + "$$INYU$$Sunavailable"+ + "unavailable"+ + ""+ + ""+ + "$$Topenurl_journal"+ + "$$Taleph_backlink$$DMore bibliographic information"+ + "$$Tamazon_thumb"+ + "$$Tamazon_toc$$DCheck for Amazon Search Inside"+ + "$$Topenurlfull_journal"+ + "$$Taleph_holdings"+ + "$$TpersistentUrl$$DCopy item link"+ + "$$Tamazon_uc$$DCheck Amazon"+ + "$$Tworldcat_isbn$$DCheck other libraries (WorldCat®)"+ + "$$Tsyndetics_excerpt$$DExcerpt from item"+ + ""+ + ""+ + "Graham, Greene 1904-1991."+ + "Greene, Graham, 1904-1991."+ + "Greene, G"+ + "Graham Greene ; introduction by Gloria Emerson."+ + "Greene, Henry Graham, 1904-1991"+ + "Gŭrin, Gŭreŏm, 1904-1991"+ + "Grin, Greham, 1904-1991"+ + "Grīna, Grāhama, 1904-1991"+ + "Grin, Grėm, 1904-1991"+ + "格拉姆・葛林, 1904-1991"+ + "Grīns, Greiems, 1904-1991"+ + "Grīns, G. (Greiems), 1904-1991"+ + "Travels with my aunt /"+ + "British Foreign countries Fiction"+ + "Women travelers Fiction"+ + "Older women Fiction"+ + "Travelers Fiction"+ + "Retirees Fiction"+ + "Aunts Fiction"+ + "Humorous stories"+ + "People, Retired"+ + "Retired persons"+ + "Retired people"+ + "Travelers, Women"+ + "Britishers"+ + "British people"+ + "Britons (British)"+ + "Brits"+ + "Aged women"+ + "Penguin Books,"+ + "\"Graham Greene centennial, 1904-2004\"--Cover."+ + "nyu_aleph"+ + "nyu_aleph000062856"+ + "0143039008"+ + "9780143039006"+ + "9780143"0390069"+ + "book"+ + "2004"+ + "1969"+ + "Penguin classics"+ + "BOBST"+ + "BOBST Main Collection"+ + "nyu_aleph"+ + "NYU"+ + "BOBST"+ + "BOBST Main Collection"+ + "nyu_aleph"+ + "NYU"+ + "PR6013.R44 T7 2004"+ + "PR6013 .R44 T7 2004"+ + "Penguin Books,"+ + ""+ + ""+ + "Travels with my aunt /"+ + "2004"+ + "Greene, Graham, 1904-1991."+ + "2004"+ + ""+ + ""+ + "eng"+ + "2004"+ + "British–Foreign countries–Fiction"+ + "Women travelers–Fiction"+ + "Older women–Fiction"+ + "Travelers–Fiction"+ + "Retirees–Fiction"+ + "Aunts–Fiction"+ + "BOBST"+ + "books"+ + "books"+ + "Greene, G"+ + "Fiction"+ + "Humorous stories"+ + "BOBST"+ + "Main Collection"+ + "P - Language and literature.–English literature"+ + "49340863"+ + "6"+ + ""+ + ""+ + "1"+ + "2004559272"+ + "0143039008;9780143039006"+ + "travelswithmyaunt"+ + "2004"+ + "2004559272"+ + "0143039008;9780143039006"+ + "travelswithmyaunt"+ + "2004"+ + "travels with my aunt"+ + "nyu"+ + "xvi, 254 p. ;"+ + "penguin books"+ + "greene graham 1904 1991"+ + ""+ + ""+ + "1"+ + "$$Kgreene graham 1904 1991$$AA"+ + "$$Kbooktravels with my aunt$$AT"+ + ""+ + ""+ + "NYU"+ + "Physical Item"+ + ""+ + ""+ + "PR6013.R44"+ + ""+ + ""+ + "1"+ + "1"+ + ""+ + ""+ + "Greene"+ + "Graham,"+ + "Greene, Graham, 1904-1991"+ + "Travels with my aunt"+ + "Penguin classics"+ + "2004"+ + "2004."+ + "0143039008"+ + "9780143039006"+ + "book"+ + "book"+ + "BOOK"+ + "Includes bibliographical references (p. xv-xvi)."+ + "New York"+ + "Penguin Books"+ + "56781200"+ + "2004559272"+ + "BOBST"+ + "Physical Item"+ + ""+ + "" + end end