relaton-cie 1.13.0 → 1.14.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 +0 -1
- data/.github/workflows/release.yml +22 -0
- data/README.adoc +24 -59
- data/grammars/basicdoc.rng +3 -27
- data/grammars/biblio-standoc.rng +164 -0
- data/grammars/biblio.rng +82 -19
- data/grammars/relaton-cie-compile.rng +11 -0
- data/grammars/relaton-cie.rng +4 -0
- data/lib/relaton_cie/bibliographic_item.rb +7 -0
- data/lib/relaton_cie/cie_bibliography.rb +2 -2
- data/lib/relaton_cie/data_fetcher.rb +7 -7
- data/lib/relaton_cie/hash_converter.rb +11 -0
- data/lib/relaton_cie/processor.rb +6 -6
- data/lib/relaton_cie/scrapper.rb +4 -3
- data/lib/relaton_cie/version.rb +1 -1
- data/lib/relaton_cie/xml_parser.rb +13 -0
- data/lib/relaton_cie.rb +3 -0
- data/relaton_cie.gemspec +1 -1
- metadata +11 -6
- data/grammars/isodoc.rng +0 -2807
- data/grammars/reqt.rng +0 -223
@@ -78,7 +78,7 @@ module RelatonCie
|
|
78
78
|
on = ref.at("p/time")
|
79
79
|
date = [RelatonBib::BibliographicDate.new(type: "published", on: on[:datetime])]
|
80
80
|
link = [RelatonBib::TypedUri.new(type: "src", content: url)]
|
81
|
-
bibitem =
|
81
|
+
bibitem = BibliographicItem.new docid: docid, title: title, link: link, date: date
|
82
82
|
type = ref.at('//li/i[contains(@class,"historical")]') ? "updates" : "updatedBy"
|
83
83
|
{ type: type, bibitem: bibitem }
|
84
84
|
end
|
@@ -103,14 +103,14 @@ module RelatonCie
|
|
103
103
|
# @param doc [Mechanize::Page]
|
104
104
|
# @return [Array<Hash>]
|
105
105
|
def fetch_contributor(doc) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity
|
106
|
-
authors = doc.xpath('//hgroup/p[not(@class="pub_date")]').text
|
106
|
+
authors = doc.xpath('//hgroup/p[not(@class="pub_date")]').text.gsub "\"", ""
|
107
107
|
contribs = []
|
108
108
|
until authors.empty?
|
109
109
|
/^(?<sname1>\S+(?:\sder?\s)?[^\s,]+)
|
110
110
|
(?:,?\s(?<sname2>[\w-]{2,})(?=,\s+\w\.))?
|
111
111
|
(?:,?\s(?<fname>[\w-]{2,})(?!,\s+\w\.))?
|
112
112
|
(?:(?:\s?,\s?|\s)(?<init>(?:\w(?:\s?\.|\s|,|$)[\s-]?)+))?
|
113
|
-
(?:(?:,\s
|
113
|
+
(?:(?:,\s*|\s+|\.|(?<=\s))(?:and\s)?)?/x =~ authors
|
114
114
|
raise StandardError, "Author name not found in \"#{authors}\"" unless $LAST_MATCH_INFO
|
115
115
|
|
116
116
|
authors.sub! $LAST_MATCH_INFO.to_s, ""
|
@@ -131,7 +131,7 @@ module RelatonCie
|
|
131
131
|
contribs << { entity: org, role: [{ type: "publisher" }] }
|
132
132
|
end
|
133
133
|
|
134
|
-
# @param bib [
|
134
|
+
# @param bib [RelatonCie::BibliographicItem]
|
135
135
|
def write_file(bib)
|
136
136
|
id = bib.docidentifier[0].id.gsub(%r{[/\s\-:.]}, "_")
|
137
137
|
file = "#{@output}/#{id.upcase}.#{@format}"
|
@@ -148,8 +148,8 @@ module RelatonCie
|
|
148
148
|
def parse_page(hit) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
149
149
|
url = "https://www.techstreet.com#{hit.at('h3/a')[:href]}"
|
150
150
|
doc = time_req { @agent.get url }
|
151
|
-
item =
|
152
|
-
type: "standard", link: fetch_link(url),
|
151
|
+
item = BibliographicItem.new(
|
152
|
+
type: "standard", link: fetch_link(url),
|
153
153
|
docid: fetch_docid(hit, doc), title: fetch_title(doc),
|
154
154
|
abstract: fetch_abstract(doc), date: fetch_date(doc),
|
155
155
|
edition: fetch_edition(doc), contributor: fetch_contributor(doc),
|
@@ -182,7 +182,7 @@ module RelatonCie
|
|
182
182
|
t1 = Time.now
|
183
183
|
puts "Started at: #{t1}"
|
184
184
|
|
185
|
-
FileUtils.mkdir output
|
185
|
+
FileUtils.mkdir output
|
186
186
|
new(output, format).fetch URL
|
187
187
|
|
188
188
|
t2 = Time.now
|
@@ -13,7 +13,7 @@ module RelatonCie
|
|
13
13
|
# @param code [String]
|
14
14
|
# @param date [String, NilClass] year
|
15
15
|
# @param opts [Hash]
|
16
|
-
# @return [
|
16
|
+
# @return [RelatonCie::BibliographicItem]
|
17
17
|
def get(code, date, opts)
|
18
18
|
::RelatonCie::CieBibliography.get(code, date, opts)
|
19
19
|
end
|
@@ -31,21 +31,21 @@ module RelatonCie
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# @param xml [String]
|
34
|
-
# @return [
|
34
|
+
# @return [RelatonCie::BibliographicItem]
|
35
35
|
def from_xml(xml)
|
36
|
-
::
|
36
|
+
::RelatonCie::XMLParser.from_xml xml
|
37
37
|
end
|
38
38
|
|
39
39
|
# @param hash [Hash]
|
40
|
-
# @return [
|
40
|
+
# @return [RelatonCie::BibliographicItem]
|
41
41
|
def hash_to_bib(hash)
|
42
|
-
::
|
42
|
+
::RelatonCie::BibliographicItem.from_hash hash
|
43
43
|
end
|
44
44
|
|
45
45
|
# Returns hash of XML grammar
|
46
46
|
# @return [String]
|
47
47
|
def grammar_hash
|
48
|
-
@grammar_hash ||= ::
|
48
|
+
@grammar_hash ||= ::RelatonCie.grammar_hash
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
data/lib/relaton_cie/scrapper.rb
CHANGED
@@ -4,7 +4,7 @@ module RelatonCie
|
|
4
4
|
|
5
5
|
class << self
|
6
6
|
# @param code [String]
|
7
|
-
# @return [
|
7
|
+
# @return [RelatonCie::BibliographicItem]
|
8
8
|
def scrape_page(code)
|
9
9
|
url = "#{ENDPOINT}#{code.gsub(/[\/\s\-:.]/, '_').upcase}.yaml"
|
10
10
|
parse_page url
|
@@ -17,11 +17,12 @@ module RelatonCie
|
|
17
17
|
private
|
18
18
|
|
19
19
|
# @param url [String]
|
20
|
-
# @retrurn [
|
20
|
+
# @retrurn [RelatoCie::BibliographicItem]
|
21
21
|
def parse_page(url)
|
22
22
|
doc = OpenURI.open_uri url
|
23
23
|
bib_hash = RelatonBib::HashConverter.hash_to_bib YAML.safe_load(doc)
|
24
|
-
|
24
|
+
bib_hash[:fetched] = Date.today.to_s
|
25
|
+
RelatonCie::BibliographicItem.new(**bib_hash)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
end
|
data/lib/relaton_cie/version.rb
CHANGED
data/lib/relaton_cie.rb
CHANGED
@@ -2,9 +2,12 @@ require "nokogiri"
|
|
2
2
|
require "open-uri"
|
3
3
|
require "relaton_bib"
|
4
4
|
require "relaton_cie/version"
|
5
|
+
require "relaton_cie/bibliographic_item"
|
5
6
|
require "relaton_cie/cie_bibliography"
|
6
7
|
require "relaton_cie/scrapper"
|
7
8
|
require "relaton_cie/data_fetcher"
|
9
|
+
require "relaton_cie/xml_parser"
|
10
|
+
require "relaton_cie/hash_converter"
|
8
11
|
|
9
12
|
module RelatonCie
|
10
13
|
# Returns hash of XML reammar
|
data/relaton_cie.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-cie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.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: 2022-
|
11
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.14.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.14.0
|
125
125
|
description: "RelatonEcma: retrieve CIE Standards for bibliographic use \nusing the
|
126
126
|
BibliographicItem model.\n"
|
127
127
|
email:
|
@@ -131,6 +131,7 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- ".github/workflows/rake.yml"
|
134
|
+
- ".github/workflows/release.yml"
|
134
135
|
- ".gitignore"
|
135
136
|
- ".rspec"
|
136
137
|
- ".rubocop.yml"
|
@@ -142,15 +143,19 @@ files:
|
|
142
143
|
- bin/rspec
|
143
144
|
- bin/setup
|
144
145
|
- grammars/basicdoc.rng
|
146
|
+
- grammars/biblio-standoc.rng
|
145
147
|
- grammars/biblio.rng
|
146
|
-
- grammars/
|
147
|
-
- grammars/
|
148
|
+
- grammars/relaton-cie-compile.rng
|
149
|
+
- grammars/relaton-cie.rng
|
148
150
|
- lib/relaton_cie.rb
|
151
|
+
- lib/relaton_cie/bibliographic_item.rb
|
149
152
|
- lib/relaton_cie/cie_bibliography.rb
|
150
153
|
- lib/relaton_cie/data_fetcher.rb
|
154
|
+
- lib/relaton_cie/hash_converter.rb
|
151
155
|
- lib/relaton_cie/processor.rb
|
152
156
|
- lib/relaton_cie/scrapper.rb
|
153
157
|
- lib/relaton_cie/version.rb
|
158
|
+
- lib/relaton_cie/xml_parser.rb
|
154
159
|
- relaton_cie.gemspec
|
155
160
|
homepage: https://github.com/metanorma/relaton-cie
|
156
161
|
licenses:
|