relaton-bib 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e1acb1bee569016f446bebcaeac0a98d1491d19be9a87dbd072cabec368c1aea
4
- data.tar.gz: 48897d74a02ea1fe1d2578ac8fbe9f6bd89d1f0fb47b19000f75dbc7697caac7
3
+ metadata.gz: a7f6ef2eec280ac48d171fa25bc4c88d2df63692b5736823868f1751af971f3d
4
+ data.tar.gz: 78e4a52cb0e1d1ce66404af62d2e7f79f27634acbf84094a19e0f593affbdb5a
5
5
  SHA512:
6
- metadata.gz: ef1c0e62f60371c2416af0d0436165ba187d95004a2b8e6401b0c56ac98c0a4a4d1a75a4ec44f65bc5c50130e38d453107bbc370c291c23697efb8aae5f1c422
7
- data.tar.gz: 2c7a9ccf203fe180282339700b580b575db35ce712901784b3c0e72005279561ad0e9218202b2d4f1a9ed609fc9118412a1ae9a7919fb913015efae150e2eeb1
6
+ metadata.gz: 226ead0669d2f060d24b541c8e0eab0d9357b0a697b96572aed3b68b539b97d9f2662f76669a7e0167eedd3fcbc1bdf8ff65e3d3135facdb1531619749095cba
7
+ data.tar.gz: 2a333a1a1ba8aa6683a6abc6f97d521c3be510cbaa7455483266e62523764cf6e04de0b909a0109c21c0c1e5aab5fc224140f97b0f2b60c66d55535e5f434c12
@@ -62,9 +62,10 @@ module RelatonBib
62
62
  # @return [String]
63
63
  def to_asciibib(prefix = "", count = 1)
64
64
  pref = prefix.empty? ? prefix : prefix + "."
65
- out = count > 1 ? "#{pref}biblionote::\n" : ""
66
- out + "#{pref}biblionote.type:: #{type}\n" if type
67
- out += super "#{pref}biblionote"
65
+ has_attrs = !(type.nil? || type.empty?)
66
+ out = count > 1 && has_attrs ? "#{pref}biblionote::\n" : ""
67
+ out += "#{pref}biblionote.type:: #{type}\n" if type
68
+ out += super "#{pref}biblionote", 1, has_attrs
68
69
  out
69
70
  end
70
71
  end
@@ -81,8 +81,11 @@ module RelatonBib
81
81
  attr_reader :entity
82
82
 
83
83
  # @param entity [RelatonBib::Person, RelatonBib::Organization]
84
- # @param role [Array<String>]
85
- def initialize(entity:, role: [{ type: "publisher" }])
84
+ # @param role [Array<Hash>]
85
+ def initialize(entity:, role: [])
86
+ if role.empty?
87
+ role << { type: entity.is_a?(Person) ? "author" : "publisher" }
88
+ end
86
89
  @entity = entity
87
90
  @role = role.map { |r| ContributorRole.new(**r) }
88
91
  end
@@ -44,7 +44,8 @@ module RelatonBib
44
44
  # @param prefix [String]
45
45
  # @param count [Integer] number of elements
46
46
  # @return [String]
47
- def to_asciibib(prefix = "", count = 1)
47
+ def to_asciibib(prefix = "", count = 1, has_attrs = false)
48
+ has_attrs ||= !(format.nil? || format.empty?)
48
49
  pref = prefix.empty? ? prefix : prefix + "."
49
50
  # out = count > 1 ? "#{prefix}::\n" : ""
50
51
  out = super
@@ -77,9 +77,13 @@ module RelatonBib
77
77
  # @param prefix [String]
78
78
  # @param count [Integer] number of elements
79
79
  # @return [String]
80
- def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
80
+ def to_asciibib(prefix = "", count = 1, has_attrs = false) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
81
81
  pref = prefix.empty? ? prefix : prefix + "."
82
82
  if content.is_a? String
83
+ unless language&.any? || script&.any? || has_attrs
84
+ return "#{prefix}:: #{content}\n"
85
+ end
86
+
83
87
  out = count > 1 ? "#{prefix}::\n" : ""
84
88
  out += "#{pref}content:: #{content}\n"
85
89
  language&.each { |l| out += "#{pref}language:: #{l}\n" }
@@ -162,7 +162,7 @@ module RelatonBib
162
162
  pref = prefix.empty? ? prefix : prefix + "."
163
163
  out = count > 1 ? "#{pref}title::\n" : ""
164
164
  out += "#{pref}title.type:: #{type}\n" if type
165
- out += title.to_asciibib "#{pref}title"
165
+ out += title.to_asciibib "#{pref}title", 1, !(type.nil? || type.empty?)
166
166
  out
167
167
  end
168
168
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.6.1".freeze
2
+ VERSION = "1.6.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug