relaton-iso-bib 1.7.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +36 -0
- data/.rubocop.yml +1 -1
- data/README.adoc +1 -1
- data/bin/rspec +29 -0
- data/grammars/basicdoc.rng +165 -20
- data/grammars/biblio.rng +5 -6
- data/grammars/isodoc.rng +532 -16
- data/grammars/isostandard.rng +56 -103
- data/grammars/reqt.rng +31 -2
- data/lib/relaton_iso_bib/editorial_group.rb +48 -48
- data/lib/relaton_iso_bib/hash_converter.rb +3 -5
- data/lib/relaton_iso_bib/ics.rb +1 -0
- data/lib/relaton_iso_bib/iso_bibliographic_item.rb +42 -25
- data/lib/relaton_iso_bib/structured_identifier.rb +2 -2
- data/lib/relaton_iso_bib/version.rb +1 -1
- data/lib/relaton_iso_bib/xml_parser.rb +5 -6
- data/lib/relaton_iso_bib.rb +1 -1
- data/relaton_iso_bib.gemspec +5 -5
- metadata +10 -39
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -33
- data/.github/workflows/windows.yml +0 -35
data/lib/relaton_iso_bib/ics.rb
CHANGED
@@ -24,9 +24,11 @@ module RelatonIsoBib
|
|
24
24
|
TYPES = %w[
|
25
25
|
international-standard technical-specification technical-report
|
26
26
|
publicly-available-specification international-workshop-agreement guide
|
27
|
-
amendment technical-corrigendum
|
27
|
+
amendment technical-corrigendum directive
|
28
28
|
].freeze
|
29
29
|
|
30
|
+
SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
|
31
|
+
|
30
32
|
# @return [RelatonIsoBib::StructuredIdentifier]
|
31
33
|
attr_reader :structuredidentifier
|
32
34
|
|
@@ -36,6 +38,9 @@ module RelatonIsoBib
|
|
36
38
|
# @return [String, NilClass]
|
37
39
|
attr_reader :doctype, :stagename
|
38
40
|
|
41
|
+
# @return [Boolean, nil]
|
42
|
+
attr_reader :horizontal
|
43
|
+
|
39
44
|
# @return [RelatonIsoBib::EditorialGroup]
|
40
45
|
attr_reader :editorialgroup
|
41
46
|
|
@@ -62,6 +67,9 @@ module RelatonIsoBib
|
|
62
67
|
# @param classification [RelatonBib::Classification, NilClass]
|
63
68
|
# @param validity [RelatonBib:Validity, NilClass]
|
64
69
|
# @param docid [Array<RelatonBib::DocumentIdentifier>]
|
70
|
+
# @param doctype [String, nil]
|
71
|
+
# @param subdoctype [String, nil]
|
72
|
+
# @param horizontal [Boolean, nil]
|
65
73
|
# @param structuredidentifier [RelatonIsoBib::StructuredIdentifier]
|
66
74
|
# @param stagename [String, NilClass]
|
67
75
|
#
|
@@ -125,26 +133,31 @@ module RelatonIsoBib
|
|
125
133
|
def initialize(**args)
|
126
134
|
check_doctype args[:doctype]
|
127
135
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
136
|
+
arg_names = %i[
|
137
|
+
id title docnumber language script docstatus date abstract contributor
|
138
|
+
edition version relation biblionote series medium place copyright link
|
139
|
+
fetched docid formattedref extent accesslocation classification validity
|
140
|
+
editorialgroup doctype keyword
|
141
|
+
]
|
142
|
+
super_args = args.select { |k| arg_names.include? k }
|
143
|
+
super(**super_args)
|
135
144
|
|
136
145
|
@type = args[:type] || "standard"
|
137
146
|
|
138
147
|
if args[:editorialgroup]
|
139
148
|
@editorialgroup = if args[:editorialgroup].is_a?(Hash)
|
140
|
-
EditorialGroup.new(args[:editorialgroup])
|
149
|
+
EditorialGroup.new(**args[:editorialgroup])
|
141
150
|
else args[:editorialgroup]
|
142
151
|
end
|
143
152
|
end
|
144
153
|
|
154
|
+
if args[:subdoctype] && !SUBDOCTYPES.include?(args[:subdoctype])
|
155
|
+
warn "Invald subdoctype '#{args[:subdoctype]}'. Allowed values are: #{SUBDOCTYPES.join(', ')}"
|
156
|
+
end
|
157
|
+
@subdoctype = args[:subdoctype]
|
145
158
|
@structuredidentifier = args[:structuredidentifier]
|
146
|
-
|
147
|
-
@ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
|
159
|
+
@horizontal = args[:horizontal]
|
160
|
+
@ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(**i) : i }
|
148
161
|
@stagename = args[:stagename]
|
149
162
|
@id_attribute = true
|
150
163
|
end
|
@@ -155,23 +168,17 @@ module RelatonIsoBib
|
|
155
168
|
# @option opts [String] :lang language
|
156
169
|
# @return [String] XML
|
157
170
|
def to_xml(**opts)
|
158
|
-
super
|
159
|
-
if
|
160
|
-
|
161
|
-
block_given?)
|
171
|
+
super(**opts) do |b|
|
172
|
+
if block_given? then yield b
|
173
|
+
elsif opts[:bibdata] && has_ext_attrs?
|
162
174
|
b.ext do
|
163
175
|
b.doctype doctype if doctype
|
164
|
-
b.
|
165
|
-
|
166
|
-
|
167
|
-
committee&.to_xml b
|
168
|
-
else
|
169
|
-
editorialgroup&.to_xml b
|
170
|
-
end
|
176
|
+
b.subdoctype subdoctype if subdoctype
|
177
|
+
b.horizontal horizontal unless horizontal.nil?
|
178
|
+
editorialgroup&.to_xml b
|
171
179
|
ics.each { |i| i.to_xml b }
|
172
180
|
structuredidentifier&.to_xml b
|
173
181
|
b.stagename stagename if stagename
|
174
|
-
yield b if block_given?
|
175
182
|
end
|
176
183
|
end
|
177
184
|
end
|
@@ -183,6 +190,7 @@ module RelatonIsoBib
|
|
183
190
|
# @return [Hash]
|
184
191
|
def to_hash
|
185
192
|
hash = super
|
193
|
+
hash["horizontal"] = horizontal unless horizontal.nil?
|
186
194
|
hash["stagename"] = stagename if stagename
|
187
195
|
hash
|
188
196
|
end
|
@@ -190,7 +198,7 @@ module RelatonIsoBib
|
|
190
198
|
# @param prefix [String]
|
191
199
|
# @return [String]
|
192
200
|
def to_asciibib(prefix = "")
|
193
|
-
pref = prefix.empty? ? prefix : prefix
|
201
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
194
202
|
out = super
|
195
203
|
out += "#{pref}stagename:: #{stagename}\n" if stagename
|
196
204
|
out
|
@@ -202,7 +210,8 @@ module RelatonIsoBib
|
|
202
210
|
# @raise ArgumentError
|
203
211
|
def check_doctype(doctype)
|
204
212
|
if doctype && !self.class::TYPES.include?(doctype)
|
205
|
-
warn "[relaton-iso-bib] invalid doctype: #{doctype}"
|
213
|
+
warn "[relaton-iso-bib] WARNING: invalid doctype: #{doctype}"
|
214
|
+
warn "[relaton-iso-bib] Allowed doctypes are: #{self.class::TYPES.join(', ')}"
|
206
215
|
end
|
207
216
|
end
|
208
217
|
|
@@ -218,5 +227,13 @@ module RelatonIsoBib
|
|
218
227
|
end
|
219
228
|
idstr&.gsub(/:/, "-")&.gsub(/\s/, "")&.strip
|
220
229
|
end
|
230
|
+
|
231
|
+
#
|
232
|
+
# @return [Boolean]
|
233
|
+
#
|
234
|
+
def has_ext_attrs? # rubocop:disable Metrics/CyclomaticComplexity
|
235
|
+
(doctype || !horizontal.nil? || editorialgroup || ics.any? ||
|
236
|
+
structuredidentifier || stagename || horizontal)
|
237
|
+
end
|
221
238
|
end
|
222
239
|
end
|
@@ -31,8 +31,8 @@ module RelatonIsoBib
|
|
31
31
|
|
32
32
|
# in docid manipulations, assume ISO as the default: id-part:year
|
33
33
|
def remove_part
|
34
|
-
@
|
35
|
-
@
|
34
|
+
@part = nil
|
35
|
+
@subpart = nil
|
36
36
|
@project_number = case @type
|
37
37
|
when "Chinese Standard"
|
38
38
|
@project_number.sub(/\.\d+/, "")
|
@@ -13,9 +13,8 @@ module RelatonIsoBib
|
|
13
13
|
ext = isoitem.at "./ext"
|
14
14
|
return data unless ext
|
15
15
|
|
16
|
-
|
17
|
-
data[:
|
18
|
-
data[:structuredidentifier] = fetch_structuredidentifier ext
|
16
|
+
hrzt = ext.at("./horizontal")
|
17
|
+
data[:horizontal] = hrzt.text == "true" if hrzt
|
19
18
|
data[:stagename] = ext.at("./stagename")&.text
|
20
19
|
data
|
21
20
|
end
|
@@ -24,7 +23,7 @@ module RelatonIsoBib
|
|
24
23
|
# @param item_hash [Hash]
|
25
24
|
# @return [RelatonIsoBib::IsoBibliographicItem]
|
26
25
|
def bib_item(item_hash)
|
27
|
-
IsoBibliographicItem.new
|
26
|
+
IsoBibliographicItem.new(**item_hash)
|
28
27
|
end
|
29
28
|
|
30
29
|
# @param ext [Nokogiri::XML::Element]
|
@@ -61,8 +60,8 @@ module RelatonIsoBib
|
|
61
60
|
def iso_subgroup(com)
|
62
61
|
return nil if com.nil?
|
63
62
|
|
64
|
-
|
65
|
-
|
63
|
+
RelatonBib::WorkGroup.new(name: com.text, type: com[:type],
|
64
|
+
number: com[:number]&.to_i)
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
data/lib/relaton_iso_bib.rb
CHANGED
@@ -10,7 +10,7 @@ module RelatonIsoBib
|
|
10
10
|
def self.grammar_hash
|
11
11
|
gem_path = File.expand_path "..", __dir__
|
12
12
|
grammars_path = File.join gem_path, "grammars", "*"
|
13
|
-
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
13
|
+
grammars = Dir[grammars_path].sort.map { |gp| File.read gp, encoding: "UTF-8" }.join
|
14
14
|
Digest::MD5.hexdigest grammars
|
15
15
|
end
|
16
16
|
end
|
data/relaton_iso_bib.gemspec
CHANGED
@@ -24,17 +24,17 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.bindir = "exe"
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
27
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
28
28
|
|
29
|
-
spec.add_development_dependency "debase"
|
29
|
+
# spec.add_development_dependency "debase"
|
30
30
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
31
31
|
spec.add_development_dependency "pry-byebug"
|
32
|
-
spec.add_development_dependency "rake", "~>
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
33
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
34
|
-
spec.add_development_dependency "ruby-debug-ide"
|
34
|
+
# spec.add_development_dependency "ruby-debug-ide"
|
35
35
|
spec.add_development_dependency "ruby-jing"
|
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.
|
39
|
+
spec.add_dependency "relaton-bib", "~> 1.9.0"
|
40
40
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iso-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.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:
|
11
|
+
date: 2021-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: debase
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: equivalent-xml
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +44,14 @@ dependencies:
|
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
47
|
+
version: '13.0'
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
54
|
+
version: '13.0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '3.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: ruby-debug-ide
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: ruby-jing
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +114,14 @@ dependencies:
|
|
142
114
|
requirements:
|
143
115
|
- - "~>"
|
144
116
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
117
|
+
version: 1.9.0
|
146
118
|
type: :runtime
|
147
119
|
prerelease: false
|
148
120
|
version_requirements: !ruby/object:Gem::Requirement
|
149
121
|
requirements:
|
150
122
|
- - "~>"
|
151
123
|
- !ruby/object:Gem::Version
|
152
|
-
version: 1.
|
124
|
+
version: 1.9.0
|
153
125
|
description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
|
154
126
|
email:
|
155
127
|
- open.source@ribose.com
|
@@ -157,9 +129,7 @@ executables: []
|
|
157
129
|
extensions: []
|
158
130
|
extra_rdoc_files: []
|
159
131
|
files:
|
160
|
-
- ".github/workflows/
|
161
|
-
- ".github/workflows/ubuntu.yml"
|
162
|
-
- ".github/workflows/windows.yml"
|
132
|
+
- ".github/workflows/rake.yml"
|
163
133
|
- ".gitignore"
|
164
134
|
- ".rspec"
|
165
135
|
- ".rubocop.yml"
|
@@ -168,6 +138,7 @@ files:
|
|
168
138
|
- README.adoc
|
169
139
|
- Rakefile
|
170
140
|
- bin/console
|
141
|
+
- bin/rspec
|
171
142
|
- bin/setup
|
172
143
|
- grammars/basicdoc.rng
|
173
144
|
- grammars/biblio.rng
|
@@ -196,14 +167,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
167
|
requirements:
|
197
168
|
- - ">="
|
198
169
|
- !ruby/object:Gem::Version
|
199
|
-
version: 2.
|
170
|
+
version: 2.5.0
|
200
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
172
|
requirements:
|
202
173
|
- - ">="
|
203
174
|
- !ruby/object:Gem::Version
|
204
175
|
version: '0'
|
205
176
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
177
|
+
rubygems_version: 3.2.3
|
207
178
|
signing_key:
|
208
179
|
specification_version: 4
|
209
180
|
summary: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
|
data/.github/workflows/macos.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: macos
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test-macos:
|
13
|
-
name: Test on Ruby ${{ matrix.ruby }} macOS
|
14
|
-
runs-on: macos-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@master
|
21
|
-
- name: Use Ruby
|
22
|
-
uses: actions/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
architecture: 'x64'
|
26
|
-
- name: Update gems
|
27
|
-
run: |
|
28
|
-
sudo gem install bundler --force
|
29
|
-
ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
|
30
|
-
ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
|
31
|
-
bundle install --jobs 4 --retry 3
|
32
|
-
- name: Run specs
|
33
|
-
run: |
|
34
|
-
bundle exec rake
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: ubuntu
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test-linux:
|
13
|
-
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@master
|
21
|
-
- name: Use Ruby
|
22
|
-
uses: actions/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
architecture: 'x64'
|
26
|
-
- name: Update gems
|
27
|
-
run: |
|
28
|
-
gem install bundler
|
29
|
-
bundle install --jobs 4 --retry 3
|
30
|
-
- name: Run specs
|
31
|
-
run: |
|
32
|
-
unset JAVA_TOOL_OPTIONS
|
33
|
-
bundle exec rake
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: windows
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
branches: [ '**' ]
|
10
|
-
|
11
|
-
jobs:
|
12
|
-
test-windows:
|
13
|
-
name: Test on Ruby ${{ matrix.ruby }} Windows
|
14
|
-
runs-on: windows-latest
|
15
|
-
strategy:
|
16
|
-
fail-fast: false
|
17
|
-
matrix:
|
18
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
19
|
-
steps:
|
20
|
-
- uses: actions/checkout@master
|
21
|
-
- name: Use Ruby
|
22
|
-
uses: actions/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
25
|
-
architecture: 'x64'
|
26
|
-
- name: Update gems
|
27
|
-
shell: pwsh
|
28
|
-
run: |
|
29
|
-
gem install bundler
|
30
|
-
bundle config --local path vendor/bundle
|
31
|
-
bundle update
|
32
|
-
bundle install --jobs 4 --retry 3
|
33
|
-
- name: Run specs
|
34
|
-
run: |
|
35
|
-
bundle exec rake
|