cff 1.0.0 → 1.1.0

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: a3c050f5d10f432c5f693e34a3e357d6f6cb6354a34f1437e2d002d31260a668
4
- data.tar.gz: 77a28d90a783419770aa706b033fc16895aa33762b1bf1e8d63f283e949b52b8
3
+ metadata.gz: 3516244b4f8ca79e358adb6a561ea0d1007590b1fc34686eff2566444e465381
4
+ data.tar.gz: 6ad965bc59a6acf7cfa1a0737ed97bbd994e4fabdb64551eb7bdef6d32411534
5
5
  SHA512:
6
- metadata.gz: 20af71ee0317e192bccd3cd2a4e8e2be39c8bab84b9c4c74571968b80d519d292b2b7f2564aa5786fe995fddedfa90edea76058e400bd0971b1d805e0256b9ab
7
- data.tar.gz: e38acde51d42a67b37c197c9d03e55fbe2a55ec5f3ee2e2632c1842a6292035831ac55acfd8ded8812bda8dc06d96578b2dcf28870f29f1d6fc0c855df758ba8
6
+ metadata.gz: 822d9b5f9e260d6bec6bbf9fa2891951b10319feca11f5c899431c86143fcdbde0b874ec9fcd598307ffd5b731578f8979d712375f65cfd7092617e5bd3dcf02
7
+ data.tar.gz: 122e43d2a21f50b897204e15d4d497cd95cea23a0de1d25a6efc744ca4316e9c5c09fab681e572e8bf66900a4bd40bcbfdf34ecb19e42168c484ca3bbf852d66
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changes log for the Ruby CFF Library
2
2
 
3
+ ## 1.1.0
4
+
5
+ * BibTeX: output months as three letter abbreviations.
6
+
7
+ ## 1.0.1
8
+
9
+ * Handle missing family or given names for authors.
10
+ * Handle authors with only an alias for a name.
11
+ * Add install instructions to the README.
12
+ * Add a note to the README re output format changes.
13
+
3
14
  ## 1.0.0
4
15
 
5
16
  * Add `type` to top-level CFF model.
data/CITATION.cff CHANGED
@@ -1,4 +1,4 @@
1
- # This CITATION.cff file was created by ruby-cff (v 1.0.0).
1
+ # This CITATION.cff file was created by ruby-cff (v 1.1.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.0.0
24
+ version: 1.1.0
25
25
  doi: 10.5281/zenodo.1184077
26
- date-released: 2022-10-09
26
+ date-released: 2023-04-10
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/README.md CHANGED
@@ -5,7 +5,7 @@ A Ruby library for creating, editing, validating and converting CITATION.cff fil
5
5
 
