uc3-dmp-citation 0.0.16 → 0.0.18
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/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: 7e4519a4904f1a6588b536ab26e4949a7a296331b1b2e0b2eae1972250492a43
|
4
|
+
data.tar.gz: a02d9ce85e76659525040ed8202b11de7236144663a82c418439407efbc03859
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e323d8dcae18788d55ce1add762c1daee7a07bae9c9d373953abf56f95d065829997ea3dceb2ceaba569ff7d89637f18cdd82a74a3625dd9ec43ba976466f49
|
7
|
+
data.tar.gz: af07b8644f00825f80fe6ae7fb45d4ab4e279257c98c4f11815c13845568c5d0efd9a66a2accd7b30ee224571cb0400f52d89044d1a57eb8d86e168709b01c43
|
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.18
|
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-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|