relaton-bib 1.11.2 → 1.11.5
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 +1 -5
- data/.rubocop.yml +1 -1
- data/README.adoc +13 -0
- data/lib/relaton_bib/bibliographic_item.rb +48 -30
- data/lib/relaton_bib/bibxml_parser.rb +1 -1
- data/lib/relaton_bib/localized_string.rb +1 -5
- data/lib/relaton_bib/typed_title_string.rb +12 -0
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +1 -1
- data/relaton-bib.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: 4879a622c8f133828b75abffc19166c9bc8047d9ecff25bbcd7b8cdc472acde4
|
|
4
|
+
data.tar.gz: 27b37f70ddf22ded981996ac98ae58b284b99790ff0d1bb96a55c100fc08a850
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46fdb1f657ae745e28ac3e4b11fa17b4bd42a75fef5c9aca29b7834796df6f75bdff1f73ef81222784f9dae07ea200a821d8d3ad10d754f5ee75eebded5e8fd1
|
|
7
|
+
data.tar.gz: 4a86ff51080029116ce9a0745f8411442fa6ce8da5a89b278a3a0dc38ffd4368fc36b516d9ea631662e74fc3704284889dfa1af758dba209520371824fe6321f
|
data/.github/workflows/rake.yml
CHANGED
|
@@ -16,7 +16,7 @@ jobs:
|
|
|
16
16
|
strategy:
|
|
17
17
|
fail-fast: false
|
|
18
18
|
matrix:
|
|
19
|
-
ruby: [ '3.0', '2.7', '2.6'
|
|
19
|
+
ruby: [ '3.0', '2.7', '2.6' ]
|
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
|
21
21
|
experimental: [ false ]
|
|
22
22
|
steps:
|
|
@@ -24,10 +24,6 @@ jobs:
|
|
|
24
24
|
with:
|
|
25
25
|
submodules: true
|
|
26
26
|
|
|
27
|
-
# https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
|
|
28
|
-
- if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
|
|
29
|
-
run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
|
|
30
|
-
|
|
31
27
|
- uses: ruby/setup-ruby@v1
|
|
32
28
|
with:
|
|
33
29
|
ruby-version: ${{ matrix.ruby }}
|
data/.rubocop.yml
CHANGED
data/README.adoc
CHANGED
|
@@ -416,6 +416,19 @@ item.to_bibtex
|
|
|
416
416
|
...
|
|
417
417
|
----
|
|
418
418
|
|
|
419
|
+
=== Export bibliographic item to Citeproc
|
|
420
|
+
|
|
421
|
+
[source,ruby]
|
|
422
|
+
----
|
|
423
|
+
item.to_citeproc
|
|
424
|
+
=> [{"title"=>"Geographic information",
|
|
425
|
+
"edition"=>"1",
|
|
426
|
+
"author"=>[{"family"=>"Bierman", "given"=>"A."}, {"family"=>"Bierman", "given"=>"Forename"}],
|
|
427
|
+
"publisher"=>"Institute of Electrical and Electronics Engineers",
|
|
428
|
+
"publisher-place"=>"bib place",
|
|
429
|
+
...
|
|
430
|
+
----
|
|
431
|
+
|
|
419
432
|
=== Exporting bibliographic item to AsciiBib
|
|
420
433
|
|
|
421
434
|
[source,ruby]
|
|
@@ -401,30 +401,26 @@ module RelatonBib
|
|
|
401
401
|
hash
|
|
402
402
|
end
|
|
403
403
|
|
|
404
|
-
#
|
|
404
|
+
#
|
|
405
|
+
# Reander BibTeX
|
|
406
|
+
#
|
|
407
|
+
# @param bibtex [BibTeX::Bibliography, nil]
|
|
408
|
+
#
|
|
405
409
|
# @return [String]
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
bibtex_classification item
|
|
421
|
-
item.keywords = keyword.map(&:content).join(", ") if keyword.any?
|
|
422
|
-
bibtex_docidentifier item
|
|
423
|
-
item.timestamp = fetched.to_s if fetched
|
|
424
|
-
bibtex_link item
|
|
425
|
-
bibtex ||= BibTeX::Bibliography.new
|
|
426
|
-
bibtex << item
|
|
427
|
-
bibtex.to_s
|
|
410
|
+
#
|
|
411
|
+
def to_bibtex(bibtex = nil)
|
|
412
|
+
bibtext_item(bibtex).to_s
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
#
|
|
416
|
+
# Render citeproc
|
|
417
|
+
#
|
|
418
|
+
# @param bibtex [BibTeX::Bibliography, nil]
|
|
419
|
+
#
|
|
420
|
+
# @return [Hash] citeproc
|
|
421
|
+
#
|
|
422
|
+
def to_citeproc(bibtex = nil)
|
|
423
|
+
bibtext_item(bibtex).to_citeproc.map { |cp| cp.transform_keys(&:to_s) }
|
|
428
424
|
end
|
|
429
425
|
|
|
430
426
|
# @param lang [String, nil] language code Iso639
|
|
@@ -555,13 +551,35 @@ module RelatonBib
|
|
|
555
551
|
|
|
556
552
|
private
|
|
557
553
|
|
|
558
|
-
#
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
554
|
+
#
|
|
555
|
+
# Create BibTeX item for this document
|
|
556
|
+
#
|
|
557
|
+
# @param [BibTeX::Bibliography, nil] bibtex <description>
|
|
558
|
+
#
|
|
559
|
+
# @return [BibTeX::Bibliography] BibTeX bibliography
|
|
560
|
+
#
|
|
561
|
+
def bibtext_item(bibtex) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
562
|
+
item = BibTeX::Entry.new
|
|
563
|
+
item.type = bibtex_type
|
|
564
|
+
item.key = id
|
|
565
|
+
title.to_bibtex item
|
|
566
|
+
item.edition = edition if edition
|
|
567
|
+
bibtex_author item
|
|
568
|
+
bibtex_contributor item
|
|
569
|
+
item.address = place.first.name if place.any?
|
|
570
|
+
bibtex_note item
|
|
571
|
+
bibtex_relation item
|
|
572
|
+
bibtex_extent item
|
|
573
|
+
bibtex_date item
|
|
574
|
+
bibtex_series item
|
|
575
|
+
bibtex_classification item
|
|
576
|
+
item.keywords = keyword.map(&:content).join(", ") if keyword.any?
|
|
577
|
+
bibtex_docidentifier item
|
|
578
|
+
item.timestamp = fetched.to_s if fetched
|
|
579
|
+
bibtex_link item
|
|
580
|
+
bibtex ||= BibTeX::Bibliography.new
|
|
581
|
+
bibtex << item
|
|
582
|
+
bibtex
|
|
565
583
|
end
|
|
566
584
|
|
|
567
585
|
# @return [String]
|
|
@@ -194,7 +194,7 @@ module RelatonBib
|
|
|
194
194
|
# @return [Array<RelatonBib::FormattedString>]
|
|
195
195
|
def abstracts(ref)
|
|
196
196
|
ref.xpath("./front/abstract").map do |a|
|
|
197
|
-
c = a.
|
|
197
|
+
c = a.inner_html.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2')
|
|
198
198
|
.gsub(/[\t\n]/, " ").squeeze " "
|
|
199
199
|
FormattedString.new(content: c, language: language(ref), script: "Latn",
|
|
200
200
|
format: "text/html")
|
|
@@ -56,14 +56,10 @@ module RelatonBib
|
|
|
56
56
|
else
|
|
57
57
|
builder.parent["language"] = language.join(",") if language&.any?
|
|
58
58
|
builder.parent["script"] = script.join(",") if script&.any?
|
|
59
|
-
builder.
|
|
59
|
+
builder.text content
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
-
def escaped_content
|
|
64
|
-
content.encode("UTF-8") # .gsub(/&/, "&").gsub(/"/, """).gsub(/'/, "'")
|
|
65
|
-
end
|
|
66
|
-
|
|
67
63
|
# @return [Hash]
|
|
68
64
|
def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
69
65
|
if content.is_a? String
|
|
@@ -62,6 +62,18 @@ module RelatonBib
|
|
|
62
62
|
tl.each { |t| opts[:builder].title { t.to_xml opts[:builder] } }
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
#
|
|
66
|
+
# Add main title ot bibtex entry
|
|
67
|
+
#
|
|
68
|
+
# @param [BibTeX::Entry] item bibtex entry
|
|
69
|
+
#
|
|
70
|
+
def to_bibtex(item)
|
|
71
|
+
tl = titles.detect { |t| t.type == "main" }
|
|
72
|
+
return unless tl
|
|
73
|
+
|
|
74
|
+
item.title = tl.title.content
|
|
75
|
+
end
|
|
76
|
+
|
|
65
77
|
private
|
|
66
78
|
|
|
67
79
|
# @param lang [String]
|
data/lib/relaton_bib/version.rb
CHANGED
|
@@ -354,7 +354,7 @@ module RelatonBib
|
|
|
354
354
|
# @return [Array<RelatonBib::FormattedString>]
|
|
355
355
|
def fetch_abstract(item)
|
|
356
356
|
item.xpath("./abstract").map do |a|
|
|
357
|
-
c = a.children.to_s
|
|
357
|
+
c = a.text.strip # children.to_s
|
|
358
358
|
FormattedString.new(content: c, language: a[:language],
|
|
359
359
|
script: a[:script], format: a[:format])
|
|
360
360
|
end
|
data/relaton-bib.gemspec
CHANGED
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.bindir = "exe"
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
|
24
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
|
25
25
|
|
|
26
26
|
spec.add_development_dependency "byebug"
|
|
27
27
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
|
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.add_dependency "addressable"
|
|
37
37
|
spec.add_dependency "bibtex-ruby"
|
|
38
38
|
spec.add_dependency "iso639"
|
|
39
|
-
spec.add_dependency "nokogiri", "~> 1.
|
|
39
|
+
spec.add_dependency "nokogiri", "~> 1.13.0"
|
|
40
40
|
end
|
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: 1.11.
|
|
4
|
+
version: 1.11.5
|
|
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-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: byebug
|
|
@@ -184,14 +184,14 @@ dependencies:
|
|
|
184
184
|
requirements:
|
|
185
185
|
- - "~>"
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 1.
|
|
187
|
+
version: 1.13.0
|
|
188
188
|
type: :runtime
|
|
189
189
|
prerelease: false
|
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
191
|
requirements:
|
|
192
192
|
- - "~>"
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: 1.
|
|
194
|
+
version: 1.13.0
|
|
195
195
|
description: 'RelatonBib: Ruby XMLDOC impementation.'
|
|
196
196
|
email:
|
|
197
197
|
- open.source@ribose.com
|
|
@@ -270,7 +270,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
270
270
|
requirements:
|
|
271
271
|
- - ">="
|
|
272
272
|
- !ruby/object:Gem::Version
|
|
273
|
-
version: 2.
|
|
273
|
+
version: 2.6.0
|
|
274
274
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
275
|
requirements:
|
|
276
276
|
- - ">="
|