relaton-ecma 1.7.pre2 → 1.10.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.
data/grammars/reqt.rng CHANGED
@@ -30,9 +30,22 @@
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>
@@ -40,17 +53,31 @@
40
53
  <attribute name="filename"/>
41
54
  </optional>
42
55
  <optional>
43
- <ref name="reqtitle"/>
56
+ <attribute name="model"/>
44
57
  </optional>
45
58
  <optional>
46
- <ref name="label"/>
59
+ <attribute name="type"/>
47
60
  </optional>
48
61
  <optional>
49
- <ref name="subject"/>
62
+ <attribute name="tag"/>
50
63
  </optional>
51
64
  <optional>
52
- <ref name="reqinherit"/>
65
+ <attribute name="multilingual-rendering">
66
+ <ref name="MultilingualRenderingType"/>
67
+ </attribute>
53
68
  </optional>
69
+ <optional>
70
+ <ref name="reqtitle"/>
71
+ </optional>
72
+ <optional>
73
+ <ref name="label"/>
74
+ </optional>
75
+ <zeroOrMore>
76
+ <ref name="subject"/>
77
+ </zeroOrMore>
78
+ <zeroOrMore>
79
+ <ref name="reqinherit"/>
80
+ </zeroOrMore>
54
81
  <zeroOrMore>
55
82
  <ref name="classification"/>
56
83
  </zeroOrMore>
@@ -61,6 +88,7 @@
61
88
  <ref name="verification"/>
62
89
  <ref name="import"/>
63
90
  <ref name="description"/>
91
+ <ref name="component"/>
64
92
  </choice>
65
93
  </zeroOrMore>
66
94
  <optional>
@@ -81,17 +109,23 @@
81
109
  </define>
82
110
  <define name="label">
83
111
  <element name="label">
84
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
85
115
  </element>
86
116
  </define>
87
117
  <define name="subject">
88
118
  <element name="subject">
89
- <text/>
119
+ <oneOrMore>
120
+ <ref name="TextElement"/>
121
+ </oneOrMore>
90
122
  </element>
91
123
  </define>
92
124
  <define name="reqinherit">
93
125
  <element name="inherit">
94
- <text/>
126
+ <oneOrMore>
127
+ <ref name="TextElement"/>
128
+ </oneOrMore>
95
129
  </element>
96
130
  </define>
97
131
  <define name="measurementtarget">
@@ -119,6 +153,12 @@
119
153
  <ref name="RequirementSubpart"/>
120
154
  </element>
121
155
  </define>
156
+ <define name="component">
157
+ <element name="component">
158
+ <attribute name="class"/>
159
+ <ref name="RequirementSubpart"/>
160
+ </element>
161
+ </define>
122
162
  <define name="reqt_references">
123
163
  <element name="references">
124
164
  <oneOrMore>
@@ -135,6 +175,24 @@
135
175
  <data type="boolean"/>
136
176
  </attribute>
137
177
  </optional>
178
+ <optional>
179
+ <attribute name="keep-with-next">
180
+ <data type="boolean"/>
181
+ </attribute>
182
+ </optional>
183
+ <optional>
184
+ <attribute name="keep-lines-together">
185
+ <data type="boolean"/>
186
+ </attribute>
187
+ </optional>
188
+ <optional>
189
+ <attribute name="tag"/>
190
+ </optional>
191
+ <optional>
192
+ <attribute name="multilingual-rendering">
193
+ <ref name="MultilingualRenderingType"/>
194
+ </attribute>
195
+ </optional>
138
196
  <oneOrMore>
139
197
  <ref name="BasicBlock"/>
140
198
  </oneOrMore>
@@ -26,8 +26,7 @@ module RelatonEcma
26
26
  # @param hash [Hash]
27
27
  # @return [RelatonBib::BibliographicItem]
28
28
  def hash_to_bib(hash)
29
- item_hash = ::RelatonBib::HashConverter.hash_to_bib(hash)
30
- ::RelatonBib::BibliographicItem.new item_hash
29
+ ::RelatonBib::BibliographicItem.new hash
31
30
  end
32
31
 
33
32
  # Returns hash of XML grammar
@@ -1,15 +1,13 @@
1
1
  module RelatonEcma
