Skip to content

Commit

Permalink
import extent & dimensions from LoC. cf. next-l/enju_leaf#1207 & next…
Browse files Browse the repository at this point in the history
  • Loading branch information
masao committed Oct 1, 2016
1 parent d1fabbe commit 8261f80
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/enju_loc/loc_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ def import_record_from_loc( doc )
:statement_of_responsibility => statement_of_responsibility,
:start_page => extent[:start_page],
:end_page => extent[:end_page],
:extent => extent[:extent],
:height => extent[:height],
:dimensions => extent[:dimensions],
:access_address => access_address,
:note => note,
:publication_place => publication_place,
Expand Down Expand Up @@ -254,11 +256,13 @@ def get_mods_extent(doc)
if extent
extent = extent.split(';')
page = extent[0].try(:strip)
value[:extent] = page
if page =~ /(\d+)\s*(p|page)/
value[:start_page] = 1
value[:end_page] = $1.dup.to_i
end
height = extent[1].try(:strip)
value[:dimensions] = height
if height =~ /(\d+)\s*cm/
value[:height] = $1.dup.to_i
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion spec/models/loc_search_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "spec_helper"
require "rails_helper"

describe LocSearch do
fixtures :all
Expand Down Expand Up @@ -163,6 +163,14 @@
expect( m ).to be_valid
expect( m.original_title ).to eq "How to lie with statistics"
end

it "should import extent", vcr: true do
m = LocSearch.import_from_sru_response( "94041789" )
expect(m).to be_valid
expect(m.original_title).to eq "The little boat"
expect(m.extent).to eq "1 v. (unpaged) : col. ill."
expect(m.dimensions).to eq "25 x 29 cm."
end
end

context ".search", :vcr => true do
Expand Down

0 comments on commit 8261f80

Please sign in to comment.