relaton-ecma 1.7.pre2 → 1.7.pre4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5826805692de35028ccf0275c7ca855e1f044f731488612f2f8c192536e8f180
4
- data.tar.gz: 119d00f6ecf72910d45206e571f523c23f06344f3a1b045cdf77459e43908f5b
3
+ metadata.gz: deb0a92653c1f7d2e24b409a59ea3fc11aa1eefe170a29726f2932ea1876560a
4
+ data.tar.gz: a8e05a0b88c3fed1e5bab10a10cb4dc6ef74186a9d24e475f6fc8abf74de5803
5
5
  SHA512:
6
- metadata.gz: eb9ec25d82615885254ecc1193e24f39073274842c9a20a51bf7bbd8a3d4f43ef0cdbffb808b2b50b07cfee58fb56da3647eed31e85fb2677d71d857dad32219
7
- data.tar.gz: b00dfc46e476ff792cdcc58df641a5e617b0feb19b0a2a73faababb0348bba565b82e24a6503f03212ef5345588e8b585dbe57bf6baa1967444b82720bbd228b
6
+ metadata.gz: f2654e5912550594cdec26a5a375721319a1726e497b0d52b35532604edac0b08e5eae9ded9675e2d5c92b7e94b8fed049772e8674a2ccbd084b834ce6f73708
7
+ data.tar.gz: d0f98cee3728a9ec59417bfc5ad6c731042a429f28c498b2e53ba3d614e49b861b2926aac5df5d4ce3cd92d82d579e11b22a9bafca7fc4a32838863fe56109ad
@@ -0,0 +1,46 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.7', '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '3.0'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '3.0'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '3.0'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ with:
35
+ submodules: true
36
+
37
+ # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
38
+ - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
39
+ run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
40
+
41
+ - uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby }}
44
+ bundler-cache: true
45
+
46
+ - run: bundle exec rake
data/README.adoc CHANGED
@@ -8,7 +8,7 @@ image:https://codeclimate.com/github/relaton/relaton-ecma/badges/gpa.svg["Code C
8
8
  image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-ecma.svg["Pull Requests", link="https://github.com/relaton/relaton-ecma/pulls"]
9
9
  image:https://img.shields.io/github/commits-since/relaton/relaton-ecma/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-ecma/releases"]
10
10
 
11
- RelatonIetf is a Ruby gem that search and fetch standards from the https://www.ecma-international.org[European Computer Manufacturers Association].
11
+ RelatonEcma is a Ruby gem that search and fetch standards from the https://www.ecma-international.org[European Computer Manufacturers Association].
12
12
 
13
13
  == Installation
14
14
 
@@ -16,7 +16,7 @@ Add this line to your application's Gemfile:
16
16
 
17
17
  [source,ruby]
18
18
  ----
19
- gem 'relaton_ecma'
19
+ gem 'relaton-ecma'
20
20
  ----
21
21
 
22
22
  And then execute:
@@ -25,7 +25,7 @@ And then execute:
25
25
 
26
26
  Or install it yourself as:
27
27
 
28
- $ gem install relaton_ecma
28
+ $ gem install relaton-ecma
29
29
 
30
30
  == Usage
31
31
 
@@ -41,6 +41,18 @@ item = RelatonEcma::EcmaBibliography.get 'ECMA-6'
41
41
  => #<RelatonBib::BibliographicItem:0x007fe0c047e340
42
42
  ...
43
43
 
44
+ RelatonEcma::EcmaBibliography.get 'ECMA TR/18'
45
+ [relaton-ecma] ("ECMA TR/18") fetching...
46
+ [relaton-ecma] ("ECMA TR/18") found ECMA TR/18
47
+ => #<RelatonBib::BibliographicItem:0x007ff53d2011a8
48
+ ...
49
+
50
+ RelatonEcma::EcmaBibliography.get "ECMA MEM/2021"
51
+ [relaton-ecma] ("ECMA MEM/2021") fetching...
52
+ [relaton-ecma] ("ECMA MEM/2021") found ECMA MEM/2021
53
+ => #<RelatonBib::BibliographicItem:0x007ff53d240150
54
+ ...
55
+
44
56
  # Return nil if document doesn't exist.
45
57
  RelatonEcma::EcmaBibliography.get '1111'
46
58
  [relaton-ecma] ("1111") fetching...
@@ -112,7 +124,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
112
124
 
113
125
  == Contributing
114
126
 
115
- Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton_ecma.
127
+ Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-ecma.
116
128
 
117
129
 
118
130
  == License
@@ -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.7.pre4".freeze
3
3
  end
data/relaton_ecma.gemspec CHANGED
@@ -27,11 +27,11 @@ 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"
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.7.pre4
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: 2021-03-19 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
@@ -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"
@@ -201,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
171
  - !ruby/object:Gem::Version
202
172
  version: 1.3.1
203
173
  requirements: []
204
- rubygems_version: 3.0.6
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
@@ -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