relaton-calconnect 1.6.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/reqt.rng CHANGED
@@ -30,15 +30,34 @@
30
30
  <data type="boolean"/>
31
31
  </attribute>
32
32
  </optional>
33
+ <optional>
34
+ <attribute name="number"/>
35
+ </optional>
33
36
  <optional>
34
37
  <attribute name="subsequence"/>
35
38
  </optional>
39
+ <optional>
40
+ <attribute name="keep-with-next">
41
+ <data type="boolean"/>
42
+ </attribute>
43
+ </optional>
44
+ <optional>
45
+ <attribute name="keep-lines-together">
46
+ <data type="boolean"/>
47
+ </attribute>
48
+ </optional>
36
49
  <attribute name="id">
37
50
  <data type="ID"/>
38
51
  </attribute>
39
52
  <optional>
40
53
  <attribute name="filename"/>
41
54
  </optional>
55
+ <optional>
56
+ <attribute name="model"/>
57
+ </optional>
58
+ <optional>
59
+ <attribute name="type"/>
60
+ </optional>
42
61
  <optional>
43
62
  <ref name="reqtitle"/>
44
63
  </optional>
@@ -48,9 +67,9 @@
48
67
  <optional>
49
68
  <ref name="subject"/>
50
69
  </optional>
51
- <optional>
70
+ <zeroOrMore>
52
71
  <ref name="reqinherit"/>
53
- </optional>
72
+ </zeroOrMore>
54
73
  <zeroOrMore>
55
74
  <ref name="classification"/>
56
75
  </zeroOrMore>
@@ -135,6 +154,16 @@
135
154
  <data type="boolean"/>
136
155
  </attribute>
137
156
  </optional>
157
+ <optional>
158
+ <attribute name="keep-with-next">
159
+ <data type="boolean"/>
160
+ </attribute>
161
+ </optional>
162
+ <optional>
163
+ <attribute name="keep-lines-together">
164
+ <data type="boolean"/>
165
+ </attribute>
166
+ </optional>
138
167
  <oneOrMore>
139
168
  <ref name="BasicBlock"/>
140
169
  </oneOrMore>
@@ -4,5 +4,12 @@ module RelatonCalconnect
4
4
  directive guide specification standard report administrative amendment
5
5
  technical\ corrigendum advisory
6
6
  ].freeze
7
+
8
+ # @param hash [Hash]
9
+ # @return [RelatonIsoBib::CcBibliographicItem]
10
+ def self.from_hash(hash)
11
+ item_hash = ::RelatonCalconnect::HashConverter.hash_to_bib(hash)
12
+ new(**item_hash)
13
+ end
7
14
  end
8
15
  end
@@ -3,7 +3,7 @@ module RelatonCalconnect
3
3
  class << self
4
4
  # @param text [String]
5
5
  # @return [RelatonCalconnect::HitCollection]
6
- def search(text, year = nil, opts = {})
6
+ def search(text, year = nil, _opts = {})
7
7
  HitCollection.new text, year
8
8
  rescue Faraday::ConnectionFailed
9
9
  raise RelatonBib::RequestError, "Could not access https://standards.calconnect.org"
@@ -18,11 +18,11 @@ module RelatonCalconnect
18
18
  # @option opts [TrueClass, FalseClass] :bibdata
19
19
  #
20
20
  # @return [RelatonCalconnect::CcBibliographicItem]
21
- def get(ref, year = nil, opts = {})
21
+ def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
22
22
  code = ref
23
23
 
24
24
  if year.nil?
25
- /^(?<code1>[^\s]+(\s\w+)?\s[\d-]+):?(?<year1>\d{4})?/ =~ ref
25
+ /^(?<code1>[^\s]+(?:\s\w+)?\s[\d-]+):?(?<year1>\d{4})?/ =~ ref
26
26
  unless code1.nil?
27
27
  code = code1
28
28
  year = year1
@@ -30,7 +30,7 @@ module RelatonCalconnect
30
30
  end
31
31
 
32
32
  warn "[relaton-calconnect] (\"#{ref}\") fetching..."
33
- result = bib_search_filter(code, year, opts) || (return nil)
33
+ result = search(code, year, opts) || (return nil)
34
34
  ret = bib_results_filter(result, year)