2
2
  module Scrapper
3
- ENDPOINT = "https://www.ecma-international.org/publications/standards/".freeze
3
+ ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-ecma/master/data/".freeze
4
4
 
5
5
  class << self
6
6
  # @param code [String]
7
7
  # @return [RelatonBib::BibliographicItem]
8
- def scrape_page(code) # rubocop:disable Metrics/AbcSize
9
- num = /\d+$/.match(code).to_s.rjust 3, "0"
10
- url = ENDPOINT + code.capitalize.sub(/\d+$/, num) + ".htm"
11
- doc = Nokogiri::HTML OpenURI.open_uri url
12
- parse_page doc, code, url
8
+ def scrape_page(code)
9
+ url = "#{ENDPOINT}#{code.gsub(/[\/\s]/, '_').upcase}.yaml"
10
+ parse_page url
13
11
  rescue OpenURI::HTTPError => e
14
12
  return if e.io.status.first == "404"
15
13
 
@@ -18,81 +16,11 @@ module RelatonEcma
18
16
 
19
17
  private
20
18
 
21
- # @param doc [Nokogiri::HTML::Document]
22
- # @param code [String]
23
19
  # @param url [String]
24
20
  # @retrurn [RelatonBib::BibliographicItem]
25
- def parse_page(doc, code, url)
26
- RelatonBib::BibliographicItem.new(
27
- type: "standard", docid: fetch_docid(code), language: ["en"], script: ["Latn"],
28
- link: fetch_link(doc, url), title: fetch_title(doc), abstract: fetch_abstract(doc),
29
- date: fetch_date(doc), relation: fetch_relation(doc), place: ["Geneva"],
30
- edition: fetch_edition(doc), doctype: "document"
31
- )
32
- end
33
-
34
- # @param code [String]
35
- # @return [Array<RelatonBib::DocumentIdentifier>]
36
- def fetch_docid(code)
37
- [RelatonBib::DocumentIdentifier.new(type: "ECMA", id: code)]
38
- end
39
-
40
- # @param doc [Nokogiri::HTM::Document]
41
- # @param url [String]
42
- # @return [Array<RelatonBib::TypedUri>]
43
- def fetch_link(doc, url)
44
- link = [RelatonBib::TypedUri.new(type: "src", content: url)]
45
- ref = doc.at('//div[@class="ecma-item-content-wrapper"]/span/a')
46
- link << RelatonBib::TypedUri.new(type: "doi", content: ref[:href]) if ref
47
- link
48
- end
49
-
50
- # @param doc [Nokogiri::HTML::Document]
51
- # @return [Array<Hash>]
52
- def fetch_title(doc)
53
- doc.xpath('//p[@class="ecma-item-short-description"]').map do |t|
54
- { content: t.text.strip, language: "en", script: "Latn" }
55
- end
56
- end
57
-
58
- # @param doc [Nokogiri::HTML::Document]
59
- # @return [Array<RelatonBib::FormattedString>]
60
- def fetch_abstract(doc)
61
- a = doc.xpath('//div[@class="ecma-item-content"]/p').map do |a|
62
- a.text.strip.squeeze(" ").gsub /\r\n/, ""
63
- end.join "\n"
64
- return [] if a.empty?
65
-
66
- [RelatonBib::FormattedString.new(content: a, language: "en", script: "Latn")]
67
- end
68
-
69
- # @param doc [Nokogiri::HTML::Document]
70
- # @return [Array<RelatonBib::BibliographicDate>]
71
- def fetch_date(doc)
72
- doc.xpath('//p[@class="ecma-item-edition"]').map do |d|
73
- date = d.text.split(", ").last
74
- RelatonBib::BibliographicDate.new type: "published", on: date
75
- end
76
- end
77
-
78
- # @param doc [Nokogiri::HTML::Document]
79
- # @return [String]
80
- def fetch_edition(doc)
81
- doc.at('//p[@class="ecma-item-edition"]')&.text&.match(/^\d+(?=th)/)&.to_s
82
- end
83
-
84
- # @param doc [Nokogiri::HTML::Document]
85
- # @return [Array<Hash>]
86
- def fetch_relation(doc) # rubocop:disable Metrics/AbcSize
87
- doc.xpath("//ul[@class='ecma-item-archives']/li").map do |rel|
88
- ref, ed, on = rel.at("span").text.split ", "
89
- fref = RelatonBib::FormattedRef.new content: ref, language: "en", script: "Latn"
90
- date = []
91
- date << RelatonBib::BibliographicDate.new(type: "published", on: on) if on
92
- link = rel.xpath("span/a").map { |l| RelatonBib::TypedUri.new type: "doi", content: l[:href] }
93
- bibitem = RelatonBib::BibliographicItem.new formattedref: fref, edition: ed.match(/^\d+/).to_s, link: link
94
- { type: "updates", bibitem: bibitem }
95
- end
21
+ def parse_page(url)
22
+ doc = OpenURI.open_uri url
23
+ RelatonBib::BibliographicItem.from_hash YAML.safe_load(doc)
96
24
  end
