uc3-dmp-citation 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-citation/version.rb +1 -1
- data/lib/uc3-dmp-citation.rb +10 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0635b611ac4f1050927777a27b9dcbcdff41a44fb15bd04588b6055a86f6684
|
4
|
+
data.tar.gz: d4edaf1b8d51cadfbf746bcf5352502d157ab13aaa6feb038ad8a12e760546a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07cb08cc43d6291d5a6ac0501c13a1ef8723c4eaee0cd43c8328e4f05c11c83ae57ccbe39044cc0735860233be6babfd59af52a37bc1d05b8406b725946e5c63
|
7
|
+
data.tar.gz: 2cd826e807172de65d1b32b50b555bd21692f377ae7adba18d4782b077bee87f454f54c0fb11c170108087f5e387d97dd96d2a0cbcdc33257917aa93a300c8da
|
data/lib/uc3-dmp-citation.rb
CHANGED
@@ -23,6 +23,7 @@ module Uc3DmpCitation
|
|
23
23
|
|
24
24
|
class << self
|
25
25
|
# rubocop:disable Metrics/AbcSize
|
26
|
+
|
26
27
|
def fetch_citation(doi:, work_type: DEFAULT_WORK_TYPE, style: DEFAULT_CITATION_STYLE, logger: nil)
|
27
28
|
uri = _doi_to_uri(doi:)
|
28
29
|
return nil if uri.nil? || uri.blank?
|
@@ -38,12 +39,14 @@ module Uc3DmpCitation
|
|
38
39
|
return nil if resp.nil? || resp.to_s.strip.empty?
|
39
40
|
|
40
41
|
bibtex_to_citation(uri: uri, bibtex_as_string: resp)
|
42
|
+
|
41
43
|
end
|
42
44
|
# rubocop:enable Metrics/AbcSize
|
43
45
|
|
44
46
|
# Convert the specified BibTex string into a citation
|
45
47
|
def bibtex_to_citation(uri:, bibtex_as_string:)
|
46
|
-
|
48
|
+
is_bibtex = looks_like_bibtex(bibtex_as_string)
|
49
|
+
return nil unless bibtex_as_string.is_a?(String) && uri.is_a?(String) && is_bibtex
|
47
50
|
|
48
51
|
bibtex = BibTeX.parse(_cleanse_bibtex(text: bibtex_as_string))
|
49
52
|
work_type = work_type.nil? ? _determine_work_type(bibtex:) : work_type
|
@@ -117,6 +120,12 @@ module Uc3DmpCitation
|
|
117
120
|
end
|
118
121
|
end
|
119
122
|
end
|
123
|
+
|
124
|
+
def looks_like_bibtex(text)
|
125
|
+
# Check if the text contains an @ followed by a known entry type
|
126
|
+
bibtex_entry_types = %w[article book booklet inbook incollection inproceedings conference manual mastersthesis phdthesis techreport misc unpublished]
|
127
|
+
bibtex_entry_types.any? { |type| text.include?("@#{type}") }
|
128
|
+
end
|
120
129
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
121
130
|
end
|
122
131
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uc3-dmp-citation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|