relaton-bib 1.13.7 → 1.13.8

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: 493716815449edfed921ea2239b0c066b614211c2722f261bf4f59d5aa094e54
4
- data.tar.gz: 661ad28bf88fcb3e5b27888885696c14385fbb9bfc891f4b20ea91d7e6dba1f1
3
+ metadata.gz: 566350d7e96478f76484698d7b249e2fc7e22a454a3b2e9572d23b4ddac14723
4
+ data.tar.gz: 53be5f2b3ee6967f22e654aae40133cbdba560ad176bbfc4c8c0f5cee541385c
5
5
  SHA512:
6
- metadata.gz: 2e5ef5a5bd17eafad776a09434fb8e7df82ec2ca3b4fc1e59a6e7d722a72e1c1f57ec75a80dfb1c651a7cea71160c04fb1083517169a68ba341bc3f607c8219c
7
- data.tar.gz: 7b556666124417d87dc58709325b4be7970fb4af443686e332376b739edaa8ad0041e0a26145954577a2b1f8674b078a31405ac2447868caa8df06b3eb25158c
6
+ metadata.gz: 0fbbf49b3d1cb2cd5a4e1b423f547cf03d4a9d2c8d9178b15e4089d384e8c42f15de338f9a8991c1cd9fd83e9a2ac1c1783b11b7d1f7fbd30d8b53e7652db077
7
+ data.tar.gz: 011acbf178b30a5b62f9180f229e49ee4c804e75cba490df2802bad897261a6fed9e1d3a40c6cbd78554375de7884c1447afbdc02e48570976f439244edbaedd
@@ -101,6 +101,7 @@ module RelatonBib
101
101
  # @param content [String]
102
102
  # @param language [String]
103
103
  # @param script [String]
104
+ # @param format [String]
104
105
  def initialize(**args) # rubocop:disable Metrics/MethodLength
105
106
  unless args[:title] || args[:content]
106
107
  raise ArgumentError, %{Keyword "title" or "content" should be passed.}
@@ -108,24 +109,35 @@ module RelatonBib
108
109
 
109
110
  @type = args[:type]
110
111
 
111
- if args[:title]
112
- @title = args[:title]
112
+ case args[:title]
113
+ when FormattedString then @title = args[:title]
114
+ when Hash then @title = FormattedString.new(**args[:title])
113
115
  else
114
116
  fsargs = args.select { |k, _v| ARGS.include? k }
115
117
  @title = FormattedString.new(**fsargs)
116
118
  end
117
119
  end
118
120
 
119
- # @param title [String]
120
- # @return [TypedTitleStringCollection]
121
- def self.from_string(title, lang = nil, script = nil)
121
+ #
122
+ # Create TypedTitleStringCollection from string
123
+ #
124
+ # @param title [String] title string
125
+ # @param lang [String, nil] language code Iso639
126
+ # @param script [String, nil] script code Iso15924
127
+ # @param format [String] format text/html, text/plain
128
+ #
129
+ # @return [TypedTitleStringCollection] collection of TypedTitleString
130
+ #
131
+ def self.from_string(title, lang = nil, script = nil, format = "text/plain")
122
132
  types = %w[title-intro title-main title-part]
123
133
  ttls = split_title(title)
124
134
  tts = ttls.map.with_index do |p, i|
125
- new type: types[i], content: p, language: lang, script: script if p
135
+ next unless p
136
+
137
+ new type: types[i], content: p, language: lang, script: script, format: format
126
138
  end.compact
127
139
  tts << new(type: "main", content: ttls.compact.join(" - "),
128
- language: lang, script: script)
140
+ language: lang, script: script, format: format)
129
141
  TypedTitleStringCollection.new tts
130
142
  end
131
143
 
@@ -140,10 +152,10 @@ module RelatonBib
140
152
  end
141
153
 
142
154
  # @param ttls [Array<String>]
143
- # @return [Array<Strin, nil>]
155
+ # @return [Array<String, nil>]
144
156
  def self.intro_or_part(ttls)
145
157
  if /^(Part|Partie) \d+:/.match? ttls[1]
146
- [nil, ttls[0], ttls[1..-1].join(" -- ")]
158
+ [nil, ttls[0], ttls[1..].join(" -- ")]
147
159
  else
148
160
  parts = ttls.slice(2..-1)
149
161
  part = parts.join " -- " if parts.any?
@@ -162,13 +174,6 @@ module RelatonBib
162
174
  th = title.to_hash
163
175
  return th unless type
164
176
 
165
- # hash = { "type" => type }
166
- # if th.is_a? String
167
- # hash["content"] = th
168
- # else
169
- # hash.merge! th
170
- # end
171
- # hash
172
177
  th.merge "type" => type
173
178
  end
174
179
 
@@ -176,7 +181,7 @@ module RelatonBib
176
181
  # @param count [Integer] number of titles
177
182
  # @return [String]
178
183
  def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
179
- pref = prefix.empty? ? prefix : prefix + "."
184
+ pref = prefix.empty? ? prefix : "#{prefix}."
180
185
  out = count > 1 ? "#{pref}title::\n" : ""
181
186
  out += "#{pref}title.type:: #{type}\n" if type
182
187
  out += title.to_asciibib "#{pref}title", 1, !(type.nil? || type.empty?)
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.13.7".freeze
2
+ VERSION = "1.13.8".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.13.7
4
+ version: 1.13.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-20 00:00:00.000000000 Z
11
+ date: 2022-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug