relaton-bib 1.19.2 → 1.19.4

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: b9d25f7a3197e13a268ac65f498dd9122c89bdbcbb270f999773ce77898fb0df
4
- data.tar.gz: ef52d177ebc581ec707f97e34f7af095a4ed97bc99aa9095b58e8bc360bcfca3
3
+ metadata.gz: f30aba03119323515ec5e39d4a257a15a4de1a83148eb6e45f1b21ba63e42e14
4
+ data.tar.gz: e2588577b331caa08e3396689fa76af66770961e5e76809765a4af3733eb41f5
5
5
  SHA512:
6
- metadata.gz: 9c4b66e2a97ef5dc7e4ada16c2e49bb3d9d0e30bfc1c00565451cfa90124475c2134dd1adfef17f71eec091ef338e781472d9ea72c602dff125c8e79dbe4047a
7
- data.tar.gz: 16e83196283dc4cdf84282786ea72c2649cfdb1dbfe2e49c0f5dcb2511fc74f43d5455188b44fdb06d3497ae8bd01dc9892e2b3586b715c37e44d422e89288a9
6
+ metadata.gz: b20b0ad0f1677bb3ef51adadd220d37fb3a22d8791f20f8f442c0b9cf7235fd933d833f9a8958f911b577f096c2b350c94c0c3748543df078ac8ab7485686e29
7
+ data.tar.gz: 88fa4fdaf09a61417e022a6893d8d998247b49aad4454ad3b4182991b80a41e0cb0e911e01d1fb74463d1418499d3d97c99b2c2893759af9cbf79b0c58130197
@@ -1,32 +1,29 @@
1
1
  module RelatonBib
2
2
  class Image
3
3
  # @return [String]
4
- attr_reader :id, :src, :mimetype, :filename, :width, :height, :alt, :title, :longdesc
4
+ attr_accessor :src, :mimetype
5
+
6
+ # @return [String, nil]
7
+ attr_accessor :id, :filename, :width, :height, :alt, :title, :longdesc
5
8
 
6
9
  #
7
10
  # Initializes a new Image object.
8
11
  #
9
- # @param id [String] the ID of the image
10
12
  # @param src [String] the source URL of the image
11
13
  # @param mimetype [String] the MIME type of the image
12
14
  # @param args [Hash] additional arguments
13
- # @option args [String] :filename the filename of the image
14
- # @option args [String] :width the width of the image
15
- # @option args [String] :height the height of the image
16
- # @option args [String] :alt the alternative text for the image
17
- # @option args [String] :title the title of the image
18
- # @option args [String] :longdesc the long description of the image
15
+ # @option id [String, nil] the ID of the image
16
+ # @option args [String, nil] :filename the filename of the image
17
+ # @option args [String, nil] :width the width of the image
18
+ # @option args [String, nil] :height the height of the image
19
+ # @option args [String, nil] :alt the alternative text for the image
20
+ # @option args [String, nil] :title the title of the image
21
+ # @option args [String, nil] :longdesc the long description of the image
19
22
  #
20
- def initialize(id:, src:, mimetype:, **args)
21
- @id = id
23
+ def initialize(src:, mimetype:, **args)
22
24
  @src = src
23
25
  @mimetype = mimetype
24
- @filename = args[:filename]
25
- @width = args[:width]
26
- @height = args[:height]
27
- @alt = args[:alt]
28
- @title = args[:title]
29
- @longdesc = args[:longdesc]
26
+ args.each { |k, v| send "#{k}=", v }
30
27
  end
31
28
 
32
29
  def ==(other)
@@ -44,7 +41,7 @@ module RelatonBib
44
41
  #
45
42
  def to_xml(builder) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
46
43
  builder.image do
47
- builder.parent[:id] = id
44
+ builder.parent[:id] = id if id
48
45
  builder.parent[:src] = src
49
46
  builder.parent[:mimetype] = mimetype
50
47
  builder.parent[:filename] = filename if filename
@@ -62,7 +59,8 @@ module RelatonBib
62
59
  # @return [Hash] The hash representation of the Image object.
63
60
  #
64
61
  def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
65
- hash = { "image" => { "id" => id, "src" => src, "mimetype" => mimetype } }
62
+ hash = { "image" => { "src" => src, "mimetype" => mimetype } }
63
+ hash["image"]["id"] = id if id
66
64
  hash["image"]["filename"] = filename if filename
67
65
  hash["image"]["width"] = width if width
68
66
  hash["image"]["height"] = height if height
@@ -81,7 +79,8 @@ module RelatonBib
81
79
  #
82
80
  def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
83
81
  pref = prefix.empty? ? "image." : "#{prefix}.image."
84
- out = "#{pref}id:: #{id}\n"
82
+ out = ""
83
+ out += "#{pref}id:: #{id}\n" if id
85
84
  out += "#{pref}src:: #{src}\n"
86
85
  out += "#{pref}mimetype:: #{mimetype}\n"
87
86
  out += "#{pref}filename:: #{filename}\n" if filename
@@ -81,7 +81,7 @@ module RelatonBib
81
81
  #
82
82
  # @return [String] encoded content
83
83
  #
84
- def encode(cnt) # rubocop:disable Metrics/MethodLength
84
+ def encode(cnt)
85
85
  escp cnt
86
86
  end
87
87
 
@@ -1,3 +1,3 @@
1
1
  module RelatonBib
2
- VERSION = "1.19.2".freeze
2
+ VERSION = "1.19.4".freeze
3
3
  end
@@ -289,13 +289,17 @@ module RelatonBib
289
289
  # @return [Array<RelatonBib::DocumentIdentifier>]
290
290
  def fetch_docid(item)
291
291
  item.xpath("./docidentifier").map do |id|
292
- did = id.to_h.transform_keys(&:to_sym)
293
- did[:id] = id.text
294
- did[:primary] = id[:primary] == "true" ? true : nil
295
- DocumentIdentifier.new(**did)
292
+ args = id.to_h.transform_keys(&:to_sym)
293
+ args[:id] = id.text
294
+ args[:primary] = id[:primary] == "true" ? true : nil
295
+ create_docid(**args)
296
296
  end
297
297
  end
298
298
 
299
+ def create_docid(**args)
300
+ DocumentIdentifier.new(**args)
301
+ end
302
+
299
303
  # @param item [Nokogiri::XML::Element]
300
304
  # @return [RelatonBib::TypedTitleStringCollection]
301
305
  def fetch_titles(item)
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.19.2
4
+ version: 1.19.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-12 00:00:00.000000000 Z
11
+ date: 2024-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable