relaton-calconnect 2.0.0.pre.alpha.2 → 2.0.0.pre.alpha.3
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/.gitignore +1 -0
- data/README.adoc +3 -3
- data/grammars/basicdoc.rng +14 -1
- data/grammars/biblio.rng +8 -8
- data/lib/relaton/calconnect/data_fetcher.rb +6 -1
- data/lib/relaton/calconnect/scraper.rb +223 -207
- data/lib/relaton/calconnect/version.rb +1 -1
- data/relaton_calconnect.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8eeb2fd8506663291f0232e8b37d85a01205c3a31a6b71a1eb1bd46d51a86697
|
|
4
|
+
data.tar.gz: aa119791dda6060581b2c43dd4bfafcd9cc1c288d61e2275196ab5568b150884
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 969a15f38d16893c511cdf9bdc341af97026c0e788ed99d6e53e2cb942a37e86a948ef367fa1a47661bbcd45a1c4b2c33f7657c86a0e4addaca5b165a5f99a9e
|
|
7
|
+
data.tar.gz: c2296648220ea1828e6393e6c57a971a52ce99c278a7f9663b02f66d6f77e329e596ac7e4a21e0338122e364dd406fd8867059f8a508b0f47981900208c2fbe4
|
data/.gitignore
CHANGED
data/README.adoc
CHANGED
|
@@ -43,7 +43,7 @@ item = hits[0].item
|
|
|
43
43
|
[source,ruby]
|
|
44
44
|
----
|
|
45
45
|
item.to_xml
|
|
46
|
-
=> "<bibitem id="CC-DIR10005-2019" type="standard" schema-version="v1.
|
|
46
|
+
=> "<bibitem id="CC-DIR10005-2019" type="standard" schema-version="v1.5.6">
|
|
47
47
|
<title language="en">Guidelines for the implementation of the CalConnect patent policy</title>
|
|
48
48
|
<docidentifier type="CalConnect" primary="true">CC/DIR 10005:2019</docidentifier>
|
|
49
49
|
...
|
|
@@ -53,11 +53,11 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
|
|
|
53
53
|
[source,ruby]
|
|
54
54
|
----
|
|
55
55
|
item.to_xml bibdata: true
|
|
56
|
-
=> "<bibdata type="standard" schema-version="v1.
|
|
56
|
+
=> "<bibdata type="standard" schema-version="v1.5.6">
|
|
57
57
|
<title language="en">Guidelines for the implementation of the CalConnect patent policy</title>
|
|
58
58
|
<docidentifier type="CalConnect" primary="true">CC/DIR 10005:2019</docidentifier>
|
|
59
59
|
...
|
|
60
|
-
<ext schema-version="v1.
|
|
60
|
+
<ext schema-version="v1.1.2">
|
|
61
61
|
<doctype abbreviation="DIR">directive</doctype>
|
|
62
62
|
<flavor>calconnect</flavor>
|
|
63
63
|
</ext>
|
data/grammars/basicdoc.rng
CHANGED
|
@@ -187,6 +187,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
187
187
|
<a:documentation>Optional caption of this block</a:documentation>
|
|
188
188
|
</attribute>
|
|
189
189
|
</optional>
|
|
190
|
+
<optional>
|
|
191
|
+
<attribute name="position">
|
|
192
|
+
<a:documentation>For an "add" change, whether the change is added before or after the location</a:documentation>
|
|
193
|
+
<choice>
|
|
194
|
+
<value>before</value>
|
|
195
|
+
<value>after</value>
|
|
196
|
+
</choice>
|
|
197
|
+
</attribute>
|
|
198
|
+
</optional>
|
|
190
199
|
<optional>
|
|
191
200
|
<element name="location">
|
|
192
201
|
<a:documentation>The location(s) in the original document which have undergone the change described in this block</a:documentation>
|
|
@@ -208,11 +217,15 @@ Applicable to modify and delete</a:documentation>
|
|
|
208
217
|
</zeroOrMore>
|
|
209
218
|
<optional>
|
|
210
219
|
<element name="newcontent">
|
|
211
|
-
<a:documentation>New content to be added to the document; applicable to add and modify
|
|
220
|
+
<a:documentation>New content to be added to the document; applicable to add and modify.
|
|
221
|
+
Can be blocks and/or sections</a:documentation>
|
|
212
222
|
<ref name="OptionalId"/>
|
|
213
223
|
<zeroOrMore>
|
|
214
224
|
<ref name="BasicBlock"/>
|
|
215
225
|
</zeroOrMore>
|
|
226
|
+
<zeroOrMore>
|
|
227
|
+
<ref name="section"/>
|
|
228
|
+
</zeroOrMore>
|
|
216
229
|
</element>
|
|
217
230
|
</optional>
|
|
218
231
|
<zeroOrMore>
|
data/grammars/biblio.rng
CHANGED
|
@@ -1142,11 +1142,11 @@ NOTE: This should preferably be encoded as a URI or short identifier, rather th
|
|
|
1142
1142
|
<a:documentation>Information about how long the current description of the bibliographic item is valid for</a:documentation>
|
|
1143
1143
|
</ref>
|
|
1144
1144
|
</optional>
|
|
1145
|
-
<
|
|
1145
|
+
<zeroOrMore>
|
|
1146
1146
|
<ref name="depiction">
|
|
1147
1147
|
<a:documentation>Depiction of the bibliographic item, typically an image</a:documentation>
|
|
1148
1148
|
</ref>
|
|
1149
|
-
</
|
|
1149
|
+
</zeroOrMore>
|
|
1150
1150
|
</define>
|
|
1151
1151
|
<define name="ReducedBibliographicItem">
|
|
1152
1152
|
<a:documentation>Reduced description of a bibliographic resource, without mandatory title and docidentifier, used for document relations
|
|
@@ -1939,10 +1939,10 @@ Detailed in https://www.relaton.org/model/relations/</a:documentation>
|
|
|
1939
1939
|
<value>hasAnnotation</value>
|
|
1940
1940
|
<value>draftOf</value>
|
|
1941
1941
|
<value>hasDraft</value>
|
|
1942
|
-
<value>
|
|
1943
|
-
<value>
|
|
1944
|
-
<value>
|
|
1945
|
-
<value>
|
|
1942
|
+
<value>predecessorDraftOf</value>
|
|
1943
|
+
<value>hasPredecessorDraft</value>
|
|
1944
|
+
<value>successorDraftOf</value>
|
|
1945
|
+
<value>hasSuccessorDraft</value>
|
|
1946
1946
|
<value>editionOf</value>
|
|
1947
1947
|
<value>hasEdition</value>
|
|
1948
1948
|
<value>updates</value>
|
|
@@ -2063,13 +2063,13 @@ provided that it is not the entire bibliographic item that is so related</a:docu
|
|
|
2063
2063
|
<ref name="LocalizedString"/>
|
|
2064
2064
|
</element>
|
|
2065
2065
|
</optional>
|
|
2066
|
-
<
|
|
2066
|
+
<zeroOrMore>
|
|
2067
2067
|
<element name="taxon">
|
|
2068
2068
|
<a:documentation>The keywords as a hierarchical taxonomy. For example, the sequence of `taxon` elements
|
|
2069
2069
|
`pump`, `centrifugal pump`, `line shaft pump` represents a taxonomic classification</a:documentation>
|
|
2070
2070
|
<ref name="LocalizedString"/>
|
|
2071
2071
|
</element>
|
|
2072
|
-
</
|
|
2072
|
+
</zeroOrMore>
|
|
2073
2073
|
<zeroOrMore>
|
|
2074
2074
|
<ref name="vocabid">
|
|
2075
2075
|
<a:documentation>Identifiers for the keyword as a controlled vocabulary</a:documentation>
|
|
@@ -27,6 +27,10 @@ module Relaton::Calconnect
|
|
|
27
27
|
@index = Relaton::Index.find_or_create :CC, file: "index-v1.yaml"
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def log_error(msg)
|
|
31
|
+
Util.error msg
|
|
32
|
+
end
|
|
33
|
+
|
|
30
34
|
#
|
|
31
35
|
# fetch data form server and save it to file.
|
|
32
36
|
#
|
|
@@ -40,6 +44,7 @@ module Relaton::Calconnect
|
|
|
40
44
|
data["root"]["items"].each { |doc| all_success &&= parse_page doc }
|
|
41
45
|
self.etag = resp[:etag] if all_success
|
|
42
46
|
index.save
|
|
47
|
+
report_errors
|
|
43
48
|
end
|
|
44
49
|
|
|
45
50
|
private
|
|
@@ -50,7 +55,7 @@ module Relaton::Calconnect
|
|
|
50
55
|
# @param [Hash] doc
|
|
51
56
|
#
|
|
52
57
|
def parse_page(doc)
|
|
53
|
-
bib = Scraper.parse_page doc
|
|
58
|
+
bib = Scraper.new(@errors).parse_page doc
|
|
54
59
|
# bib.link.each { |l| l.content.merge!(scheme: SCHEME, host: HOST) unless l.content.host }
|
|
55
60
|
write_doc doc["docid"][0]["id"], bib
|
|
56
61
|
true
|
|
@@ -3,264 +3,280 @@ require_relative "model/item"
|
|
|
3
3
|
|
|
4
4
|
module Relaton
|
|
5
5
|
module Calconnect
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
class Scraper
|
|
7
|
+
include Core::HashKeysSymbolizer
|
|
8
|
+
include Core::ArrayWrapper
|
|
9
9
|
|
|
10
10
|
DOMAIN = "https://standards.calconnect.org/".freeze
|
|
11
11
|
SCHEME, HOST = DOMAIN.split(%r{:?/?/})
|
|
12
12
|
# DOMAIN = "http://127.0.0.1:4000/".freeze
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# @papam hit [Hash] document hash
|
|
19
|
-
#
|
|
20
|
-
# @return [Relaton::Calconnect::ItemData] bibliographic item
|
|
21
|
-
#
|
|
22
|
-
def parse_page(hit) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
23
|
-
hash = symbolize_hash_keys hit
|
|
24
|
-
links = array(hash[:link])
|
|
25
|
-
link = links.detect { |l| l[:type] == "rxl" }
|
|
26
|
-
if link
|
|
27
|
-
bib = fetch_bib_xml link[:content]
|
|
28
|
-
update_links bib, links
|
|
29
|
-
else
|
|
30
|
-
hash.delete :fetched
|
|
31
|
-
bib = hash_to_item hash
|
|
32
|
-
end
|
|
33
|
-
update_sources bib
|
|
34
|
-
bib
|
|
35
|
-
end
|
|
14
|
+
# @param errors [Hash] error tracking hash
|
|
15
|
+
def initialize(errors = {})
|
|
16
|
+
@errors = errors
|
|
17
|
+
end
|
|
36
18
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
end
|
|
55
|
-
xml = rxl.to_xml.gsub(%r{(</?)technical-committee(>)}, '\1committee\2')
|
|
56
|
-
.gsub(%r{type="(?:csd|CC)"(?=>)}i, '\0 primary="true"')
|
|
57
|
-
Item.from_xml xml
|
|
19
|
+
#
|
|
20
|
+
# Parse document page
|
|
21
|
+
#
|
|
22
|
+
# @papam hit [Hash] document hash
|
|
23
|
+
#
|
|
24
|
+
# @return [Relaton::Calconnect::ItemData] bibliographic item
|
|
25
|
+
#
|
|
26
|
+
def parse_page(hit) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
27
|
+
hash = symbolize_hash_keys hit
|
|
28
|
+
links = array(hash[:link])
|
|
29
|
+
link = links.detect { |l| l[:type] == "rxl" }
|
|
30
|
+
if link
|
|
31
|
+
bib = fetch_bib_xml link[:content]
|
|
32
|
+
update_links bib, links
|
|
33
|
+
else
|
|
34
|
+
hash.delete :fetched
|
|
35
|
+
bib = hash_to_item hash
|
|
58
36
|
end
|
|
37
|
+
update_sources bib
|
|
38
|
+
bib
|
|
39
|
+
end
|
|
59
40
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# Fetch bibliographic item from XML source
|
|
45
|
+
#
|
|
46
|
+
# @param url [String] URL to fetch
|
|
47
|
+
#
|
|
48
|
+
# @return [RelatonCalconnect::CcBibliographicItem] bibliographic item
|
|
49
|
+
#
|
|
50
|
+
def fetch_bib_xml(url) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
51
|
+
rxl = get_rxl url
|
|
52
|
+
uri_rxl = rxl.at("uri[@type='rxl']")
|
|
53
|
+
if uri_rxl
|
|
54
|
+
uri_xml = rxl.xpath("//uri").to_xml
|
|
55
|
+
rxl = get_rxl uri_rxl.text
|
|
56
|
+
docid = rxl.at "//docidentifier"
|
|
57
|
+
docid.add_previous_sibling uri_xml
|
|
65
58
|
end
|
|
59
|
+
xml = rxl.to_xml.gsub(%r{(</?)technical-committee(>)}, '\1committee\2')
|
|
60
|
+
.gsub(%r{type="(?:csd|CC)"(?=>)}i, '\0 primary="true"')
|
|
61
|
+
Item.from_xml xml
|
|
62
|
+
end
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
#
|
|
74
|
-
def hash_to_item(hash)
|
|
75
|
-
hash_to_title hash
|
|
76
|
-
hash_to_source hash
|
|
77
|
-
hash_to_docid hash
|
|
78
|
-
hash_to_date hash
|
|
79
|
-
hash_to_contributor hash
|
|
80
|
-
hash_to_edition hash
|
|
81
|
-
hash_to_version hash
|
|
82
|
-
hosh_to_abstract hash
|
|
83
|
-
hash_to_status hash
|
|
84
|
-
hash_to_relation hash
|
|
85
|
-
hash_to_copyrigh hash
|
|
86
|
-
hash_to_keyword hash
|
|
87
|
-
hash_to_editorialgroup hash
|
|
88
|
-
hash_to_ext hash
|
|
89
|
-
ItemData.new(**hash)
|
|
90
|
-
end
|
|
64
|
+
# @param path [String]
|
|
65
|
+
# @return [Nokogiri::XML::Document]
|
|
66
|
+
def get_rxl(path)
|
|
67
|
+
resp = Faraday.get DOMAIN + path
|
|
68
|
+
Nokogiri::XML resp.body
|
|
69
|
+
end
|
|
91
70
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
71
|
+
#
|
|
72
|
+
# Fix editorial group
|
|
73
|
+
#
|
|
74
|
+
# @param [Hash] doc
|
|
75
|
+
#
|
|
76
|
+
# @return [Hash]
|
|
77
|
+
#
|
|
78
|
+
def hash_to_item(hash)
|
|
79
|
+
hash_to_title hash
|
|
80
|
+
hash_to_source hash
|
|
81
|
+
hash_to_docid hash
|
|
82
|
+
hash_to_date hash
|
|
83
|
+
hash_to_contributor hash
|
|
84
|
+
hash_to_edition hash
|
|
85
|
+
hash_to_version hash
|
|
86
|
+
hosh_to_abstract hash
|
|
87
|
+
hash_to_status hash
|
|
88
|
+
hash_to_relation hash
|
|
89
|
+
hash_to_copyrigh hash
|
|
90
|
+
hash_to_keyword hash
|
|
91
|
+
hash_to_editorialgroup hash
|
|
92
|
+
hash_to_ext hash
|
|
93
|
+
ItemData.new(**hash)
|
|
94
|
+
end
|
|
100
95
|
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
def hash_to_title(hash)
|
|
97
|
+
hash[:title] = array(hash[:title]).map do |t|
|
|
98
|
+
t[:language] = t[:language].first if t[:language].is_a? Array
|
|
99
|
+
t[:script] = t[:script].first if t[:script].is_a? Array
|
|
100
|
+
t.delete :format
|
|
101
|
+
Bib::Title.new(**t)
|
|
103
102
|
end
|
|
103
|
+
@errors[:title] &&= hash[:title].empty?
|
|
104
|
+
end
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
def hash_to_source(hash)
|
|
107
|
+
hash[:source] = array(hash[:link]).map { |link| Bib::Uri.new(type: "src", **link) }
|
|
108
|
+
@errors[:source] &&= hash[:source].empty?
|
|
109
|
+
end
|
|
108
110
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
def hash_to_docid(hash)
|
|
112
|
+
docid = hash.delete(:docid)
|
|
113
|
+
@errors[:docid] &&= docid.nil?
|
|
114
|
+
return unless docid
|
|
115
|
+
|
|
116
|
+
docid_types = %w[CC CSD]
|
|
117
|
+
hash[:docidentifier] = array(docid).map do |id|
|
|
118
|
+
id[:primary] = true if docid_types.include? id[:type].upcase
|
|
119
|
+
id[:content] = id.delete(:id) if id[:id]
|
|
120
|
+
Bib::Docidentifier.new(**id)
|
|
115
121
|
end
|
|
122
|
+
end
|
|
116
123
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
end
|
|
124
|
+
def hash_to_date(hash)
|
|
125
|
+
hash[:date] = array(hash[:date]).map do |d|
|
|
126
|
+
d[:at] = d.delete(:value) if d[:value]
|
|
127
|
+
Bib::Date.new(**d)
|
|
122
128
|
end
|
|
129
|
+
@errors[:date] &&= hash[:date].empty?
|
|
130
|
+
end
|
|
123
131
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
end
|
|
135
|
-
Bib::Contributor::Role.new(**role)
|
|
132
|
+
def hash_to_contributor(hash)
|
|
133
|
+
hash[:contributor] = array(hash[:contributor]).map do |contrib|
|
|
134
|
+
if contrib[:organization]
|
|
135
|
+
contrib[:organization] = create_organization contrib[:organization]
|
|
136
|
+
elsif contrib[:person]
|
|
137
|
+
contrib[:person] = create_person contrib[:person]
|
|
138
|
+
end
|
|
139
|
+
contrib[:role] = array(contrib[:role]).map do |role|
|
|
140
|
+
role[:description] = array(role[:description]).map do |desc|
|
|
141
|
+
Bib::LocalizedMarkedUpString.new content: desc
|
|
136
142
|
end
|
|
137
|
-
Bib::Contributor.new(**
|
|
143
|
+
Bib::Contributor::Role.new(**role)
|
|
138
144
|
end
|
|
145
|
+
Bib::Contributor.new(**contrib)
|
|
139
146
|
end
|
|
147
|
+
@errors[:contributor] &&= hash[:contributor].empty?
|
|
148
|
+
end
|
|
140
149
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
150
|
+
def create_organization(org_hash)
|
|
151
|
+
org_name = array(org_hash[:name]).each { |name| Bib::TypedLocalizedString.new(**name) }
|
|
152
|
+
contact = create_contact org_hash[:contact]
|
|
153
|
+
Bib::Organization.new(name: org_name, **contact)
|
|
154
|
+
end
|
|
146
155
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
end
|
|
156
|
+
def create_contact(contact_hash)
|
|
157
|
+
array(contact_hash).each_with_object({address: [], email: [], uri: []}) do |cont, acc|
|
|
158
|
+
case cont
|
|
159
|
+
in { address: addr_hash }
|
|
160
|
+
acc[:address] = Bib::Address.new(**addr_hash)
|
|
161
|
+
in { email: email }
|
|
162
|
+
acc[:email] << email
|
|
163
|
+
in { uri: uri }
|
|
164
|
+
acc[:uri] << Bib::Uri.new(content: uri)
|
|
157
165
|
end
|
|
158
166
|
end
|
|
167
|
+
end
|
|
159
168
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
end
|
|
167
|
-
contact = create_contact person_hash[:contact]
|
|
168
|
-
Bib::Person.new(name: name, affiliation: affiliation, **contact)
|
|
169
|
+
def create_person(person_hash)
|
|
170
|
+
completename = Bib::LocalizedString.new(**person_hash[:name][:completename])
|
|
171
|
+
name = Bib::FullName.new completename: completename
|
|
172
|
+
affiliation = array(person_hash[:affiliation]).map do |aff|
|
|
173
|
+
org = create_organization aff[:organization]
|
|
174
|
+
Bib::Affiliation.new(organization: org)
|
|
169
175
|
end
|
|
176
|
+
contact = create_contact person_hash[:contact]
|
|
177
|
+
Bib::Person.new(name: name, affiliation: affiliation, **contact)
|
|
178
|
+
end
|
|
170
179
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
180
|
+
def hash_to_edition(hash)
|
|
181
|
+
number = hash.dig(:edition, :content)
|
|
182
|
+
@errors[:edition] &&= number.nil?
|
|
183
|
+
hash[:edition] = Bib::Edition.new(number: number) if number
|
|
184
|
+
end
|
|
175
185
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
end
|
|
186
|
+
def hash_to_version(hash)
|
|
187
|
+
hash[:version] = array(hash[:version]).map do |ver|
|
|
188
|
+
Bib::Version.new(revision_date: ver[:revision_date])
|
|
180
189
|
end
|
|
190
|
+
end
|
|
181
191
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
end
|
|
192
|
+
def hosh_to_abstract(hash)
|
|
193
|
+
hash[:abstract] = array(hash[:abstract]).map do |abs|
|
|
194
|
+
Bib::Abstract.new(**abs)
|
|
186
195
|
end
|
|
196
|
+
@errors[:abstract] &&= hash[:abstract].empty?
|
|
197
|
+
end
|
|
187
198
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
199
|
+
def hash_to_status(hash)
|
|
200
|
+
docstatus = hash.delete(:docstatus)
|
|
201
|
+
@errors[:status] &&= docstatus.nil?
|
|
202
|
+
return unless docstatus
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
stage = Bib::Status::Stage.new content: docstatus.dig(:stage, :value)
|
|
205
|
+
hash[:status] = Bib::Status.new stage: stage
|
|
206
|
+
end
|
|
195
207
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
end
|
|
208
|
+
def hash_to_relation(hash)
|
|
209
|
+
hash[:relation] = array(hash[:relation]).map do |rel|
|
|
210
|
+
Bib::Relation.new(type: rel[:type], bibitem: hash_to_item(rel[:bibitem]))
|
|
200
211
|
end
|
|
212
|
+
@errors[:relation] &&= hash[:relation].empty?
|
|
213
|
+
end
|
|
201
214
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
end
|
|
208
|
-
Bib::ContributionInfo.new organization: Bib::Organization.new(name: org_name)
|
|
215
|
+
def hash_to_copyrigh(hash)
|
|
216
|
+
hash[:copyright] = array(hash[:copyright]).map do |cr|
|
|
217
|
+
cr[:owner] = array(cr[:owner]).map do |owner|
|
|
218
|
+
org_name = array(owner[:name]).map do |name|
|
|
219
|
+
Bib::TypedLocalizedString.new(**name)
|
|
209
220
|
end
|
|
210
|
-
Bib::
|
|
221
|
+
Bib::ContributionInfo.new organization: Bib::Organization.new(name: org_name)
|
|
211
222
|
end
|
|
223
|
+
Bib::Copyright.new(**cr)
|
|
212
224
|
end
|
|
225
|
+
@errors[:copyright] &&= hash[:copyright].empty?
|
|
226
|
+
end
|
|
213
227
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
end
|
|
228
|
+
def hash_to_keyword(hash)
|
|
229
|
+
hash[:keyword] = array(hash[:keyword]).map do |kw|
|
|
230
|
+
vocab = Bib::LocalizedString.new(**kw)
|
|
231
|
+
Bib::Keyword.new(vocab: vocab)
|
|
219
232
|
end
|
|
233
|
+
@errors[:keyword] &&= hash[:keyword].empty?
|
|
234
|
+
end
|
|
220
235
|
|
|
221
|
-
|
|
222
|
-
|
|
236
|
+
def hash_to_ext(hash)
|
|
237
|
+
return unless hash[:ext]
|
|
223
238
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
239
|
+
hash_to_doctype hash[:ext]
|
|
240
|
+
hash[:ext] = Ext.new(flavor: "calconnect", **hash.delete(:ext))
|
|
241
|
+
end
|
|
227
242
|
|
|
228
|
-
|
|
229
|
-
|
|
243
|
+
def hash_to_doctype(ext)
|
|
244
|
+
@errors[:doctype] &&= ext[:doctype].nil?
|
|
245
|
+
return unless ext[:doctype]
|
|
230
246
|
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
ext[:doctype] = Doctype.new content: ext.dig(:doctype, :type), abbreviation: ext.dig(:doctype, :abbreviation)
|
|
248
|
+
end
|
|
233
249
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
+
def hash_to_editorialgroup(hash)
|
|
251
|
+
eg = hash.delete(:editorialgroup) || (hash[:ext] && hash[:ext].delete(:editorialgroup))
|
|
252
|
+
@errors[:editorialgroup] &&= eg.nil?
|
|
253
|
+
return unless eg
|
|
254
|
+
|
|
255
|
+
# Handle old format: { technical_committee: { name: "X" } }
|
|
256
|
+
eg = eg[:technical_committee] if eg[:technical_committee]
|
|
257
|
+
|
|
258
|
+
subdiv_name = Bib::TypedLocalizedString.new content: eg[:name]
|
|
259
|
+
subdivision = Bib::Subdivision.new(type: "technical-committee", name: [subdiv_name])
|
|
260
|
+
org_name = Bib::TypedLocalizedString.new content: "CalConnect"
|
|
261
|
+
org = Bib::Organization.new name: [org_name], subdivision: [subdivision]
|
|
262
|
+
description = Bib::LocalizedMarkedUpString.new content: "committee"
|
|
263
|
+
role = Bib::Contributor::Role.new type: "author", description: [description]
|
|
264
|
+
hash[:contributor] ||= []
|
|
265
|
+
hash[:contributor] << Bib::Contributor.new(organization: org, role: [role])
|
|
266
|
+
end
|
|
250
267
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
end
|
|
256
|
-
bib
|
|
268
|
+
def update_links(bib, links)
|
|
269
|
+
links.each do |l|
|
|
270
|
+
tu = l.transform_keys(&:to_sym)
|
|
271
|
+
bib.source << Relaton::Bib::Uri.new(**tu) unless bib.source(l[:type])
|
|
257
272
|
end
|
|
273
|
+
bib
|
|
274
|
+
end
|
|
258
275
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
end
|
|
276
|
+
def update_sources(bib)
|
|
277
|
+
bib.source.each do |l|
|
|
278
|
+
uri = Addressable::URI.parse l.content
|
|
279
|
+
l.content = uri.merge(scheme: SCHEME, host: HOST).to_s unless uri.host
|
|
264
280
|
end
|
|
265
281
|
end
|
|
266
282
|
end
|
data/relaton_calconnect.gemspec
CHANGED
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
|
28
28
|
|
|
29
29
|
spec.add_dependency "faraday", "~> 2.7.0"
|
|
30
|
-
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.
|
|
31
|
-
spec.add_dependency "relaton-core", "~> 0.0.
|
|
30
|
+
spec.add_dependency "relaton-bib", "~> 2.0.0-alpha.7"
|
|
31
|
+
spec.add_dependency "relaton-core", "~> 0.0.12"
|
|
32
32
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
|
33
33
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-calconnect
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.0.pre.alpha.
|
|
4
|
+
version: 2.0.0.pre.alpha.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -29,28 +29,28 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 2.0.0.pre.alpha.
|
|
32
|
+
version: 2.0.0.pre.alpha.7
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 2.0.0.pre.alpha.
|
|
39
|
+
version: 2.0.0.pre.alpha.7
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: relaton-core
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.0.
|
|
46
|
+
version: 0.0.12
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.0.
|
|
53
|
+
version: 0.0.12
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: relaton-index
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|