relaton-iso-bib 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b02914af398916111849f7377145375f05ce647e3ff02c6c2ca83013464b4d0
4
- data.tar.gz: b32bddded529b02ae662959a692cf03e6a4df256751da54648fe9aca899845d3
3
+ metadata.gz: f9f99c30bfb243452c65a6d360870fdee10666c5943523fbfb9fa3a4621b74cf
4
+ data.tar.gz: 6b89f2abf535eca4eb2f2228825e4c4e35ee43c837898d549f68abe37859dc92
5
5
  SHA512:
6
- metadata.gz: c5521cd8a693d3ba710aa6a3c1675033682ef390d882603398cdb15f2826182dd7b3bf8e5e00fcdd44f9e13d7b7676ea5aab357e9d76a94e639a4ae4c4179133
7
- data.tar.gz: e92e7afbdead56a076456aba13be52f1484b191736787d3b4c3928daa6e77259ccaba67d6e2af1ebb59b4acf73277b984875c8caf96d3a4fa1a8021a4cade423
6
+ metadata.gz: 7b06406809884e1059d4dbf7e58875bb052e6d9ed1abe1f6ee58036b224f336cc662d6ba7d9ee6359d4216c80ca504803116b1ad848c1fc544d12483b6b790ae
7
+ data.tar.gz: 7f93851f6f71d1d37871b3735aa6033e1c8ea5711d2246258cf91a7161c587f6d16168d4d3111168fce7f29d76ec654f113eaa55477bf3cf5c88ec81fa7e6978
@@ -29,4 +29,5 @@ jobs:
29
29
  bundle install --jobs 4 --retry 3
30
30
  - name: Run specs
31
31
  run: |
32
+ unset JAVA_TOOL_OPTIONS
32
33
  bundle exec rake
@@ -5,6 +5,6 @@
5
5
  inherit_from:
6
6
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
7
7
  AllCops:
8
- TargetRubyVersion: 2.3
8
+ TargetRubyVersion: 2.4
9
9
  Rails:
10
- Enabled: true
10
+ Enabled: false
@@ -33,7 +33,7 @@ module RelatonIsoBib
33
33
  # @option workgroup [Integer] :number
34
34
  #
35
35
  # @param secretariat [String, NilClass]
36
- def initialize(technical_committee:, **args)
36
+ def initialize(technical_committee:, **args) # rubocop:disable Metrics/CyclomaticComplexity
37
37
  @technical_committee = technical_committee.map do |tc|
38
38
  tc.is_a?(Hash) ? IsoSubgroup.new(tc) : tc
39
39
  end
@@ -49,8 +49,9 @@ module RelatonIsoBib
49
49
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
50
50
 
51
51
  # @param builder [Nokogiri::XML::Builder]
52
- def to_xml(builder)
53
- return unless technical_committee || subcommittee || workgroup || secretariat
52
+ def to_xml(builder) # rubocop:disable Metrics/CyclomaticComplexity
53
+ return unless technical_committee || subcommittee || workgroup ||
54
+ secretariat
54
55
 
55
56
  builder.editorialgroup do
56
57
  technical_committee.each do |tc|
@@ -69,12 +70,36 @@ module RelatonIsoBib
69
70
 
70
71
  # @return [Hash]
71
72
  def to_hash
72
- hash = { "technical_committee" => single_element_array(technical_committee) }
73
- hash["subcommittee"] = single_element_array(subcommittee) if subcommittee&.any?
73
+ hash = {
74
+ "technical_committee" => single_element_array(technical_committee),
75
+ }
76
+ if subcommittee&.any?
77
+ hash["subcommittee"] = single_element_array(subcommittee)
78
+ end
74
79
  hash["workgroup"] = single_element_array(workgroup) if workgroup&.any?
75
80
  hash["secretariat"] = secretariat if secretariat
76
81
  hash
77
82
  end
