cff 0.4.0 → 0.8.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: 32661be9e23147731575824f34df12b82dfb6f0560af3fd4d8081958f633cac6
4
- data.tar.gz: 5b525849ff1e6ff1829d70e657852377c88bf0b6e83dffff96dd6cd660fc029b
3
+ metadata.gz: 30519ae0956f0d4221822133c8d638170919f92a3c969af8fc9acf75146f1652
4
+ data.tar.gz: d50b46821a6b7711cadfa8f89628afad29c1c06c0549756c7cbbe2f50fd38507
5
5
  SHA512:
6
- metadata.gz: c1df6fd36b30cdd828d9d80ae183795f9eea5a3691684ed0769bbe75b8bca026ed540611f671341bca8880352f396c727931ceb55865086b8613c016af5a7769
7
- data.tar.gz: 0f3afd7def478528b073c4a9454c804731fe6c50cde9acbcdafa0fdc0d6bfba577ca812fcc34fe0b36732f5b1dafebde2b90940f81c6ddf882ac22754b01b419
6
+ metadata.gz: cf2c30b86d41a0450d0ece7312fb25be248cc434de332178413aea306b67ad0a7a6d5a553c7cffcd971683a224c00727ef5ad815d0e73df5c06c9c8cc3faf723
7
+ data.tar.gz: 9700c2ecf3fcc319bb04037081c653361c8062e35eb772881932bf7025679f5dc3d1907c042d841f2ba40b42efb1416a95a9ecff8361c02b0b74ea0c2f05b3c5
data/CHANGES.md CHANGED
@@ -1,5 +1,73 @@
1
1
  # Changes log for the Ruby CFF Library
2
2
 
3
+ ## Version 0.8.0
4
+
5
+ * Add a comment field to the File class.
6
+ * Update the CITATION.cff file to add a comment.
7
+ * Document the simple fields in Model.
8
+ * Updating Ruby version and dependencies
9
+ * GitHub Actions for CI
10
+ * Update Gemspec to fix security vulnerabilities
11
+ * Implement BibTeX output
12
+ * Implement APA-like output
13
+ * Update the LICENCE and the file headers.
14
+ * Add a linter Action.
15
+ * Adjust fixtures to reflect custom styles
16
+ * Move latest supported ruby to be >= 2.6.
17
+ * Dynamically create tests
18
+ * Use the new `YAML.safe_load` API form.
19
+ * Add a filename to `CFF::File`.
20
+ * Fix invalid references bug
21
+ * Allow time to be loaded from YAML
22
+ * Add `CFF::File.open` which accepts a block.
23
+ * `Model::new` can now accept a block.
24
+ * `Entity::new` can now accept a block.
25
+ * `Person::new` can now accept a block.
26
+ * `Reference::new` can now accept a block.
27
+ * Update README with new `Model` and `File` APIs.
28
+ * Turn on Actions CI for all branches.
29
+ * Turn Coveralls reporting back on after move to Actions.
30
+ * Use `Last, First` format for BibTeX output.
31
+ * Add `BibtexFormatter::generate_reference`.
32
+ * Change DOI links to https in the APA formatter.
33
+ * Set up a GitHub Action to build and deploy the docs.
34
+ * Add metadata to the gemspec.
35
+ * Generalize authorship of the gem a bit.
36
+ * Document `to_*` formatting methods in `Model`.
37
+ * Add `alias` field to `Person`.
38
+ * `Person` no longer requires `given-names` and `family-names`.
39
+ * The `version` field can be a number or a string.
40
+ * Bump default spec version to 1.2.0.
41
+ * Load and parse the CFF schema.
42
+ * Add validation code and supporting infrastructure.
43
+ * Add validation class methods to `CFF::File`.
44
+ * Handle empty fields in `Reference` when reading from files.
45
+ * Add an `Identifier` type.
46
+ * Add the `identifiers` field to the `Model`.
47
+ * Add the `identifiers` field to `Reference`.
48
+ * Update the key complete CFF file in the tests.
49
+ * Ensure `name-particle` is used in BibTex output.
50
+ * Add `preferred-citation` to the `Model`.
51
+ * Load the `Entity` fields in a `Reference` correctly.
52
+ * Preserve title capitalization in BibTeX output.
53
+ * Add `Licensable` mixin.
54
+ * Wire `Licensable` into `Model`.
55
+ * Wire `Licensable` into `Reference`.
56
+ * Use the SPDX licences list in the schema to cross-check.
57
+ * Protect `Entity` names in BibTeX output with `{}`.
58
+ * Add support for `name-suffix` in BibTeX output.
59
+ * Streamline the APA formatter `format_author` method.
60
+ * Streamline BibTeX `generate_reference` method.
61
+ * Streamline the BibTeX `format_author` method.
62
+ * Update `1.2.0` schema.
63
+ * Add `Formatter::month_and_year_from_date` util method.
64
+ * Add `Formatter::url` util method.
65
+ * Simplify `BibtexFormatter::format`.
66
+ * Simplify and improve the APA formatter.
67
+ * Honour `preferred_citation` when outputting citation text.
68
+ * Only use '[Computer software]' label in APA format for software.
69
+ * Map `Reference` types to BibTeX types when formatting.
70
+
3
71
  ## Version 0.4.0
4
72
 
5
73
  * Remove unused Util#expand_field method.
data/CITATION.cff CHANGED
@@ -1,21 +1,26 @@
1
- cff-version: 1.0.3
1
+ # This CITATION.cff file was created by ruby-cff (v 0.8.0).
2
+ # Gem: https://rubygems.org/gems/cff
3
+ # CFF: https://citation-file-format.github.io/
4
+
5
+ cff-version: 1.2.0
2
6
  message: If you use ruby-cff in your work, please cite it using the following metadata
3
7
  title: Ruby CFF Library
4
- abstract: This library provides a Ruby interface to manipulate CITATION.cff files
8
+ abstract: This library provides a Ruby interface to manipulate Citation File Format files
5
9
  authors:
6
10
  - family-names: Haines
7
11
  given-names: Robert
8
12
  orcid: https://orcid.org/0000-0002-9538-7919
9
13
  affiliation: The University of Manchester, UK
14
+ - name: The Ruby Citation File Format Developers
10
15
  keywords:
11
16
  - ruby
12
17
  - credit
13
18
  - citation
14
19
  - metadata
15
20
  - cff
16
- version: 0.4.0
21
+ version: 0.8.0
17
22
  doi: 10.5281/zenodo.1184077
18
- date-released: 2018-07-29
23
+ date-released: 2021-08-08
19
24
  license: Apache-2.0
20
25
  repository-artifact: https://rubygems.org/gems/cff
21
26
  repository-code: https://github.com/citation-file-format/ruby-cff
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
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 [yyyy] [name of copyright owner]
189
+ Copyright (c) 2018-2021 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
@@ -1,44 +1,49 @@
1
1
  # Ruby CFF
2
- ## Robert Haines
2
+ ## Robert Haines and The Ruby Citation File Format Developers
3
3
 
