Skip to content

Commit

Permalink
rename location method to avoid clash with super class definition in …
Browse files Browse the repository at this point in the history
…mods gem
  • Loading branch information
peetucket committed Feb 18, 2016
1 parent 1743ca8 commit 97f6933
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion config/mappings_hash.rb
Expand Up @@ -30,7 +30,7 @@
'physical_description_form' => '//physicalDescription/form/text()', # .to_s
'physical_description_media_type' => '//physicalDescription/internetMediaType/text()', # .to_s

# location
# physical_location
'physical_location' => '//location/physicalLocation/text()', # .to_s
'location_url' => '//location/url/text()', # .to_s

Expand Down
5 changes: 3 additions & 2 deletions lib/stanford-mods/physical_location.rb
Expand Up @@ -47,12 +47,13 @@ def folder
folder_num.first
end

# return entire contents of physicalLocation (note: single valued)
# return entire contents of physicalLocation as a string (note: single valued)
# but only if it has series, accession, box or folder data
# data in location/physicalLocation or in relatedItem/location/physicalLocation
# so use _location to get the data from either one of them
# TODO: should it be hierarchical series/box/folder?
def location
# NOTE: there is a "physicalLocation" and a "location" method defined in the mods gem, so we cannot use these names to avoid conflicts
def physical_location_str
# _location.physicalLocation should find top level and relatedItem
loc = @mods_ng_xml._location.physicalLocation.map do |node|
node.text if node.text.match(/.*(Series)|(Accession)|(Folder)|(Box).*/i)
Expand Down
2 changes: 1 addition & 1 deletion lib/stanford-mods/version.rb
@@ -1,6 +1,6 @@
module Stanford
module Mods
# this is the Ruby Gem version
VERSION = "2.0.0"
VERSION = "2.1.0"
end
end
6 changes: 3 additions & 3 deletions spec/physical_location_spec.rb
Expand Up @@ -179,19 +179,19 @@
context 'in /location/physicalLocation' do
it "has the expected location '#{expected}'" do
@smods_rec.from_str(mods_loc_phys_loc)
expect(@smods_rec.location).to eq expected
expect(@smods_rec.physical_location_str).to eq expected
end
end
context 'in /relatedItem/location/physicalLocation' do
it "has the expected location '#{expected}'" do
@smods_rec.from_str(mods_rel_item_loc_phys_loc)
expect(@smods_rec.location).to eq expected
expect(@smods_rec.physical_location_str).to eq expected
end
end
context 'with multiple physicalLocation elements' do
it "has the expected location '#{expected}'" do
@smods_rec.from_str(mods_loc_multiple_phys_loc)
expect(@smods_rec.location).to eq expected
expect(@smods_rec.physical_location_str).to eq expected
end
end
end # for example
Expand Down

0 comments on commit 97f6933

Please sign in to comment.