iso-bib-item 0.2.2 → 0.2.3

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
- SHA1:
3
- metadata.gz: 2143e8c3463e1f4ffedd26c995e761ed9eebdcea
4
- data.tar.gz: 3b9373cbf1dfaf0d50e9b4dae3a8b2749f430865
2
+ SHA256:
3
+ metadata.gz: d9cb5e4bea651968a0d44b55b2b5f0de83a5a57160aa9ce3edc3a3e900aa55e1
4
+ data.tar.gz: 7391ff666d1d2a31b9540c4184670f116c9a3b403ba820806317f79b66c82c6e
5
5
  SHA512:
6
- metadata.gz: d68733b283b9d6e441e64092ffcb613dd4754da01a25ea12f30badd4aa06fbc66785effa10b0e0f5aed369aada52831e50f3b1a94b4a7dffdb74a35c1e2d58d7
7
- data.tar.gz: '097dc1d5b306e8afb8d08708894b7c5af6fcd2a1adf4530977ed26209a9d68e6e163dcba0c84143a8932b230866faf5ec3d0dec4cc71043313b3eb58039701b4'
6
+ metadata.gz: 20ca6ca1ce0d1e447adc25c8510224f4a6c0f06436c955c206df5c4e1f66c90e383c82f56339b58391e9297e9805fe2c2f68dc9ab0be646a4887e3f02e34cbfa
7
+ data.tar.gz: d8525c1e17e9fed3743e00e1ad119248de90b55280e8d720186dc7a1df0619e340926010bc3ba40fd6ac97fe0293e327193a7fad6def8d8fe995f885b392fd0e
@@ -30,7 +30,8 @@ module IsoBibItem
30
30
  return unless did
31
31
  id = did.text.match(/(?<project>\d+)(?<hyphen>-)?(?(<hyphen>)(?<part>\d*))/)
32
32
  IsoBibItem::IsoDocumentId.new project_number: id[:project],
33
- part_number: id[:part]
33
+ part_number: id[:part],
34
+ prefix: nil
34
35
  end
35
36
 
36
37
  def fetch_titles(doc)
@@ -29,11 +29,15 @@ module IsoBibItem
29
29
  # @return [Integer]
30
30
  attr_reader :part_number
31
31
 
32
+ # @return [Prefix]
33
+ attr_reader :prefix
34
+
32
35
  # @param project_number [Integer]
33
36
  # @param part_number [Integer]
34
- def initialize(project_number:, part_number:)
37
+ def initialize(project_number:, part_number:, prefix:)
35
38
  @project_number = project_number
36
39
  @part_number = part_number
40
+ @prefix = prefix
37
41
  end
38
42
 
39
43
  def remove_part
@@ -100,7 +104,7 @@ module IsoBibItem
100
104
  # @return [Array<IsoBibItem::Ics>]
101
105
  attr_reader :ics
102
106
 
103
- # @param docid [Hash{project_number=>Integer, part_number=>Integer},
107
+ # @param docid [Hash{project_number=>Integer, part_number=>Integer, prefix=>string},
104
108
  # IsoBibItem::IsoDocumentId]
105
109
  # @param titles [Array<Hash{title_intro=>String, title_main=>String,
106
110
  # title_part=>String, language=>String, script=>String}>]
@@ -39,13 +39,17 @@ module IsoBibItem
39
39
  # @return [Array<IsoBibItem::OrgIdentifier>]
40
40
  attr_reader :identifiers
41
41
 
42
+ def hash2locstr(name)
43
+ name.is_a?(Hash) ? LocalizedString.new(name[:content], name[:language], name[:script]) : LocalizedString.new(name)
44
+ end
45
+
42
46
  # @param name [String]
43
47
  # @param abbreviation [String]
44
48
  # @param url [String]
45
49
  # @TODO identifier
46
50
  def initialize(name:, abbreviation: nil, url: nil)
47
51
  super(url: url)
48
- @name = LocalizedString.new name
52
+ @name = name.is_a?(Array) ? name.map { |n| hash2locstr(n) } : [hash2locstr(name)]
49
53
  @abbreviation = LocalizedString.new abbreviation
50
54
  @identifiers = []
51
55
  end
@@ -53,7 +57,9 @@ module IsoBibItem
53
57
  # @param builder [Nokogiri::XML::Builder]
54
58
  def to_xml(builder)
55
59
  builder.organization do
56
- builder.name { |b| name.to_xml b }
60
+ name.each do |n|
61
+ builder.name { |b| n.to_xml b }
62
+ end
57
63
  builder.abbreviation { |a| abbreviation.to_xml a } if abbreviation&.to_s
58
64
  builder.uri uri.to_s if uri
59
65
  identifiers.each { |identifier| identifier.to_xml builder }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.2.2'.freeze
4
+ VERSION = '0.2.3'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso-bib-item
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-22 00:00:00.000000000 Z
11
+ date: 2018-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.6.12
196
+ rubygems_version: 2.7.6
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: 'IsoBibItem: Ruby ISOXMLDOC impementation.'