35
35
  if ret[:ret]
36
36
  warn "[relaton-calconnect] (\"#{ref}\") found #{ret[:ret].docidentifier.first.id}"
@@ -42,10 +42,6 @@ module RelatonCalconnect
42
42
 
43
43
  private
44
44
 
45
- def bib_search_filter(code, year, opts)
46
- search(code, year, opts)
47
- end
48
-
49
45
  # Sort through the results from RelatonNist, fetching them three at a time,
50
46
  # and return the first result that matches the code,
51
47
  # matches the year (if provided), and which # has a title (amendments do not).
@@ -80,8 +76,8 @@ module RelatonCalconnect
80
76
  warn "[relaton-calconnect] WARNING: no match found online for #{id}. "\
81
77
  "The code must be exactly like it is on the standards website."
82
78
  unless missed_years.empty?
83
- warn "[relaton-calconnect] (There was no match for #{year}, though there were matches "\
84
- "found for #{missed_years.join(', ')}.)"
79
+ warn "[relaton-calconnect] (There was no match for #{year}, though "\
80
+ "there were matches found for #{missed_years.join(', ')}.)"
85
81
  end
86
82
  nil
87
83
  end
@@ -1,4 +1,15 @@
1
1
  module RelatonCalconnect
2
2
  class HashConverter < RelatonBib::HashConverter
3
+ class << self
4
+ # @param ret [Hash]
5
+ def editorialgroup_hash_to_bib(ret)
6
+ return unless ret[:editorialgroup]
7
+
8
+ technical_committee = array(ret[:editorialgroup]).map do |wg|
9
+ TechnicalCommittee.new RelatonBib::WorkGroup.new(**wg)
10
+ end
11
+ ret[:editorialgroup] = RelatonBib::EditorialGroup.new technical_committee
12
+ end
13
+ end
3
14
  end
4
15
  end
@@ -23,7 +23,7 @@ module RelatonCalconnect
23
23
  private
24
24
 
25
25
  #
26
- # Fetch data form yaml
26
+ # Fetch data from yaml
27
27
  #
28
28
  # @param docid [String]
29
29
  def from_yaml(docid, **_opts)
@@ -44,7 +44,7 @@ module RelatonCalconnect
44
44
  end
45
45
 
46
46
  #
47
- # fetch data form server and save it to file.
47
+ # fetch data from server and save it to file.
48
48
  #
49
49
  def fetch_data
50
50
  resp = Faraday.new(ENDPOINT, headers: { "If-None-Match" => etag }).get
@@ -57,7 +57,7 @@ module RelatonCalconnect
57
57
  end
58
58
 
59
59
  #
60
- # Read ETag form file
60
+ # Read ETag from file
61
61
  #
62
62
  # @return [String, NilClass]
63
63
  def etag
@@ -28,8 +28,7 @@ module RelatonCalconnect
28
28
  # @param hash [Hash]
29
29
  # @return [RelatonIsoBib::CcBibliographicItem]
30
30
  def hash_to_bib(hash)
31
- item_hash = ::RelatonCalconnect::HashConverter.hash_to_bib(hash)
32
- ::RelatonCalconnect::CcBibliographicItem.new item_hash
31
+ ::RelatonCalconnect::CcBibliographicItem.from_hash hash
33
32
  end
34
33
 
35
34
  # Returns hash of XML grammar
@@ -0,0 +1,8 @@
1
+ module RelatonCalconnect
2
+ class TechnicalCommittee < RelatonBib::TechnicalCommittee
3
+ # @param builder [Nokogiri::XML::Builder]
4
+ def to_xml(builder)
5
+ builder.committee { |b| workgroup.to_xml b }
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonCalconnect
2
- VERSION = "1.6.0".freeze
2
+ VERSION = "1.9.0".freeze
3
3
  end
@@ -5,7 +5,20 @@ module RelatonCalconnect
5
5
  # @param item_hash [Hash]
6
6
  # @return [RelatonIsoBib::IsoBibliographicItem]
7
7
  def bib_item(item_hash)