83
+
84
+ # @param prefix [String]
85
+ # @return [String]
86
+ def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
87
+ pref = prefix.empty? ? prefix : prefix + "."
88
+ pref += "editorialgroup"
89
+ out = ""
90
+ technical_committee.each do |tc|
91
+ out += tc.to_asciibib "#{pref}.technical_committee",
92
+ technical_committee.size
93
+ end
94
+ subcommittee.each do |sc|
95
+ out += sc.to_asciibib "#{pref}.subcommittee", subcommittee.size
96
+ end
97
+ workgroup.each do |wg|
98
+ out += wg.to_asciibib "#{pref}.workgroup", workgroup.size
99
+ end
100
+ out += "#{pref}.secretariat:: #{secretariat}\n" if secretariat
101
+ out
102
+ end
78
103
  end
79
104
 
80
105
  # ISO subgroup.
@@ -111,5 +136,15 @@ module RelatonIsoBib
111
136
  hash["number"] = number if number
112
137
  hash
113
138
  end
139
+
140
+ # @param prefix [String]
141
+ # @param count [Integer] number of the elements
142
+ def to_asciibib(prefix, count = 1)
143
+ out = count > 1 ? "#{prefix}::\n" : ""
144
+ out += "#{prefix}.type:: #{type}\n" if type
145
+ out += "#{prefix}.number:: #{number}\n" if number
146
+ out += "#{prefix}.name:: #{name}\n"
147
+ out
148
+ end
114
149
  end
115
150
  end
@@ -7,7 +7,8 @@ module RelatonIsoBib
7
7
  # @param subgroup [Integer, NilClass]
8
8
  def initialize(code = nil, field: nil, group: nil, subgroup: nil)
9
9
  unless code || field
10
- raise ArgumentError, "wrong arguments (should be string or { fieldcode: [String] }"
10
+ raise ArgumentError,
11
+ "wrong arguments (should be string or { fieldcode: [String] }"
11
12
  end
12
13
 
13
14
  field, group, subgroup = code.split "." if code
@@ -28,5 +29,17 @@ module RelatonIsoBib
28
29
  hash["code"] = code if code
29
30
  hash
30
31
  end
32
+
33
+ # @param prefix [String]
34
+ # @param count [Integer] number of ICS
35
+ # @return [String]
36
+ def to_asciibib(prefix = "", count = 1)
37
+ pref = prefix.empty? ? prefix : prefix + "."
38
+ pref += "ics"
39
+ out = count > 1 ? "#{pref}::\n" : ""
40
+ out += "#{pref}.code:: #{code}\n"
41
+ out += "#{pref}.description:: #{description}\n"
42
+ out
43
+ end
31
44
  end
32
45
  end
@@ -3,7 +3,6 @@
3
3
  require "nokogiri"
4
4
  require "isoics"
5
5
  require "relaton_bib"
6
- # require "relaton_iso_bib/typed_title_string"
7
6
  require "relaton_iso_bib/editorial_group"
8
7
  require "relaton_iso_bib/xml_parser"
9
8
  require "relaton_iso_bib/structured_identifier"
@@ -160,11 +159,11 @@ module RelatonIsoBib
160
159
  end
161
160
 
162
161
  # @return [String]
163
- def to_xml(builder = nil, **opts, &block)
162
+ def to_xml(builder = nil, **opts)
164
163
  if opts[:note]&.any?
165
164
  opts.fetch(:note, []).each do |n|
166
165
  @biblionote << RelatonBib::BiblioNote.new(
167
- content: n[:text], type: n[:type], format: "text/plain",
166
+ content: n[:text], type: n[:type], format: "text/plain"
168
167
  )
169
168
  end
170
169
  end
@@ -175,7 +174,7 @@ module RelatonIsoBib
175
174
  b.ext do
176
175
  b.doctype doctype if doctype
177
176
  b.docsubtype docsubtype if respond_to?(:docsubtype) && docsubtype
178
- # GB renders gbcommittee elements istead of an editorialgroup element.
177
+ # GB renders gbcommittee elements istead of an editorialgroup
179
178
  if respond_to? :committee
180
179
  committee&.to_xml b
181
180
  else
@@ -196,12 +195,19 @@ module RelatonIsoBib
196
195
  # @return [Hash]
197
196
  def to_hash
198
197
  hash = super
