relaton-bib 0.5.0 → 0.8.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/macos.yml +16 -7
- data/.github/workflows/ubuntu.yml +16 -7
- data/.github/workflows/windows.yml +16 -7
- data/lib/relaton_bib.rb +1 -0
- data/lib/relaton_bib/bibliographic_item.rb +14 -3
- data/lib/relaton_bib/bibtex_parser.rb +10 -3
- data/lib/relaton_bib/deep_dup.rb +30 -0
- data/lib/relaton_bib/document_identifier.rb +2 -1
- data/lib/relaton_bib/hash_converter.rb +2 -0
- data/lib/relaton_bib/hit.rb +17 -3
- data/lib/relaton_bib/hit_collection.rb +41 -2
- data/lib/relaton_bib/localized_string.rb +1 -1
- data/lib/relaton_bib/typed_uri.rb +6 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +8 -5
- data/relaton-bib.gemspec +1 -1
- metadata +4 -5
- data/lib/relaton_bib/hash_to_bib.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d8b311616840c90e25325574979fe74ec6253ef5d23c0873545255ff3dce033
|
4
|
+
data.tar.gz: b144ea5a04e375c1a97ccc06891e0660b790048394a65e272f54ffda8d8c2edb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c5c5906f25a7f2289f9393efce6233ba11c7d8a0ffa0dfa1b7b863d69413756a6df679e5e0222fc744b3450bb6610499cbabe89da8b75dbaa00c1d9502080b
|
7
|
+
data.tar.gz: 31a66938522b61ca282a674106023d65c6250d0636f477b1dbed979427092a2f5aa3f6f8863331190b101a0eb56aa8e96dafed023c17a37f3c0459b148b2e413
|
data/.github/workflows/macos.yml
CHANGED
@@ -1,20 +1,29 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: macos
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
branches: [ '**' ]
|
6
10
|
|
7
11
|
jobs:
|
8
12
|
test-macos:
|
9
13
|
name: Test on Ruby ${{ matrix.ruby }} macOS
|
10
14
|
runs-on: macos-latest
|
11
15
|
strategy:
|
16
|
+
fail-fast: false
|
12
17
|
matrix:
|
13
18
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
19
|
steps:
|
15
|
-
- uses: actions/checkout@
|
16
|
-
|
17
|
-
|
20
|
+
- uses: actions/checkout@master
|
21
|
+
- name: Checkout submodules
|
22
|
+
shell: bash
|
23
|
+
run: |
|
24
|
+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
25
|
+
git submodule sync --recursive
|
26
|
+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
18
27
|
- name: Use Ruby
|
19
28
|
uses: actions/setup-ruby@v1
|
20
29
|
with:
|
@@ -22,7 +31,7 @@ jobs:
|
|
22
31
|
architecture: 'x64'
|
23
32
|
- name: Update gems
|
24
33
|
run: |
|
25
|
-
sudo gem install bundler
|
34
|
+
sudo gem install bundler --force
|
26
35
|
bundle install --jobs 4 --retry 3
|
27
36
|
- name: Run specs
|
28
37
|
run: |
|
@@ -1,20 +1,29 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: ubuntu
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
branches: [ '**' ]
|
6
10
|
|
7
11
|
jobs:
|
8
12
|
test-linux:
|
9
13
|
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
10
14
|
runs-on: ubuntu-latest
|
11
15
|
strategy:
|
16
|
+
fail-fast: false
|
12
17
|
matrix:
|
13
18
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
19
|
steps:
|
15
|
-
- uses: actions/checkout@
|
16
|
-
|
17
|
-
|
20
|
+
- uses: actions/checkout@master
|
21
|
+
- name: Checkout submodules
|
22
|
+
shell: bash
|
23
|
+
run: |
|
24
|
+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
25
|
+
git submodule sync --recursive
|
26
|
+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
18
27
|
- name: Use Ruby
|
19
28
|
uses: actions/setup-ruby@v1
|
20
29
|
with:
|
@@ -22,7 +31,7 @@ jobs:
|
|
22
31
|
architecture: 'x64'
|
23
32
|
- name: Update gems
|
24
33
|
run: |
|
25
|
-
gem install bundler
|
34
|
+
gem install bundler
|
26
35
|
bundle install --jobs 4 --retry 3
|
27
36
|
- name: Run specs
|
28
37
|
run: |
|
@@ -1,20 +1,29 @@
|
|
1
|
-
# Auto-generated
|
2
|
-
#
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
3
|
name: windows
|
4
4
|
|
5
|
-
on:
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
branches: [ '**' ]
|
6
10
|
|
7
11
|
jobs:
|
8
12
|
test-windows:
|
9
13
|
name: Test on Ruby ${{ matrix.ruby }} Windows
|
10
14
|
runs-on: windows-latest
|
11
15
|
strategy:
|
16
|
+
fail-fast: false
|
12
17
|
matrix:
|
13
18
|
ruby: [ '2.6', '2.5', '2.4' ]
|
14
19
|
steps:
|
15
|
-
- uses: actions/checkout@
|
16
|
-
|
17
|
-
|
20
|
+
- uses: actions/checkout@master
|
21
|
+
- name: Checkout submodules
|
22
|
+
shell: bash
|
23
|
+
run: |
|
24
|
+
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
25
|
+
git submodule sync --recursive
|
26
|
+
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
18
27
|
- name: Use Ruby
|
19
28
|
uses: actions/setup-ruby@v1
|
20
29
|
with:
|
@@ -23,7 +32,7 @@ jobs:
|
|
23
32
|
- name: Update gems
|
24
33
|
shell: pwsh
|
25
34
|
run: |
|
26
|
-
gem install bundler
|
35
|
+
gem install bundler
|
27
36
|
bundle config --local path vendor/bundle
|
28
37
|
bundle update
|
29
38
|
bundle install --jobs 4 --retry 3
|
data/lib/relaton_bib.rb
CHANGED
@@ -102,7 +102,7 @@ module RelatonBib
|
|
102
102
|
attr_reader :extent
|
103
103
|
|
104
104
|
# @return [Array<Strig>]
|
105
|
-
attr_reader :accesslocation
|
105
|
+
attr_reader :accesslocation, :license
|
106
106
|
|
107
107
|
# @return [Array<Relaton::Classification>]
|
108
108
|
attr_reader :classification
|
@@ -113,6 +113,9 @@ module RelatonBib
|
|
113
113
|
# @return [Date]
|
114
114
|
attr_reader :fetched
|
115
115
|
|
116
|
+
# @return [Array<RelatonBib::LocalizedString>]
|
117
|
+
attr_reader :keyword
|
118
|
+
|
116
119
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
117
120
|
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
118
121
|
|
@@ -136,6 +139,7 @@ module RelatonBib
|
|
136
139
|
# @param classification [Array<RelatonBib::Classification>]
|
137
140
|
# @param validity [RelatonBib:Validity, NilClass]
|
138
141
|
# @param fetched [Date, NilClass] default nil
|
142
|
+
# @param keyword [Array<String>]
|
139
143
|
#
|
140
144
|
# @param copyright [Hash, RelatonBib::CopyrightAssociation, NilClass]
|
141
145
|
# @option copyright [Hash, RelatonBib::ContributionInfo] :owner
|
@@ -171,7 +175,7 @@ module RelatonBib
|
|
171
175
|
# @option link [String] :content
|
172
176
|
def initialize(**args)
|
173
177
|
if args[:type] && !TYPES.include?(args[:type])
|
174
|
-
warn %{
|
178
|
+
warn %{[relaton-bib] document type "#{args[:type]}" is invalid.}
|
175
179
|
end
|
176
180
|
|
177
181
|
@title = (args[:title] || []).map do |t|
|
@@ -222,6 +226,8 @@ module RelatonBib
|
|
222
226
|
@classification = args.fetch :classification, []
|
223
227
|
@validity = args[:validity]
|
224
228
|
@fetched = args.fetch :fetched, nil # , Date.today # we should pass the fetched arg from scrappers
|
229
|
+
@keyword = (args[:keyword] || []).map { |kw| LocalizedString.new(kw) }
|
230
|
+
@license = args.fetch :license, []
|
225
231
|
end
|
226
232
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
227
233
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
@@ -303,6 +309,8 @@ module RelatonBib
|
|
303
309
|
hash["classification"] = single_element_array(classification) if classification&.any?
|
304
310
|
hash["validity"] = validity.to_hash if validity
|
305
311
|
hash["fetched"] = fetched.to_s if fetched
|
312
|
+
hash["keyword"] = single_element_array(keyword) if keyword&.any?
|
313
|
+
hash["license"] = single_element_array(license) if license&.any?
|
306
314
|
hash
|
307
315
|
end
|
308
316
|
|
@@ -323,6 +331,7 @@ module RelatonBib
|
|
323
331
|
bibtex_date item
|
324
332
|
bibtex_series item
|
325
333
|
bibtex_classification item
|
334
|
+
item.keywords = keyword.map(&:content).join(", ") if keyword.any?
|
326
335
|
bibtex_docidentifier item
|
327
336
|
item.timestamp = fetched.to_s if fetched
|
328
337
|
bibtex_link item
|
@@ -455,7 +464,7 @@ module RelatonBib
|
|
455
464
|
classification.each do |c|
|
456
465
|
case c.type
|
457
466
|
when "type" then item["type"] = c.value
|
458
|
-
when "keyword" then item.keywords = c.value
|
467
|
+
# when "keyword" then item.keywords = c.value
|
459
468
|
when "mendeley" then item["mendeley-tags"] = c.value
|
460
469
|
end
|
461
470
|
end
|
@@ -519,7 +528,9 @@ module RelatonBib
|
|
519
528
|
place.each { |pl| pl.to_xml builder }
|
520
529
|
extent.each { |e| builder.extent { e.to_xml builder } }
|
521
530
|
accesslocation.each { |al| builder.accesslocation al }
|
531
|
+
license.each { |l| builder.license l }
|
522
532
|
classification.each { |cls| cls.to_xml builder }
|
533
|
+
keyword.each { |kw| builder.keyword { kw.to_xml(builder) } }
|
523
534
|
validity&.to_xml builder
|
524
535
|
if block_given?
|
525
536
|
yield builder
|
@@ -24,7 +24,8 @@ module RelatonBib
|
|
24
24
|
series: fetch_series(bt),
|
25
25
|
link: fetch_link(bt),
|
26
26
|
language: fetch_language(bt),
|
27
|
-
classification: fetch_classification(bt)
|
27
|
+
classification: fetch_classification(bt),
|
28
|
+
keyword: fetch_keyword(bt)
|
28
29
|
)
|
29
30
|
h
|
30
31
|
end
|
@@ -225,12 +226,18 @@ module RelatonBib
|
|
225
226
|
def fetch_classification(bibtex)
|
226
227
|
cls = []
|
227
228
|
cls << Classification.new(type: "type", value: bibtex["type"].to_s) if bibtex["type"]
|
228
|
-
cls << Classification.new(type: "keyword", value: bibtex.keywords.to_s) if bibtex["keywords"]
|
229
|
+
# cls << Classification.new(type: "keyword", value: bibtex.keywords.to_s) if bibtex["keywords"]
|
229
230
|
if bibtex["mendeley-tags"]
|
230
|
-
|
231
|
+
cls << Classification.new(type: "mendeley", value: bibtex["mendeley-tags"].to_s)
|
231
232
|
end
|
232
233
|
cls
|
233
234
|
end
|
235
|
+
|
236
|
+
# @param bibtex [BibTeX::Entry]
|
237
|
+
# @return [Array<String>]
|
238
|
+
def fetch_keyword(bibtex)
|
239
|
+
bibtex["keywords"]&.split(", ") || []
|
240
|
+
end
|
234
241
|
end
|
235
242
|
end
|
236
243
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Object
|
2
|
+
def duplicable?
|
3
|
+
true
|
4
|
+
end
|
5
|
+
|
6
|
+
def deep_dup
|
7
|
+
duplicable? ? dup : self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Array
|
12
|
+
def deep_dup
|
13
|
+
map(&:deep_dup)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# class Hash
|
18
|
+
# def deep_dup
|
19
|
+
# hash = dup
|
20
|
+
# each_pair do |key, value|
|
21
|
+
# if key.frozen? && ::String === key
|
22
|
+
# hash[key] = value.deep_dup
|
23
|
+
# else
|
24
|
+
# hash.delete(key)
|
25
|
+
# hash[key.deep_dup] = value.deep_dup
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
# hash
|
29
|
+
# end
|
30
|
+
# end
|
data/lib/relaton_bib/hit.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
class Hit
|
3
|
+
# @return [RelatonBib::HitCollection]
|
4
|
+
attr_reader :hit_collection
|
5
|
+
|
3
6
|
# @return [Array<Hash>]
|
4
7
|
attr_reader :hit
|
5
8
|
|
@@ -24,9 +27,20 @@ module RelatonBib
|
|
24
27
|
"@title=\"#{@hit[:code]}\">"
|
25
28
|
end
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
def fetch
|
31
|
+
raise "Not implemented"
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param builder [Nokogiri::XML::Builder]
|
35
|
+
def to_xml(builder = nil, **opts)
|
36
|
+
if builder
|
37
|
+
fetch.to_xml builder, **opts
|
38
|
+
else
|
39
|
+
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
40
|
+
fetch.to_xml xml, **opts
|
41
|
+
end
|
42
|
+
builder.doc.root.to_xml
|
43
|
+
end
|
30
44
|
end
|
31
45
|
end
|
32
46
|
end
|
@@ -1,5 +1,11 @@
|
|
1
|
+
require "forwardable"
|
2
|
+
|
1
3
|
module RelatonBib
|
2
|
-
class HitCollection
|
4
|
+
class HitCollection
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :@array, :<<, :[], :first, :empty?, :any?, :size, :each, :each_slice
|
8
|
+
|
3
9
|
# @return [TrueClass, FalseClass]
|
4
10
|
attr_reader :fetched
|
5
11
|
|
@@ -9,6 +15,14 @@ module RelatonBib
|
|
9
15
|
# @return [String]
|
10
16
|
attr_reader :year
|
11
17
|
|
18
|
+
# @param text [String] reference to search
|
19
|
+
def initialize(text, year = nil)
|
20
|
+
@array = []
|
21
|
+
@text = text
|
22
|
+
@year = year
|
23
|
+
@fetched = false
|
24
|
+
end
|
25
|
+
|
12
26
|
# @return [RelatonIso::HitCollection]
|
13
27
|
def fetch
|
14
28
|
workers = WorkersPool.new 4
|
@@ -22,13 +36,38 @@ module RelatonBib
|
|
22
36
|
self
|
23
37
|
end
|
24
38
|
|
39
|
+
def to_xml(**opts)
|
40
|
+
builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
|
41
|
+
xml.documents do
|
42
|
+
@array.each do |hit|
|
43
|
+
hit.fetch
|
44
|
+
hit.to_xml xml, **opts
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
builder.to_xml
|
49
|
+
end
|
50
|
+
|
51
|
+
def select(&block)
|
52
|
+
me = self.deep_dup
|
53
|
+
array_dup = self.instance_variable_get(:@array).deep_dup
|
54
|
+
me.instance_variable_set(:@array, array_dup)
|
55
|
+
array_dup.select!(&block)
|
56
|
+
me
|
57
|
+
end
|
58
|
+
|
59
|
+
def reduce!(sum, &block)
|
60
|
+
@array = @array.reduce sum, &block
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
25
64
|
def to_s
|
26
65
|
inspect
|
27
66
|
end
|
28
67
|
|
29
68
|
# @return [String]
|
30
69
|
def inspect
|
31
|
-
"<#{self.class}:#{format('%#.14x', object_id << 1)} @fetched=#{@fetched}>"
|
70
|
+
"<#{self.class}:#{format('%#.14x', object_id << 1)} @ref=#{@text} @fetched=#{@fetched}>"
|
32
71
|
end
|
33
72
|
end
|
34
73
|
end
|
@@ -6,7 +6,7 @@ module RelatonBib
|
|
6
6
|
# @return [Symbol] :src/:obp/:rss
|
7
7
|
attr_reader :type
|
8
8
|
# @retutn [URI]
|
9
|
-
|
9
|
+
attr_reader :content
|
10
10
|
|
11
11
|
# @param type [String] src/obp/rss
|
12
12
|
# @param content [String]
|
@@ -15,6 +15,11 @@ module RelatonBib
|
|
15
15
|
@content = Addressable::URI.parse content if content
|
16
16
|
end
|
17
17
|
|
18
|
+
# @parma url [String]
|
19
|
+
def content=(url)
|
20
|
+
@content = Addressable::URI.parse url
|
21
|
+
end
|
22
|
+
|
18
23
|
# @param builder [Nokogiri::XML::Builder]
|
19
24
|
def to_xml(builder)
|
20
25
|
builder.uri(content.to_s, type: type)
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -42,6 +42,8 @@ module RelatonBib
|
|
42
42
|
extent: fetch_extent(bibitem),
|
43
43
|
accesslocation: bibitem.xpath("./accesslocation").map(&:text),
|
44
44
|
classification: fetch_classification(bibitem),
|
45
|
+
keyword: bibitem.xpath("keyword").map(&:text),
|
46
|
+
license: bibitem.xpath("license").map(&:text),
|
45
47
|
validity: fetch_validity(bibitem),
|
46
48
|
}
|
47
49
|
end
|
@@ -168,12 +170,13 @@ module RelatonBib
|
|
168
170
|
end
|
169
171
|
|
170
172
|
def fetch_dates(item)
|
171
|
-
item.xpath("./date").
|
173
|
+
item.xpath("./date").reduce([]) do |a, d|
|
172
174
|
type = d[:type].to_s.empty? ? "published" : d[:type]
|
173
|
-
|
174
|
-
type: type, on:
|
175
|
-
|
176
|
-
|
175
|
+
if (on = d.at("on"))
|
176
|
+
a << RelatonBib::BibliographicDate.new(type: type, on: on.text, to: d.at("to")&.text)
|
177
|
+
elsif (from = d.at("from"))
|
178
|
+
a << RelatonBib::BibliographicDate.new(type: type, from: from.text, to: d.at("to")&.text)
|
179
|
+
end
|
177
180
|
end
|
178
181
|
end
|
179
182
|
|
data/relaton-bib.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = "RelatonBib: Ruby XMLDOC impementation."
|
12
12
|
spec.description = "RelatonBib: Ruby XMLDOC impementation."
|
13
|
-
spec.homepage = "https://github.com/relaton/relaton-
|
13
|
+
spec.homepage = "https://github.com/relaton/relaton-bib"
|
14
14
|
spec.license = "BSD-2-Clause"
|
15
15
|
|
16
16
|
# Specify which files should be added to the gem when it is released.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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: 2020-
|
11
|
+
date: 2020-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -193,7 +193,6 @@ files:
|
|
193
193
|
- ".rspec"
|
194
194
|
- ".rubocop.yml"
|
195
195
|
- Gemfile
|
196
|
-
- Gemfile.lock
|
197
196
|
- LICENSE.txt
|
198
197
|
- README.adoc
|
199
198
|
- Rakefile
|
@@ -212,6 +211,7 @@ files:
|
|
212
211
|
- lib/relaton_bib/contribution_info.rb
|
213
212
|
- lib/relaton_bib/contributor.rb
|
214
213
|
- lib/relaton_bib/copyright_association.rb
|
214
|
+
- lib/relaton_bib/deep_dup.rb
|
215
215
|
- lib/relaton_bib/document_identifier.rb
|
216
216
|
- lib/relaton_bib/document_relation.rb
|
217
217
|
- lib/relaton_bib/document_relation_collection.rb
|
@@ -219,7 +219,6 @@ files:
|
|
219
219
|
- lib/relaton_bib/formatted_ref.rb
|
220
220
|
- lib/relaton_bib/formatted_string.rb
|
221
221
|
- lib/relaton_bib/hash_converter.rb
|
222
|
-
- lib/relaton_bib/hash_to_bib.rb
|
223
222
|
- lib/relaton_bib/hit.rb
|
224
223
|
- lib/relaton_bib/hit_collection.rb
|
225
224
|
- lib/relaton_bib/localized_string.rb
|
@@ -235,7 +234,7 @@ files:
|
|
235
234
|
- lib/relaton_bib/workers_pool.rb
|
236
235
|
- lib/relaton_bib/xml_parser.rb
|
237
236
|
- relaton-bib.gemspec
|
238
|
-
homepage: https://github.com/relaton/relaton-
|
237
|
+
homepage: https://github.com/relaton/relaton-bib
|
239
238
|
licenses:
|
240
239
|
- BSD-2-Clause
|
241
240
|
metadata: {}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
module RelatonBib
|
2
|
-
class << self
|
3
|
-
def hash_to_bib(args, nested = false)
|
4
|
-
return nil unless args.is_a?(Hash)
|
5
|
-
ret = Marshal.load(Marshal.dump(symbolize(args))) # deep copy
|
6
|
-
timestamp_hash(ret) unless nested
|
7
|
-
title_hash_to_bib(ret)
|
8
|
-
link_hash_to_bib(ret)
|
9
|
-
language_hash_to_bib(ret)
|
10
|
-
script_hash_to_bib(ret)
|
11
|
-
dates_hash_to_bib(ret)
|
12
|
-
docid_hash_to_bib(ret)
|
13
|
-
version_hash_to_bib(ret)
|
14
|
-
biblionote_hash_to_bib(ret)
|
15
|
-
abstract_hash_to_bib(ret)
|
16
|
-
formattedref_hash_to_bib(ret)
|
17
|
-
docstatus_hash_to_bib(ret)
|
18
|
-
contributors_hash_to_bib(ret)
|
19
|
-
relations_hash_to_bib(ret)
|
20
|
-
series_hash_to_bib(ret)
|
21
|
-
medium_hash_to_bib(ret)
|
22
|
-
place_hash_to_bib(ret)
|
23
|
-
extent_hash_to_bib(ret)
|
24
|
-
accesslocation_hash_to_bib(ret)
|
25
|
-
classification_hash_to_bib(ret)
|
26
|
-
validity_hash_to_bib(ret)
|
27
|
-
ret
|
28
|
-
end
|
29
|
-
|
30
|
-
def timestamp_hash(ret)
|
31
|
-
ret[:fetched] ||= Date.today.to_s
|
32
|
-
end
|
33
|
-
|
34
|
-
def symbolize(obj)
|
35
|
-
obj.is_a? Hash and
|
36
|
-
return obj.inject({}){|memo,(k,v)| memo[k.to_sym] = symbolize(v); memo}
|
37
|
-
obj.is_a? Array and
|
38
|
-
return obj.inject([]){|memo,v | memo << symbolize(v); memo}
|
39
|
-
return obj
|
40
|
-
end
|
41
|
-
|
42
|
-
def array(a)
|
43
|
-
return [] unless a
|
44
|
-
return [].push(a) unless a.is_a?(Array)
|
45
|
-
a
|
46
|
-
end
|
47
|
-
|
48
|
-
def localname(f, c)
|
49
|
-
return nil if f.nil?
|
50
|
-
f.is_a?(Hash) and lang = f[:language]
|
51
|
-
lang ||= c[:name][:language]
|
52
|
-
f.is_a?(Hash) and script = f[:script]
|
53
|
-
script ||= c[:name][:script]
|
54
|
-
f.is_a?(Hash) ?
|
55
|
-
RelatonBib::LocalizedString.new(f[:content], lang, script) :
|
56
|
-
RelatonBib::LocalizedString.new(f, lang, script)
|
57
|
-
end
|
58
|
-
|
59
|
-
def localizedstring(f)
|
60
|
-
f.is_a?(Hash) ?
|
61
|
-
RelatonBib::LocalizedString.new(f[:content], f[:language], f[:script]) :
|
62
|
-
RelatonBib::LocalizedString.new(f)
|
63
|
-
end
|
64
|
-
|
65
|
-
def formattedref(f)
|
66
|
-
f.is_a?(Hash) ? RelatonBib::FormattedRef.new(f) :
|
67
|
-
RelatonBib::FormattedRef.new(content: f)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|