Skip to content

Commit

Permalink
fix Place#to_hash function
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew2net committed Sep 20, 2020
1 parent 7cd71fc commit 2965ccd
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/relaton_bib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def parse_date(date) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/Met

# @param array [Array]
# @return [Array<String>, String]
def single_element_array(array) # rubocop:disable Metrics/CyclomaticComplexity
def single_element_array(array) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
if array.size > 1
array.map { |e| e.is_a?(String) ? e : e.to_hash }
else
Expand Down
3 changes: 2 additions & 1 deletion lib/relaton_bib/bibliographic_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ module RelatonBib
# Bibliographic date.
class BibliographicDate
TYPES = %w[published accessed created implemented obsoleted confirmed
updated issued transmitted copied unchanged circulated adapted].freeze
updated issued transmitted copied unchanged circulated adapted
vote-started vote-ended].freeze

# @return [String]
attr_reader :type
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/place.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def to_xml(builder)
# @return [Hash]
def to_hash
if uri || region
hash = { name: name }
hash = { "name" => name }
hash["uri"] = uri if uri
hash["region"] = region if region
hash
Expand Down
2 changes: 1 addition & 1 deletion lib/relaton_bib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RelatonBib
VERSION = "1.4.0".freeze
VERSION = "1.4.1".freeze
end
6 changes: 4 additions & 2 deletions lib/relaton_bib/xml_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def stage(elm)
abbreviation: elm[:abbreviation])
end

def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
# @param node [Nokogiri::XML::Elemen]
# @return [Array<RelatonBib::BibliographicDate>]
def fetch_dates(item) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
item.xpath("./date").reduce([]) do |a, d|
type = d[:type].to_s.empty? ? "published" : d[:type]
if (on = d.at("on"))
Expand All @@ -229,7 +231,7 @@ def get_org(org) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
identifier: identifier)
end

def get_person(person) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
def get_person(person) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
affiliations = person.xpath("./affiliation").map do |a|
org = a.at "./organization"
desc = a.xpath("./description").map do |e|
Expand Down
2 changes: 1 addition & 1 deletion spec/examples/hash.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ medium:
scale: medium scale
place:
- bib place
- :name: Geneva
- name: Geneva
uri: geneva.place
region: Switzelznd
extent:
Expand Down

0 comments on commit 2965ccd

Please sign in to comment.