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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8f6ce6b1e876be86359025dc20ed5f0cb61ce24414c3976f6cfe6cf1ea64a48
4
- data.tar.gz: 8db13b8bed6167b3c888945d59ec0e23a2a47668001f867082b453f859ad1c60
3
+ metadata.gz: f0635b611ac4f1050927777a27b9dcbcdff41a44fb15bd04588b6055a86f6684
4
+ data.tar.gz: d4edaf1b8d51cadfbf746bcf5352502d157ab13aaa6feb038ad8a12e760546a5
5
5
  SHA512:
6
- metadata.gz: deba715a7e4a87f9499d0a5e37357ddda9992b50f5037efbd344b5fc3dcacd7ab3ca2b8a49fd4ff0c8e5d0f5f82d261b3ecc903d8f8f1aff622e9ad05f818806
7
- data.tar.gz: c9acc90c6ea97c091fc4595bc004e18148075d6c3b3d8193e5f4c942434a76dfe8d728cf26c75940234dc4aa0e0010d9bcf91ccd56a2365d0e3efc6bed7fc90e
6
+ metadata.gz: 07cb08cc43d6291d5a6ac0501c13a1ef8723c4eaee0cd43c8328e4f05c11c83ae57ccbe39044cc0735860233be6babfd59af52a37bc1d05b8406b725946e5c63
7
+ data.tar.gz: 2cd826e807172de65d1b32b50b555bd21692f377ae7adba18d4782b077bee87f454f54c0fb11c170108087f5e387d97dd96d2a0cbcdc33257917aa93a300c8da
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpCitation
4
- VERSION = '0.0.16'
4
+ VERSION = '0.0.17'
5
5
  end
@@ -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
- return nil unless bibtex_as_string.is_a?(String) && uri.is_a?(String)
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.16
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: 2024-08-05 00:00:00.000000000 Z
11
+ date: 2025-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug