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 +4 -4
- data/lib/relaton_bib/typed_title_string.rb +22 -17
- data/lib/relaton_bib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 566350d7e96478f76484698d7b249e2fc7e22a454a3b2e9572d23b4ddac14723
|
4
|
+
data.tar.gz: 53be5f2b3ee6967f22e654aae40133cbdba560ad176bbfc4c8c0f5cee541385c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
112
|
-
|
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
|
-
#
|
120
|
-
#
|
121
|
-
|
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
|
-
|
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<
|
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
|
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?)
|
data/lib/relaton_bib/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2022-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|