6
6
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1184077.svg)](https://doi.org/10.5281/zenodo.1184077)
7
7
  [![Gem Version](https://badge.fury.io/rb/cff.svg)](https://badge.fury.io/rb/cff)
8
- [![Tests](https://github.com/citation-file-format/ruby-cff/actions/workflows/ruby.yml/badge.svg)](https://github.com/citation-file-format/ruby-cff/actions/workflows/ruby.yml)
8
+ [![Tests](https://github.com/citation-file-format/ruby-cff/actions/workflows/tests.yml/badge.svg)](https://github.com/citation-file-format/ruby-cff/actions/workflows/ruby.yml)
9
9
  [![Linter](https://github.com/citation-file-format/ruby-cff/actions/workflows/lint.yml/badge.svg)](https://github.com/citation-file-format/ruby-cff/actions/workflows/lint.yml)
10
10
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
11
11
  [![Maintainability](https://api.codeclimate.com/v1/badges/6bb4c661bfb4971260ba/maintainability)](https://codeclimate.com/github/citation-file-format/ruby-cff/maintainability)
@@ -21,6 +21,23 @@ See the [CITATION.cff documentation](https://citation-file-format.github.io/) fo
21
21
 
22
22
  See the [full API documentation](https://citation-file-format.github.io/ruby-cff/) for more details about Ruby CFF.
23
23
 
24
+ ### Installation
25
+
26
+ Add this line to your application's Gemfile:
27
+ ```ruby
28
+ gem 'cff'
29
+ ```
30
+
31
+ And then execute:
32
+ ```shell
33
+ $ bundle
34
+ ```
35
+
36
+ Or install it yourself with:
37
+ ```shell
38
+ $ gem install cff
39
+ ```
40
+
24
41
  ### Quick start
25
42
 
26
43
  You can quickly build and save a CFF index like this:
@@ -192,6 +209,8 @@ Due to the different expectations of different publication venues, the citation
192
209
 
193
210
  From version 1.0.0 onwards, the principles of [semantic versioning](https://semver.org/) are applied when numbering releases with new features or breaking changes.
194
211
 
212
+ Minor or stylistic changes to output formats are not considered "breaking" for the purposes of library versioning.
213
+
195
214
  ### Developing Ruby CFF
196
215
 
197
216
  Please see our [Code of Conduct](https://github.com/citation-file-format/ruby-cff/blob/main/CODE_OF_CONDUCT.md) and our [contributor guidelines](https://github.com/citation-file-format/ruby-cff/blob/main/CONTRIBUTING.md).
@@ -136,9 +136,25 @@ module CFF
136
136
 
137
137
  particle =
138
138
  author.name_particle.empty? ? '' : "#{author.name_particle} "
139
- suffix = author.name_suffix.empty? ? '.' : "., #{author.name_suffix}"
139
+ suffix = author.name_suffix.empty? ? '' : ", #{author.name_suffix}"
140
140
 
141
- "#{particle}#{author.family_names}, #{initials(author.given_names)}#{suffix}"
141
+ "#{particle}#{format_name(author)}#{suffix}"
142
+ end
143
+
144
+ # Format a name using an alias if needs be.
145
+ # https://blog.apastyle.org/apastyle/2012/02/how-to-cite-pseudonyms.html
146
+ def self.format_name(author)
147
+ if author.family_names.empty?
148
+ if author.given_names.empty?
149
+ author.alias
150
+ else
151
+ author.given_names
152
+ end
153
+ elsif author.given_names.empty?
154
+ author.family_names
155
+ else
156
+ "#{author.family_names}, #{initials(author.given_names)}."
157
+ end
142
158
  end
143
159
  end
144
160
  end
@@ -38,7 +38,14 @@ module CFF
38
38
  'unpublished' => %w[doi note!]
39
39
  }.freeze
40
40
 
41
- def self.format(model:, preferred_citation: true) # rubocop:disable Metrics/AbcSize
41
+ # Convert months to three letter abbreviations, as per
42
+ # https://www.bibtex.com/f/month-field/. Need to downcase from the
43
+ # built-in set.
44
+ MONTHS_MAP = Date::ABBR_MONTHNAMES.map do |month|
45
+ month.downcase unless month.nil?
46
+ end.freeze
47
+
48
+ def self.format(model:, preferred_citation: true) # rubocop:disable Metrics
42
49
  model = select_and_check_model(model, preferred_citation)
43
50
  return if model.nil?
44
51
 
@@ -50,7 +57,7 @@ module CFF
50
57
  publication_data_from_model(model, publication_type, values)
51
58
 
52
59
  month, year = month_and_year_from_model(model)
53
- values['month'] = month
60
+ values['month'] = MONTHS_MAP[month.to_i] unless month.empty?
54
61
  values['year'] = year
55
62
 
56
63
  values['url'] = url(model)
@@ -59,7 +66,8 @@ module CFF
59
66
 
60
67
  values.reject! { |_, v| v.empty? }
61
68
  sorted_values = values.sort.map do |key, value|
62
- "#{key} = {#{value}}"
69
+ value = "{#{value}}" unless key == 'month'
70
+ "#{key} = #{value}"
63
71
  end
64
72
  sorted_values.insert(0, generate_citekey(values))
65
73
 
@@ -176,6 +184,7 @@ module CFF
176
184
 
177
185
  def self.format_actor(author)
178
186
  return "{#{author.name}}" if author.is_a?(Entity)
187
+ return author.alias if author.family_names.empty? && author.given_names.empty?
179
188
 
180
189
  particle =
181
190
  author.name_particle.empty? ? '' : "#{author.name_particle} "
data/lib/cff/util.rb CHANGED
@@ -40,9 +40,11 @@ module CFF
40
40
  end
41
41
  end
42
42
 
43
+ # Currently need to make some sort of guess as to whether an actor
44
+ # is a Person or Entity. This isn't perfect, but works 99.99% I think.
43
45
  def build_actor_collection!(source)
44
46
  source.map! do |s|
45
- s.has_key?('given-names') ? Person.new(s) : Entity.new(s)
47
+ s.has_key?('name') ? Entity.new(s) : Person.new(s)
46
48
  end
47
49
  end
48
50
 
data/lib/cff/version.rb CHANGED
@@ -17,7 +17,7 @@
17
17
  ##
18
18
  module CFF
19
19
  # :nodoc:
20
- VERSION = '1.0.0'
20
+ VERSION = '1.1.0'
21
21
  DEFAULT_SPEC_VERSION = '1.2.0'
22
22
  MIN_VALIDATABLE_VERSION = '1.2.0'
23
23
  end
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.0.0
4
+ version: 1.1.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: 2022-10-09 00:00:00.000000000 Z
12
+ date: 2023-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_schema
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  requirements: []
245
- rubygems_version: 3.1.6
245
+ rubygems_version: 3.3.23
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: A Ruby library for manipulating CITATION.cff files.