8
- CcBibliographicItem.new item_hash
8
+ CcBibliographicItem.new(**item_hash)
9
+ end
10
+
11
+ # @param ext [Nokogiri::XML::Element]
12
+ # @return [RelatonBib::EditorialGroup, nil]
13
+ def fetch_editorialgroup(ext)
14
+ return unless ext && (eg = ext.at "editorialgroup")
15
+
16
+ eg = eg.xpath("committee", "technical-committee").map do |tc|
17
+ wg = RelatonBib::WorkGroup.new(name: tc.text, number: tc[:number]&.to_i,
18
+ type: tc[:type])
19
+ TechnicalCommittee.new wg
20
+ end
21
+ RelatonBib::EditorialGroup.new eg if eg.any?
9
22
  end
10
23
  end
11
24
  end
@@ -4,6 +4,7 @@ require "relaton_calconnect/cc_bibliography"
4
4
  require "relaton_calconnect/hit_collection"
5
5
  require "relaton_calconnect/hit"
6
6
  require "relaton_calconnect/scrapper"
7
+ require "relaton_calconnect/technical_committee"
7
8
  require "relaton_calconnect/cc_bibliographic_item"
8
9
  require "relaton_calconnect/xml_parser"
9
10
  require "relaton_calconnect/hash_converter"
@@ -24,18 +24,16 @@ 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.4.0")
27
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
- spec.add_development_dependency "debase"
30
29
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
31
30
  spec.add_development_dependency "rake", "~> 10.0"
32
31
  spec.add_development_dependency "rspec", "~> 3.0"
33
- spec.add_development_dependency "ruby-debug-ide"
34
32
  spec.add_development_dependency "ruby-jing"
35
33
  spec.add_development_dependency "simplecov"
36
34
  spec.add_development_dependency "vcr"
37
35
  spec.add_development_dependency "webmock"
38
36
 
39
37
  spec.add_dependency "faraday"
40
- spec.add_dependency "relaton-bib", "~> 1.6.0"
38
+ spec.add_dependency "relaton-bib", "~> 1.9.0"
41
39
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-calconnect
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
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: 2020-11-13 00:00:00.000000000 Z
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
@@ -66,20 +52,6 @@ dependencies:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: ruby-debug-ide
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: ruby-jing
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +128,14 @@ dependencies:
156
128
  requirements:
157
129
  - - "~>"
158
130
  - !ruby/object:Gem::Version
159
- version: 1.6.0
131
+ version: 1.9.0
160
132
  type: :runtime
161
133
  prerelease: false
162
134
  version_requirements: !ruby/object:Gem::Requirement
163
135
  requirements:
164
136
  - - "~>"
165
137
  - !ruby/object:Gem::Version
166
- version: 1.6.0
138
+ version: 1.9.0
167
139
  description: 'RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem
168
140
  model'
169
141
  email:
@@ -172,9 +144,7 @@ executables: []
172
144
  extensions: []
173
145
  extra_rdoc_files: []
174
146
  files:
175
- - ".github/workflows/macos.yml"
176
- - ".github/workflows/ubuntu.yml"
177
- - ".github/workflows/windows.yml"
147
+ - ".github/workflows/rake.yml"
178
148
  - ".gitignore"
179
149
  - ".rspec"
180
150
  - ".rubocop.yml"
@@ -198,6 +168,7 @@ files:
198
168
  - lib/relaton_calconnect/hit_collection.rb
199
169
  - lib/relaton_calconnect/processor.rb
200
170
  - lib/relaton_calconnect/scrapper.rb
171
+ - lib/relaton_calconnect/technical_committee.rb
201
172
  - lib/relaton_calconnect/version.rb
202
173
  - lib/relaton_calconnect/xml_parser.rb
203
174
  - relaton_calconnect.gemspec
@@ -213,14 +184,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
184
  requirements:
214
185
  - - ">="
215
186
  - !ruby/object:Gem::Version
216
- version: 2.4.0
187
+ version: 2.5.0
217
188
  required_rubygems_version: !ruby/object:Gem::Requirement
218
189
  requirements:
219
190
  - - ">="
220
191
  - !ruby/object:Gem::Version
221
192
  version: '0'
222
193
  requirements: []
223
- rubygems_version: 3.0.6
194
+ rubygems_version: 3.2.3
224
195
  signing_key:
225
196
  specification_version: 4
226
197
  summary: 'RelatonIso: retrieve CC Standards for bibliographic use using the IsoBibliographicItem
@@ -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