lib/rfcbib/scrapper.rb in rfcbib-0.2.2 vs lib/rfcbib/scrapper.rb in rfcbib-0.2.3
- old
+ new
@@ -64,11 +64,11 @@
# @return [Array<Hash{Symbol=>IsoBibItem::Person,Symbol=>Array<String>}>]
def persons
@reference.xpath('//front/author').map do |author|
entity = IsoBibItem::Person.new(
name: full_name(author),
- affilation: [affilation(author)],
+ affiliation: [affiliation(author)],
contacts: contacts(author.at('//address'))
)
{ entity: entity, roles: [contributor_role(author)] }
end
end
@@ -130,11 +130,11 @@
contacts << IsoBibItem::Contact.new(type: type, value: value.text)
end
# @param author [Nokogiri::XML::Document]
# @return [IsoBibItem::Affilation]
- def affilation(author)
+ def affiliation(author)
organization = author.at('//organization')
IsoBibItem::Affilation.new IsoBibItem::Organization.new(
name: organization.text.empty? ? 'IETF' : organization.text,
abbreviation: organization[:abbrev] || 'IETF'
)
@@ -162,18 +162,19 @@
# Extract document identifiers from reference
#
# @return [Array<IsoBibItem::DocumentIdentifier>]
#
def docids(id)
- ret = @reference.xpath('//seriesinfo').map do |si|
+ ret = []
+ ret << IsoBibItem::DocumentIdentifier.new(type: "IETF", id: id)
+ ret = ret + @reference.xpath('//seriesinfo').map do |si|
next unless si[:name] == 'DOI'
IsoBibItem::DocumentIdentifier.new(
id: si[:value],
type: si[:name]
)
end.compact
- ret << IsoBibItem::DocumentIdentifier.new(type: "IETF", id: id)
end
#
# Extract series form reference
#
@@ -184,10 +185,11 @@
next if si[:name] == 'DOI' || si[:stream] || si[:status]
IsoBibItem::Series.new(
title: IsoBibItem::FormattedString.new(
content: si[:name], language: language, script: 'Latn'
),
- number: si[:value]
+ number: si[:value],
+ type: "main"
)
end.compact
end
#