97
25
  end
98
26
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonEcma
2
- VERSION = "1.7.pre2".freeze
2
+ VERSION = "1.10.0".freeze
3
3
  end
data/lib/relaton_ecma.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "nokogiri"
2
2
  require "open-uri"
3
+ require "yaml"
3
4
  require "relaton_bib"
4
5
  require "relaton_ecma/version"
5
6
  require "relaton_ecma/scrapper"
data/relaton_ecma.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
14
14
  DESCRIPTION
15
15
  spec.homepage = "https://github.com/metanorma/relaton-ecma"
16
16
  spec.license = "BSD-2-Clause"
17
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
17
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
 
@@ -27,15 +27,15 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_development_dependency "debase"
30
+ # spec.add_development_dependency "debase"
31
31
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
32
32
  spec.add_development_dependency "pry-byebug"
33
33
  spec.add_development_dependency "rake", "~> 10.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
  spec.add_development_dependency "vcr"
38
38
  spec.add_development_dependency "webmock"
39
39
 
40
- spec.add_dependency "relaton-bib", "~> 1.7.0"
40
+ spec.add_dependency "relaton-bib", "~> 1.10.0"
41
41
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ecma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.pre2
4
+ version: 1.10.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: 2021-01-21 00:00:00.000000000 Z
11
+ date: 2022-01-30 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: '10.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
@@ -142,14 +114,14 @@ dependencies:
142
114
  requirements:
143
115
  - - "~>"
144
116
  - !ruby/object:Gem::Version
145
- version: 1.7.0
117
+ version: 1.10.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.7.0
124
+ version: 1.10.0
153
125
  description: "RelatonEcma: retrieve ECMA Standards for bibliographic use \nusing the
154
126
  BibliographicItem model.\n"
155
127
  email:
@@ -158,9 +130,7 @@ executables: []
158
130
  extensions: []
159
131
  extra_rdoc_files: []
160
132
  files:
161
- - ".github/workflows/macos.yml"
162
- - ".github/workflows/ubuntu.yml"
163
- - ".github/workflows/windows.yml"
133
+ - ".github/workflows/rake.yml"
164
134
  - ".gitignore"
165
135
  - ".rspec"
166
136
  - ".rubocop.yml"
@@ -168,7 +138,6 @@ files:
168
138
  - LICENSE.txt
169
139
  - README.adoc
170
140
  - Rakefile
171
- - bin/console
172
141
  - bin/rspec
173
142
  - bin/setup
174
143
  - grammars/basicdoc.rng
@@ -194,14 +163,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
194
163
  requirements:
195
164
  - - ">="
196
165
  - !ruby/object:Gem::Version
197
- version: 2.4.0
166
+ version: 2.5.0
198
167
  required_rubygems_version: !ruby/object:Gem::Requirement
199
168
  requirements:
200
- - - ">"
169
+ - - ">="
201
170
  - !ruby/object:Gem::Version
202
- version: 1.3.1
171
+ version: '0'
203
172
  requirements: []
204
- rubygems_version: 3.0.6
173
+ rubygems_version: 3.2.3
205
174
  signing_key:
206
175
  specification_version: 4
207
176
  summary: 'RelatonIetf: retrieve ECMA Standards for bibliographic use using the BibliographicItem
@@ -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
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "relaton_ecma"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)