lib/stanford-mods/searchworks.rb in stanford-mods-0.0.11 vs lib/stanford-mods/searchworks.rb in stanford-mods-0.0.12
- old
+ new
@@ -28,11 +28,14 @@
# TODO: this should be written to a logger
p "Couldn't find english name for #{ct.text}"
result << SEARCHWORKS_LANGUAGES[v.strip]
end
else
- result << SEARCHWORKS_LANGUAGES[v.strip]
+ vals = ct.text.split(/[,|\ ]/).reject {|x| x.strip.length == 0 }
+ vals.each do |v|
+ result << SEARCHWORKS_LANGUAGES[v.strip]
+ end
end
}
# add languageTerm text values
n.text_term.each { |tt|
val = tt.text.strip
@@ -71,21 +74,23 @@
@mods_ng_xml.plain_name.select {|n| n.type_at != 'personal'}.map { |n| n.display_value_w_date }
end
# @return [Array<String>] values for author_corp_display
def sw_corporate_authors
- @mods_ng_xml.plain_name.select {|n| n.type_at == 'corporate'}.map { |n| n.display_value_w_date }
+ val=@mods_ng_xml.plain_name.select {|n| n.type_at == 'corporate'}.map { |n| n.display_value_w_date }
+ puts val.to_s
+ val
end
# @return [Array<String>] values for author_meeting_display
def sw_meeting_authors
@mods_ng_xml.plain_name.select {|n| n.type_at == 'conference'}.map { |n| n.display_value_w_date }
end
# Returns a sortable version of the main_author:
- # main_author + sorting title
- # which is the mods approximation of the value created for a marc record
+ # main_author + sorting title
+ # which is the mods approximation of the value created for a marc record
# @return [String] value for author_sort field
def sw_sort_author
# substitute java Character.MAX_CODE_POINT for nil main_author so missing main authors sort last
val = '' + (main_author_w_date ? main_author_w_date : "\u{FFFF} ") + ( sort_title ? sort_title : '')
val.gsub(/[[:punct:]]*/, '').strip
@@ -98,10 +103,14 @@
short_titles ? short_titles.first : nil
end
# @return [String] value for title_245_search, title_display, title_full_display
def sw_full_title
- full_titles ? full_titles.find { |s| s =~ Regexp.new(Regexp.escape(sw_short_title)) } : nil
+ toret = full_titles ? full_titles.find { |s| s =~ Regexp.new(Regexp.escape(sw_short_title)) } : nil
+ if toret
+ toret = toret.gsub(/,$/, '')
+ end
+ toret
end
# this includes all titles except
# @return [Array<String>] values for title_variant_search
def sw_addl_titles