Sha256: 3e09ca268600fc2088813c6236bda3049b33e4eb6020b6d0e65366b150f03a77
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
require "nokogiri" require "twitter_cldr" require_relative "parse_contributors" require_relative "parse_extract" module Relaton module Render class Parse def initialize(options) @lang = options[:lang] || "en" @script = options[:script] || "Latn" end def extract(doc) host = host(doc) simple_xml2hash(doc).merge(simple_or_host_xml2hash(doc, host)) .merge(host_xml2hash(host)) .merge(series_xml2hash(doc, host)) end def simple_xml2hash(doc) creators, role = creatornames(doc) { type: type(doc), title: title(doc), extent_raw: extent(doc), size_raw: size(doc), standardidentifier: standardidentifier(doc), uri_raw: uri(doc), status: status(doc), creators: creators, role_raw: role } end def simple_or_host_xml2hash(doc, host) { edition_raw: edition(doc, host), medium_raw: medium(doc, host), place_raw: place(doc, host), publisher_raw: publisher(doc, host), distributor_raw: distributor(doc, host), draft_raw: draft(doc, host), access_location: access_location(doc, host), date: date(doc, host), date_updated: date_updated(doc, host), date_accessed: date_accessed(doc, host) } end def host_xml2hash(host) creators, role = creatornames(host) { host_creators: creators, host_role_raw: role, host_title: title(host) } end def series_xml2hash(doc, host) series = series(doc) host and series ||= series(host) series_xml2hash1(series, doc) end def series_xml2hash1(series, doc) return {} unless series { series_formatted: series_formatted(series, doc), series_title: series_title(series, doc), series_abbr: series_abbr(series, doc), series_run: series_run(series, doc), series_num: series_num(series, doc), series_partnumber: series_partnumber(series, doc) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
relaton-render-0.3.2 | lib/relaton/render/parse/parse.rb |
relaton-render-0.3.1 | lib/relaton/render/parse/parse.rb |