bolognese 2.6.0 → 2.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0dacdf04ab9d6bac881314d6769bbe4a32ef487886eb9e40b9c0de0025d3b93
4
- data.tar.gz: d208c61ab72eb28be3262692c3080caee9bd793d48129367659120f36bc429bd
3
+ metadata.gz: af6403c24df2779189b8883a6ac2a649856eefc21021f2a93e5e6ebeee91592a
4
+ data.tar.gz: 4fab74f8c6e1044c48a3d66fb64ff90ff134cf868b881dcbfc6a91e410fb3fa8
5
5
  SHA512:
6
- metadata.gz: a24c08c281faaccd79fde6ea90dbdb2341b4291a569095143c06fb5b91fcad02ebd365be08a2cd60db00259b53e7fef030780a879c7f27754aa98f4e7498cfa4
7
- data.tar.gz: 938bb5a4c4f05535fae6bb2bae548bf136b6775d070676ba9cddaa42469831c0ec3d6dff223fc111f9b3af7282a3ab2be78500efb964472c836403125d352ccb
6
+ metadata.gz: edb53a6a6644b9184fec632cb1b6a128d630c403499d19df8ce3e0febbac3a51d3d85d86b3f8a124a5b4fa3f3573022b0d0b633c5b9ced8a9bc416638cd7dfd4
7
+ data.tar.gz: a3f0b04d4ed508858ea7e7ec896f2182bdd9d7d5773e58e4e97faa8e52bd362cd0688a305b2efec9c614a51564b0927d8270b597ce976322e8650182cab5bc4a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bolognese (2.6.0)
4
+ bolognese (2.6.1)
5
5
  activesupport (~> 8.1, >= 8.1.2)
6
6
  bibtex-ruby (~> 6.2)
7
7
  builder (~> 3.3)
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Minimal patch for csl-ruby and citeproc-ruby compatibility
4
+ # Root cause: 'contributor' is not recognized as a names variable in citeproc gem
5
+ # https://github.com/inukshuk/citeproc/blob/121fa4a950b9bd71960e42d20db96bcea1165201/lib/citeproc/variable.rb#L20-L24
6
+
7
+ module CiteProc
8
+ class Variable
9
+ # Unfreeze, modify, and refreeze the fields to add 'contributor' and 'accepted-date'
10
+ if @fields
11
+ # Unfreeze the fields hash temporarily
12
+ fields_dup = @fields.dup
13
+
14
+ # Add contributor to names (make a new unfrozen array)
15
+ fields_dup[:names] = (@fields[:names] + [:contributor]).uniq
16
+
17
+ # Add accepted-date to dates (make a new unfrozen array)
18
+ fields_dup[:date] = (@fields[:date] + [:'accepted-date']).uniq
19
+
20
+ # Rebuild the types mapping - only use actual type keys, not aliases like :all, :any, etc.
21
+ types_hash = Hash[*[:date, :names, :number, :text].map { |k| fields_dup[k].map { |n| [n, k] } }.flatten]
22
+
23
+ # Update the class instance variables
24
+ @fields = fields_dup
25
+ @types = Hash.new { |h,k| h.fetch(k.to_sym, nil) }.merge(types_hash).freeze
26
+
27
+ # Rebuild @factories from the new @types
28
+ # This maps each field name to its Variable subclass (Names, Date, Text, Number)
29
+ @factories = Hash.new { |h,k| h.fetch(k.to_s.intern, CiteProc::Variable) }.merge(
30
+ Hash[*@types.map { |field_name, type|
31
+ [field_name, CiteProc.const_get(type.to_s.capitalize)]
32
+ }.flatten]
33
+ ).freeze
34
+
35
+ # Recreate the aliases
36
+ @fields[:name] = @fields[:names]
37
+ @fields[:dates] = @fields[:date]
38
+ @fields[:numbers] = @fields[:number]
39
+
40
+ # Recreate :all and :any
41
+ @fields[:all] = @fields[:any] =
42
+ [:date, :names, :text, :number].reduce([]) { |s,a| s.concat(@fields[a]) }.sort
43
+
44
+ # Refreeze fields
45
+ @fields.freeze
46
+ end
47
+ end
48
+ end
@@ -139,19 +139,28 @@ module Bolognese
139
139
  author = to_citeproc(creators)
140
140
  end
141
141
 
142
- if types["resourceTypeGeneral"] == "Software" && version_info.present?
143
- type = "book"
142
+ if types["resourceTypeGeneral"] == "Software"
143
+ type = "software"
144
144
  else
145
145
  type = types["citeproc"]
146
146
  end
147
147
 
148
+ # Filter out contributors who are already creators, editors, or translators to avoid duplication
149
+ creator_names = Array.wrap(creators).map { |c| c["name"] || [c["givenName"], c["familyName"]].compact.join(" ") }.compact
150
+ unique_contributors = Array.wrap(contributors).reject do |c|
151
+ contributor_name = c["name"] || [c["givenName"], c["familyName"]].compact.join(" ")
152
+ creator_names.include?(contributor_name) ||
153
+ c["contributorType"] == "Editor" ||
154
+ c["contributorType"] == "Translator"
155
+ end
156
+
148
157
  {
149
158
  "type" => type,
150
159
  "id" => normalize_doi(doi),
151
160
  "categories" => Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) }.presence,
152
161
  "language" => language,
153
162
  "author" => author,
154
- "contributor" => to_citeproc(contributors),
163
+ "contributor" => unique_contributors.presence ? to_citeproc(unique_contributors) : nil,
155
164
  "editor" => contributors ? to_citeproc(contributors.select { |c| c["contributorType"] == "Editor" }) : nil,
156
165
  "translator" => contributors ? to_citeproc(contributors.select { |c| c["contributorType"] == "Translator" }) : nil,
157
166
  "issued" => get_date(dates, "Issued") ? get_date_parts(get_date(dates, "Issued")) : get_date_parts(publication_year.to_s),
@@ -1,3 +1,3 @@
1
1
  module Bolognese
2
- VERSION = "2.6.0"
2
+ VERSION = "2.6.1"
3
3
  end
data/lib/bolognese.rb CHANGED
@@ -16,6 +16,7 @@ require 'citeproc'
16
16
  require 'csl/styles'
17
17
  require 'edtf'
18
18
 
19
+ require "bolognese/citeproc_extensions"
19
20
  require "bolognese/version"
20
21
  require "bolognese/metadata"
21
22
  require "bolognese/cli"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bolognese
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-03-12 00:00:00.000000000 Z
10
+ date: 2026-04-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: maremma
@@ -515,6 +515,7 @@ files:
515
515
  - lib/bolognese.rb
516
516
  - lib/bolognese/array.rb
517
517
  - lib/bolognese/author_utils.rb
518
+ - lib/bolognese/citeproc_extensions.rb
518
519
  - lib/bolognese/cli.rb
519
520
  - lib/bolognese/datacite_utils.rb
520
521
  - lib/bolognese/doi_utils.rb