4
- A Ruby library for manipulating CITATION.cff files.
4
+ A Ruby library for creating, editing, validating and converting CITATION.cff files.
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
- [![Build Status](https://travis-ci.org/citation-file-format/ruby-cff.svg?branch=master)](https://travis-ci.org/citation-file-format/ruby-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)
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)
9
10
  [![Maintainability](https://api.codeclimate.com/v1/badges/6bb4c661bfb4971260ba/maintainability)](https://codeclimate.com/github/citation-file-format/ruby-cff/maintainability)
10
11
  [![Coverage Status](https://coveralls.io/repos/github/citation-file-format/ruby-cff/badge.svg)](https://coveralls.io/github/citation-file-format/ruby-cff)
11
12
 
12
13
  ### Synopsis
13
14
 
14
- This library provides a Ruby interface to manipulate CITATION.cff files. The primary entry points are the Model and File classes.
15
+ This library provides a Ruby interface to create and edit Citation File Format (CFF) files. The resulting files can be validated against a formal schema to ensure correctness and can be output in a number of different citation-friendly formats.
15
16
 
16
- See the [CITATION.cff documentation](https://citation-file-format.github.io/) for more details.
17
+ The primary API entry points are the `Model` and `File` classes.
18
+
19
+ See the [CITATION.cff documentation](https://citation-file-format.github.io/) for more details about the Citation File Format.
20
+
21
+ See the [full API documentation](https://citation-file-format.github.io/ruby-cff/) for more details about Ruby CFF.
17
22
 
18
23
  ### Quick start
19
24
 
25
+ You can quickly build and save a CFF model like this:
26
+
20
27
  ```ruby
21
- cff = CFF::Model.new("Ruby CFF Library")
22
- cff.version = CFF::VERSION
23
- cff.date_released = Date.today
24
- cff.authors << CFF::Person.new("Robert", "Haines")
25
- cff.license = "Apache-2.0"
26
- cff.keywords << "ruby" << "credit" << "citation"
27
- cff.repository_artifact = "https://rubygems.org/gems/cff"
28
+ model = CFF::Model.new('Ruby CFF Library') do |cff|
29
+ cff.version = CFF::VERSION
30
+ cff.date_released = Date.today
31
+ cff.authors << CFF::Person.new('Robert', 'Haines')
32
+ cff.license = 'Apache-2.0'
33
+ cff.keywords << 'ruby' << 'credit' << 'citation'
34
+ cff.repository_artifact = 'https://rubygems.org/gems/cff'
35
+ cff.repository_code = 'https://github.com/citation-file-format/ruby-cff'
36
+ end
28
37
 
29
- CFF::File.write("CITATION.cff", cff)
38
+ CFF::File.write('CITATION.cff', model)
30
39
  ```
31
40
 
32
- Will produce a file that looks something like this:
41
+ Which will produce a file that looks something like this:
33
42
 
34
- ```
35
- cff-version: 1.0.3
43
+ ```yaml
44
+ cff-version: 1.2.0
36
45
  message: If you use this software in your work, please cite it using the following metadata
37
46
  title: Ruby CFF Library
38
- version: 0.3.0
39
- date-released: 2018-03-04
40
- license: Apache-2.0
41
- repository-artifact: https://rubygems.org/gems/cff
42
47
  authors:
43
48
  - family-names: Haines
44
49
  given-names: Robert
@@ -46,8 +51,107 @@ keywords:
46
51
  - ruby
47
52
  - credit
48
53
  - citation
54
+ version: 0.8.0
55
+ date-released: 2021-08-08
56
+ license: Apache-2.0
57
+ repository-artifact: https://rubygems.org/gems/cff
58
+ repository-code: https://github.com/citation-file-format/ruby-cff
59
+ ```
60
+
61
+ `CFF::File` can be used to create a file directly, and it exposes the underlying `CFF::Model` directly. If using a block with `CFF::File::open` the file will get written on closing it:
62
+
63
+ ```ruby
64
+ CFF::File.open('CITATION.cff') do |cff|
65
+ cff.version = CFF::VERSION
66
+ cff.date_released = Date.today
67
+ cff.authors << CFF::Person.new('Robert', 'Haines')
68
+ cff.license = 'Apache-2.0'
69
+ cff.keywords << 'ruby' << 'credit' << 'citation'
70
+ cff.repository_artifact = 'https://rubygems.org/gems/cff'
71
+ cff.repository_code = 'https://github.com/citation-file-format/ruby-cff'
72
+ end
73
+ ```
74
+
75
+ ### Validating CFF files
76
+
77
+ To quickly validate a file and raise an error on failure, you can use `CFF::File` directly:
78
+
79
+ ```ruby
80
+ begin
81
+ CFF::File.validate!('CITATION.cff')
82
+ rescue CFF::ValidationError => e
83
+ # Handle validation errors here...
84
+ end
85
+ ```
86
+
87
+ Both `CFF::File` and `CFF::Model` have instance methods to validate CFF files as well:
88
+
89
+ ```ruby
90
+ cff = CFF::File.read('CITATION.cff')
91
+ begin
92
+ cff.validate!(fail_fast: true)
93
+ rescue CFF::ValidationError => e
94
+ # Handle validation errors here...
95
+ end
96
+ ```
97
+
98
+ Non-bang methods (`validate`) return a two-element array, with `true`/`false` at index 0 to indicate pass/fail, and an array of errors at index 1 (if any).
99
+
100
+ Passing `fail_fast: true` (default: `false`) will cause the validator to abort on the first error it encounters and report just that. Only the instance methods on `CFF::File` and `CFF::Model` provide the `fail_fast` option.
101
+
102
+ ### Outputting citation text
103
+
104
+ This library can use CFF data to output text suitable for use when citing software. Currently the output formats supported are:
105
+
106
+ * BibTeX; and
107
+ * an APA-like format.
108
+
109
+ You can use this feature as follows:
110
+ ```ruby
111
+ cff = CFF::File.read('CITATION.cff')
112
+
113
+ cff.to_bibtex
114
+ cff.to_apalike
115
+ ```
116
+
117
+ These methods assume that the CFF data is valid - see the notes on validation above.
118
+
119
+ Assuming the same CFF data as above, the two formats will look something like this:
120
+
121
+ #### BibTeX format
122
+
123
+ ```tex
124
+ @misc{Haines_Ruby_CFF_Library_2021,
125
+ author = {Haines, Robert},
126
+ month = {8},
127
+ title = {{Ruby CFF Library}},
128
+ url = {https://github.com/citation-file-format/ruby-cff},
129
+ year = {2021}
130
+ }
131
+ ```
132
+
133
+ #### APA-like format
134
+
135
+ ```
136
+ Haines, R. (2021). Ruby CFF Library (Version 0.8.0) [Computer software]. https://github.com/citation-file-format/ruby-cff
49
137
  ```
50
138
 
139
+ #### Citing a paper rather than software
140
+
141
+ The CFF has been designed with direct citation of software in mind. We'd like software to be considered a first-class research output, like journal articles and conference papers. If you would rather that your citation text points to a paper that describes your software, rather than the software itself, you can use the `preferred-citation` field for that paper. When producing citation text this library will honour `preferred-citation`, if present, by default. If you would like to specify a `preferred-citation` and still produce a direct citation to the software then you can configure the formatter as follows:
142
+
143
+ ```ruby
144
+ cff = CFF::File.read('CITATION.cff')
145
+
146
+ cff.to_bibtex(preferred_citation: false)
147
+ cff.to_apalike(preferred_citation: false)
148
+
149
+ ```
150
+
151
+ #### A note on citation formats
152
+
153
+ 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 please [let us know](https://github.com/citation-file-format/ruby-cff/issues).
154
+
51
155
  ### Library versions
52
156
 
53
157
  Until this library reaches version 1.0.0 the API may be subject to breaking changes. When version 1.0.0 is released, then the principles of [semantic versioning](https://semver.org/) will be applied.
@@ -55,3 +159,15 @@ Until this library reaches version 1.0.0 the API may be subject to breaking chan
55
159
  ### Licence
56
160
 
57
161
  [Apache 2.0](http://www.apache.org/licenses/). See LICENCE for details.
162
+
163
+ ### Research notice
164
+
165
+ Please note that this repository is participating in a study into sustainability
166
+ of open source projects. Data will be gathered about this repository for
167
+ approximately the next 12 months, starting from June 2021.
168
+
169
+ Data collected will include number of contributors, number of PRs, time taken to
170
+ close/merge these PRs, and issues closed.
171
+
172
+ For more information, please visit
173
+ [our informational page](https://sustainable-open-science-and-software.github.io/) or download our [participant information sheet](https://sustainable-open-science-and-software.github.io/assets/PIS_sustainable_software.pdf).
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2018 Robert Haines.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'cff'
data/cff.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2018 Robert Haines.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -12,14 +14,15 @@
12
14
  # See the License for the specific language governing permissions and
13
15
  # limitations under the License.
14
16
 
15
- lib = File.expand_path('lib', __dir__)
16
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
17
- require 'cff/version'
17
+ require_relative 'lib/cff/version'
18
18
 
19
19
  Gem::Specification.new do |spec|
20
20
  spec.name = 'cff'
21
21
  spec.version = CFF::VERSION
22
- spec.authors = ['Robert Haines']
22
+ spec.authors = [
23
+ 'Robert Haines',
24
+ 'The Ruby Citation File Format Developers'
25
+ ]
23
26
  spec.email = ['robert.haines@manchester.ac.uk']
24
27
 
25
28
  spec.summary = 'A Ruby library for manipulating CITATION.cff files.'
@@ -28,23 +31,34 @@ Gem::Specification.new do |spec|
28
31
  spec.homepage = 'https://github.com/citation-file-format/ruby-cff'
29
32
  spec.license = 'Apache-2.0'
30
33
 
31
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
34
+ spec.metadata = {
35
+ 'bug_tracker_uri' => 'https://github.com/citation-file-format/ruby-cff/issues',
36
+ 'changelog_uri' => 'https://github.com/citation-file-format/ruby-cff/blob/main/CHANGES.md',
37
+ 'documentation_uri' => 'https://citation-file-format.github.io/ruby-cff/',
38
+ 'source_code_uri' => 'https://github.com/citation-file-format/ruby-cff'
39
+ }
40
+
41
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
32
42
  f.match(%r{^((test|spec|features)/|\.)})
33
43
  end
44
+
34
45
  spec.bindir = 'exe'
35
46
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
47
  spec.require_paths = ['lib']
37
48
 
38
- spec.required_ruby_version = '>= 2.2.0'
49
+ spec.required_ruby_version = '>= 2.6'
39
50
 
51
+ spec.add_runtime_dependency 'json_schema', '~> 0.21.0'
40
52
  spec.add_runtime_dependency 'language_list', '~> 1.2'
41
- spec.add_runtime_dependency 'spdx-licenses', '~> 1.1'
42
-
43
- spec.add_development_dependency 'bundler', '~> 1.16'
44
- spec.add_development_dependency 'coveralls', '~> 0.8'
45
- spec.add_development_dependency 'minitest', '~> 5.0'
46
- spec.add_development_dependency 'rake', '~> 10.0'
47
- spec.add_development_dependency 'rdoc', '~> 6.0'
48
- spec.add_development_dependency 'rubocop', '~> 0.54'
53
+
54
+ spec.add_development_dependency 'minitest', '~> 5.14'
55
+ spec.add_development_dependency 'rake', '~> 13.0'
56
+ spec.add_development_dependency 'rdoc', '~> 6.3'
57
+ spec.add_development_dependency 'rubocop', '~> 1.15'
58
+ spec.add_development_dependency 'rubocop-minitest', '~> 0.13'
59
+ spec.add_development_dependency 'rubocop-performance', '~> 1.11.0'
60
+ spec.add_development_dependency 'rubocop-rake', '~> 0.5.0'
61
+ spec.add_development_dependency 'simplecov', '~> 0.20.0'
62
+ spec.add_development_dependency 'simplecov-lcov', '~> 0.8.0'
49
63
  spec.add_development_dependency 'test_construct', '~> 2.0'
50
64
  end
data/lib/cff.rb CHANGED
@@ -1,4 +1,6 @@
1
- # Copyright (c) 2018 Robert Haines.
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2018-2021 The Ruby Citation File Format Developers.
2
4
  #
3
5
  # Licensed under the Apache License, Version 2.0 (the "License");
4
6
  # you may not use this file except in compliance with the License.
@@ -13,23 +15,33 @@
13
15
  # limitations under the License.
14
16
 
15
17
  require 'date'
18
+ require 'json'
16
19
  require 'yaml'
20
+
17
21
  require 'language_list'
18
- require 'spdx-licenses'
22
+
23
+ # This library provides a Ruby interface to manipulate CITATION.cff files. The
24
+ # primary entry points are Model and File.
25
+ #
26
+ # See the [CITATION.cff documentation](https://citation-file-format.github.io/)
27
+ # for more details.
28
+ module CFF
29
+ SCHEMA_PATH = ::File.join(__dir__, 'schema', '1.2.0.json') # :nodoc:
30
+ SCHEMA_FILE = JSON.parse(::File.read(SCHEMA_PATH)) # :nodoc:
31
+ end
19
32
 
20
33
  require 'cff/version'
34
+ require 'cff/errors'
21
35
  require 'cff/util'
36
+ require 'cff/licensable'
37
+ require 'cff/validatable'
22
38
  require 'cff/model_part'
23
39
  require 'cff/person'
24
40
  require 'cff/entity'
41
+ require 'cff/identifier'
25
42
  require 'cff/reference'
26
43
  require 'cff/model'
27
44
  require 'cff/file'
28
-
29
- # This library provides a Ruby interface to manipulate CITATION.cff files. The
30
- # primary entry points are Model and File.
31
- #
32
- # See the [CITATION.cff documentation](https://citation-file-format.github.io/)
33
- # for more details.
34
- module CFF
35
- end
45
+ require 'cff/formatter/formatter'
46
+ require 'cff/formatter/apa_formatter'
47
+ require 'cff/formatter/bibtex_formatter'