relaton-ecma 1.7.pre1 → 1.9.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 +4 -4
- data/.github/workflows/rake.yml +36 -0
- data/.rubocop.yml +1 -1
- data/README.adoc +16 -4
- data/grammars/basicdoc.rng +165 -20
- data/grammars/biblio.rng +5 -6
- data/grammars/isodoc.rng +532 -16
- data/grammars/reqt.rng +31 -2
- data/lib/relaton_ecma/processor.rb +1 -2
- data/lib/relaton_ecma/scrapper.rb +7 -79
- data/lib/relaton_ecma/version.rb +1 -1
- data/relaton_ecma.gemspec +4 -4
- metadata +9 -39
- data/.github/workflows/macos.yml +0 -34
- data/.github/workflows/ubuntu.yml +0 -33
- data/.github/workflows/windows.yml +0 -35
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
|
-
<
|
|
70
|
+
<zeroOrMore>
|
|
52
71
|
<ref name="reqinherit"/>
|
|
53
|
-
</
|
|
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>
|
|
@@ -26,8 +26,7 @@ module RelatonEcma
|
|
|
26
26
|
# @param hash [Hash]
|
|
27
27
|
# @return [RelatonBib::BibliographicItem]
|
|
28
28
|
def hash_to_bib(hash)
|
|
29
|
-
|
|
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://
|
|
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)
|
|
9
|
-
|
|
10
|
-
url
|
|
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(
|
|
26
|
-
|
|
27
|
-
|
|
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('//tr[@class="STbody"]/td/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('//span[@class="STsubtitle"]').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('//p[@class="STdescription"]').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('//span[@class="STedition"]').map do |d|
|
|
73
|
-
date = d.text.match(/(?<=\()\w+\s\d{4}(?=\))/).to_s
|
|
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('//span[@class="STedition"]')&.text&.strip&.match(/^\d+(?=th)/)&.to_s
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
# @param doc [Nokogiri::HTML::Document]
|
|
85
|
-
# @return [Array<Hash>]
|
|
86
|
-
def fetch_relation(doc)
|
|
87
|
-
history = doc.at "//p[contains(., 'historical')]/a"
|
|
88
|
-
return [] unless history
|
|
89
|
-
|
|
90
|
-
rel_doc = Nokogiri::HTML OpenURI.open_uri(ENDPOINT + history[:href])
|
|
91
|
-
rel_doc.xpath("//tr[@class='STbody']/td[1]/*").map do |rel|
|
|
92
|
-
fref = RelatonBib::FormattedRef.new content: rel.text, language: "en", script: "Latn"
|
|
93
|
-
bibitem = RelatonBib::BibliographicItem.new formattedref: fref
|
|
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
|
data/lib/relaton_ecma/version.rb
CHANGED
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.
|
|
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.
|
|
40
|
+
spec.add_dependency "relaton-bib", "~> 1.9.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.
|
|
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
|
|
@@ -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.
|
|
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: "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/
|
|
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"
|
|
@@ -194,14 +164,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
194
164
|
requirements:
|
|
195
165
|
- - ">="
|
|
196
166
|
- !ruby/object:Gem::Version
|
|
197
|
-
version: 2.
|
|
167
|
+
version: 2.5.0
|
|
198
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
169
|
requirements:
|
|
200
|
-
- - "
|
|
170
|
+
- - ">="
|
|
201
171
|
- !ruby/object:Gem::Version
|
|
202
|
-
version:
|
|
172
|
+
version: '0'
|
|
203
173
|
requirements: []
|
|
204
|
-
rubygems_version: 3.
|
|
174
|
+
rubygems_version: 3.2.3
|
|
205
175
|
signing_key:
|
|
206
176
|
specification_version: 4
|
|
207
177
|
summary: 'RelatonIetf: retrieve ECMA Standards for bibliographic use using the BibliographicItem
|
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
|