199
- hash["editorialgroup"] = editorialgroup.to_hash if editorialgroup
200
- hash["ics"] = single_element_array(ics) if ics&.any?
201
198
  hash["stagename"] = stagename if stagename
202
199
  hash
203
200
  end
204
201
 
202
+ # @param prefix [String]
203
+ # @return [String]
204
+ def to_asciibib(prefix = "")
205
+ pref = prefix.empty? ? prefix : prefix + "."
206
+ out = super
207
+ out += "#{pref}stagename:: #{stagename}\n" if stagename
208
+ out
209
+ end
210
+
205
211
  private
206
212
 
207
213
  # @param doctype [String]
@@ -212,7 +218,7 @@ module RelatonIsoBib
212
218
  end
213
219
  end
214
220
 
215
- def makeid(id, attribute, _delim = "")
221
+ def makeid(id, attribute, _delim = "") # rubocop:disable Metrics/CyclomaticComplexity
216
222
  return nil if attribute && !@id_attribute
217
223
 
218
224
  id ||= @docidentifier.reject { |i| i&.type == "DOI" }[0]
@@ -33,11 +33,12 @@ module RelatonIsoBib
33
33
  def remove_part
34
34
  @part_number = nil
35
35
  @subpart_number = nil
36
- case @type
37
- when "Chinese Standard" then @project_number = @project_number.sub(/\.\d+/, "")
38
- else
39
- @project_number = @project_number.sub(/-\d+/, "")
40
- end
36
+ @project_number = case @type
37
+ when "Chinese Standard"
38
+ @project_number.sub(/\.\d+/, "")
39
+ else
40
+ @project_number = @project_number.sub(/-\d+/, "")
41
+ end
41
42
  end
42
43
 
43
44
  def remove_date
@@ -62,7 +63,9 @@ module RelatonIsoBib
62
63
  pn = builder.send "project-number", project_number
63
64
  pn[:part] = part if part
64
65
  pn[:subpart] = subpart if subpart
65
- builder.send "tc-document-number", tc_document_number if tc_document_number
66
+ if tc_document_number
67
+ builder.send "tc-document-number", tc_document_number
68
+ end
66
69
  end
67
70
  xml[:type] = type if type
68
71
  end
@@ -78,6 +81,24 @@ module RelatonIsoBib
78
81
  hash
79
82
  end
80
83
 
84
+ # @param prefix [String]
85
+ # @return [String]
86
+ def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
87
+ pref = prefix.empty? ? prefix : prefix + "."
88
+ pref += "structured_identifier"
89
+ out = ""
90
+ if tc_document_number
91
+ out += "#{pref}.tc_document_number:: #{tc_document_number}\n"
92
+ end
93
+ if project_number
94
+ out += "#{pref}.project_number:: #{project_number}\n"
95
+ end
96
+ out += "#{pref}.part:: #{part}\n" if part
97
+ out += "#{pref}.subpart:: #{subpart}\n" if subpart
98
+ out += "#{pref}.type:: #{type}\n" if type
99
+ out
100
+ end
101
+
81
102
  def presence?
82
103
  true
83
104
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIsoBib
2
- VERSION = "1.2.0".freeze
2
+ VERSION = "1.3.0".freeze
3
3
  end
@@ -56,7 +56,7 @@ module RelatonIsoBib
56
56
  # @TODO Organization doesn't recreated
57
57
  # @param ext [Nokogiri::XML::Element]
58
58
  # @return [RelatonIsoBib::EditorialGroup]
59
- def fetch_editorialgroup(ext)
59
+ def fetch_editorialgroup(ext) # rubocop:disable Metrics/CyclomaticComplexity
60
60
  eg = ext&.at("./editorialgroup")
61
61
  return unless eg
62
62
 
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "simplecov"
37
37
 
38
38
  spec.add_dependency "isoics", "~> 0.1.6"
39
- spec.add_dependency "relaton-bib", "~> 1.2.0"
39
+ spec.add_dependency "relaton-bib", "~> 1.3.0"
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iso-bib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
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-06-26 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: 1.2.0
145
+ version: 1.3.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: 1.2.0
152
+ version: 1.3.0
153
153
  description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
154
154
  email:
155
155
  - open.source@ribose.com