cff 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/CITATION.cff +3 -3
- data/LICENCE +1 -1
- data/README.md +1 -1
- data/lib/cff/formatters/bibtex.rb +21 -11
- data/lib/cff/formatters/formatter.rb +4 -11
- data/lib/cff/model_part.rb +49 -15
- data/lib/cff/version.rb +1 -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: '0685f4e60680971f1d131ee18722cd4989631cc223a192197a226cf18b8deca4'
|
4
|
+
data.tar.gz: 2bc27bb586bd0056a631b992a1da78befae597d8cc3815f5e124a72aa0e50180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b36c030c352a815045c8ee5464f2c445802e99ab44a7caab1503029f785f740673b273949faf530593141497e9948652886d2a2761ea1f8f66cb6707be7bcb5
|
7
|
+
data.tar.gz: 0325a6308c04c27213a16d54fb657f2b94c3fbb554e838ab469d3c10ef737e57bc3150b58e68550605b51aa2b971d5d6560933686d124be74aa746f1fb8c6669
|
data/CHANGES.md
CHANGED
data/CITATION.cff
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# This CITATION.cff file was created by ruby-cff (v 1.
|
1
|
+
# This CITATION.cff file was created by ruby-cff (v 1.2.0).
|
2
2
|
# Gem: https://rubygems.org/gems/cff
|
3
3
|
# CFF: https://citation-file-format.github.io/
|
4
4
|
|
@@ -21,9 +21,9 @@ keywords:
|
|
21
21
|
- metadata
|
22
22
|
- citation file format
|
23
23
|
- CFF
|
24
|
-
version: 1.
|
24
|
+
version: 1.2.0
|
25
25
|
doi: 10.5281/zenodo.1184077
|
26
|
-
date-released:
|
26
|
+
date-released: 2024-01-19
|
27
27
|
license: Apache-2.0
|
28
28
|
repository-artifact: https://rubygems.org/gems/cff
|
29
29
|
repository-code: https://github.com/citation-file-format/ruby-cff
|
data/LICENCE
CHANGED
@@ -186,7 +186,7 @@
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
187
187
|
identification within third-party archives.
|
188
188
|
|
189
|
-
Copyright (c) 2018-
|
189
|
+
Copyright (c) 2018-2024 The Ruby Citation File Format Developers.
|
190
190
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
192
192
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -203,7 +203,7 @@ cff.to_apalike(preferred_citation: false)
|
|
203
203
|
|
204
204
|
#### A note on citation formats
|
205
205
|
|
206
|
-
Due to the different expectations of different publication venues, the citation text may need minor tweaking to be used in specific situations. If you spot a major, or general, error in the output do [let us know](https://github.com/citation-file-format/ruby-cff/issues), but please check against the [
|
206
|
+
Due to the different expectations of different publication venues, the citation text may need minor tweaking to be used in specific situations. If you spot a major, or general, error in the output do [let us know](https://github.com/citation-file-format/ruby-cff/issues), but please check against the [BibTeX](https://www.bibtex.com/format/) and [APA](https://apastyle.apa.org/style-grammar-guidelines/references) standards first.
|
207
207
|
|
208
208
|
### Library versions
|
209
209
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-
|
3
|
+
# Copyright (c) 2018-2024 The Ruby Citation File Format Developers.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -45,13 +45,17 @@ module CFF
|
|
45
45
|
month.downcase unless month.nil?
|
46
46
|
end.freeze
|
47
47
|
|
48
|
+
# We need to escape these characters in titles and names, as per
|
49
|
+
# https://tex.stackexchange.com/questions/34580/escape-character-in-latex
|
50
|
+
ESCAPE_CHARS = Regexp.new(/([&%$#_{}])/)
|
51
|
+
|
48
52
|
def self.format(model:, preferred_citation: true) # rubocop:disable Metrics
|
49
53
|
model = select_and_check_model(model, preferred_citation)
|
50
54
|
return if model.nil?
|
51
55
|
|
52
56
|
values = {}
|
53
57
|
values['author'] = actor_list(model.authors)
|
54
|
-
values['title'] = "{#{model.title}}"
|
58
|
+
values['title'] = "{#{l(model.title)}}"
|
55
59
|
|
56
60
|
publication_type = bibtex_type(model)
|
57
61
|
publication_data_from_model(model, publication_type, values)
|
@@ -79,7 +83,7 @@ module CFF
|
|
79
83
|
def self.publication_data_from_model(model, type, fields)
|
80
84
|
ENTRY_TYPE_MAP[type].each do |field|
|
81
85
|
if model.respond_to?(field)
|
82
|
-
fields[field] = model.send(field).to_s
|
86
|
+
fields[field] = l(model.send(field).to_s)
|
83
87
|
else
|
84
88
|
field = field.chomp('!')
|
85
89
|
fields[field] = send("#{field}_from_model", model)
|
@@ -108,9 +112,9 @@ module CFF
|
|
108
112
|
# BibTeX 'institution' could be grabbed from an author's affiliation, or
|
109
113
|
# provided explicitly.
|
110
114
|
def self.institution_from_model(model)
|
111
|
-
return model.institution.name unless model.institution.empty?
|
115
|
+
return l(model.institution.name) unless model.institution.empty?
|
112
116
|
|
113
|
-
model.authors.first.affiliation
|
117
|
+
l(model.authors.first.affiliation)
|
114
118
|
end
|
115
119
|
|
116
120
|
# BibTeX 'school' is CFF 'institution'.
|
@@ -125,7 +129,7 @@ module CFF
|
|
125
129
|
|
126
130
|
# BibTeX 'booktitle' is CFF 'collection-title'.
|
127
131
|
def self.booktitle_from_model(model)
|
128
|
-
model.collection_title
|
132
|
+
l(model.collection_title)
|
129
133
|
end
|
130
134
|
|
131
135
|
# BibTeX 'editor' is CFF 'editors' or 'editors-series'.
|
@@ -138,11 +142,11 @@ module CFF
|
|
138
142
|
end
|
139
143
|
|
140
144
|
def self.publisher_from_model(model)
|
141
|
-
model.publisher.empty? ? '' : model.publisher.name
|
145
|
+
model.publisher.empty? ? '' : l(model.publisher.name)
|
142
146
|
end
|
143
147
|
|
144
148
|
def self.series_from_model(model)
|
145
|
-
model.conference.empty? ? '' : model.conference.name
|
149
|
+
model.conference.empty? ? '' : l(model.conference.name)
|
146
150
|
end
|
147
151
|
|
148
152
|
# If we're citing a conference paper, try and use the date of the
|
@@ -182,9 +186,9 @@ module CFF
|
|
182
186
|
end
|
183
187
|
end
|
184
188
|
|
185
|
-
def self.format_actor(author)
|
186
|
-
return "{#{author.name}}" if author.is_a?(Entity)
|
187
|
-
return author.alias if author.family_names.empty? && author.given_names.empty?
|
189
|
+
def self.format_actor(author) # rubocop:disable Metrics/AbcSize
|
190
|
+
return "{#{l(author.name)}}" if author.is_a?(Entity)
|
191
|
+
return l(author.alias) if author.family_names.empty? && author.given_names.empty?
|
188
192
|
|
189
193
|
particle =
|
190
194
|
author.name_particle.empty? ? '' : "#{author.name_particle} "
|
@@ -209,6 +213,12 @@ module CFF
|
|
209
213
|
|
210
214
|
Util.parameterize(reference)
|
211
215
|
end
|
216
|
+
|
217
|
+
# Escape a string to preserve special characters in LaTeX output.
|
218
|
+
# Used in many places, so short method name to preserve reading flow.
|
219
|
+
def self.l(string)
|
220
|
+
string.gsub(ESCAPE_CHARS, '\\\\\1')
|
221
|
+
end
|
212
222
|
end
|
213
223
|
end
|
214
224
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-
|
3
|
+
# Copyright (c) 2018-2023 The Ruby Citation File Format Developers.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -67,16 +67,9 @@ module CFF
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def self.month_and_year_from_date(value)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
begin
|
74
|
-
date = Date.parse(value.to_s)
|
75
|
-
[date.month, date.year].map(&:to_s)
|
76
|
-
rescue ArgumentError
|
77
|
-
['', '']
|
78
|
-
end
|
79
|
-
end
|
70
|
+
return ['', ''] unless value.is_a?(Date)
|
71
|
+
|
72
|
+
[value.month, value.year].map(&:to_s)
|
80
73
|
end
|
81
74
|
|
82
75
|
# CFF 'pages' is the number of pages, which has no equivalent in BibTeX
|
data/lib/cff/model_part.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-
|
3
|
+
# Copyright (c) 2018-2023 The Ruby Citation File Format Developers.
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -59,23 +59,57 @@ module CFF
|
|
59
59
|
symbols.each do |symbol|
|
60
60
|
field = symbol.to_s.tr('_', '-')
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
# date = (date.is_a?(Date) ? date.dup : Date.parse(date))
|
65
|
-
#
|
66
|
-
# @fields['date-end'] = date
|
67
|
-
# end
|
68
|
-
<<-END_SETTER, __FILE__, __LINE__ + 1
|
69
|
-
def #{symbol}=(date)
|
70
|
-
date = (date.is_a?(Date) ? date.dup : Date.parse(date))
|
71
|
-
|
72
|
-
@fields['#{field}'] = date
|
73
|
-
end
|
74
|
-
END_SETTER
|
75
|
-
)
|
62
|
+
date_getter(symbol, field)
|
63
|
+
date_setter(symbol, field)
|
76
64
|
end
|
77
65
|
end
|
78
66
|
|
67
|
+
def self.date_getter(symbol, field)
|
68
|
+
class_eval(
|
69
|
+
# def date_end
|
70
|
+
# date = @fields['date-end']
|
71
|
+
# return date if date.is_a?(Date)
|
72
|
+
#
|
73
|
+
# begin
|
74
|
+
# Date.parse(date)
|
75
|
+
# rescue
|
76
|
+
# ''
|
77
|
+
# end
|
78
|
+
# end
|
79
|
+
<<-END_GETTER, __FILE__, __LINE__ + 1
|
80
|
+
def #{symbol}
|
81
|
+
date = @fields['#{field}']
|
82
|
+
return date if date.is_a?(Date)
|
83
|
+
|
84
|
+
begin
|
85
|
+
Date.parse(date)
|
86
|
+
rescue
|
87
|
+
''
|
88
|
+
end
|
89
|
+
end
|
90
|
+
END_GETTER
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.date_setter(symbol, field)
|
95
|
+
class_eval(
|
96
|
+
# def date_end=(date)
|
97
|
+
# date = (date.is_a?(Date) ? date.dup : Date.parse(date))
|
98
|
+
#
|
99
|
+
# @fields['date-end'] = date
|
100
|
+
# end
|
101
|
+
<<-END_SETTER, __FILE__, __LINE__ + 1
|
102
|
+
def #{symbol}=(date)
|
103
|
+
date = (date.is_a?(Date) ? date.dup : Date.parse(date))
|
104
|
+
|
105
|
+
@fields['#{field}'] = date
|
106
|
+
end
|
107
|
+
END_SETTER
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
private_class_method :date_getter, :date_setter
|
112
|
+
|
79
113
|
private
|
80
114
|
|
81
115
|
def method_to_field(name)
|
data/lib/cff/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Haines
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_schema
|