cff
A Ruby library for manipulating CITATION.cff files.
Science Score: 77.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 3 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
2 of 10 committers (20.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.6%) to scientific vocabulary
Keywords
Repository
A Ruby library for manipulating CITATION.cff files.
Basic Info
Statistics
- Stars: 54
- Watchers: 3
- Forks: 19
- Open Issues: 11
- Releases: 8
Topics
Metadata Files
README.md
Ruby CFF
Robert Haines and The Ruby Citation File Format Developers
A Ruby library for creating, editing, validating and converting CITATION.cff files.
Synopsis
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.
The primary API entry points are the Index and File classes.
See the CITATION.cff documentation for more details about the Citation File Format.
See the full API documentation for more details about Ruby CFF.
Installation
Add this line to your application's Gemfile:
ruby
gem 'cff'
And then execute:
shell
$ bundle
Or install it yourself with:
shell
$ gem install cff
Quick start
You can quickly build and save a CFF index like this:
```ruby index = CFF::Index.new('Ruby CFF Library') do |cff| cff.version = CFF::VERSION cff.datereleased = Date.today cff.authors << CFF::Person.new('Robert', 'Haines') cff.license = 'Apache-2.0' cff.keywords << 'ruby' << 'credit' << 'citation' cff.repositoryartifact = 'https://rubygems.org/gems/cff' cff.repository_code = 'https://github.com/citation-file-format/ruby-cff' end
CFF::File.write('CITATION.cff', index) ```
Which will produce a file that looks something like this:
yaml
cff-version: 1.2.0
message: If you use this software in your work, please cite it using the following metadata
title: Ruby CFF Library
authors:
- family-names: Haines
given-names: Robert
keywords:
- ruby
- credit
- citation
version: 1.0.0
date-released: 2022-10-01
license: Apache-2.0
repository-artifact: https://rubygems.org/gems/cff
repository-code: https://github.com/citation-file-format/ruby-cff
CFF::File can be used to create a file directly, and it exposes the underlying CFF::Index directly. If using a block with CFF::File::open the file will get written on closing it:
ruby
CFF::File.open('CITATION.cff') do |cff|
cff.version = CFF::VERSION
cff.date_released = Date.today
cff.authors << CFF::Person.new('Robert', 'Haines')
cff.license = 'Apache-2.0'
cff.keywords << 'ruby' << 'credit' << 'citation'
cff.repository_artifact = 'https://rubygems.org/gems/cff'
cff.repository_code = 'https://github.com/citation-file-format/ruby-cff'
end
You can read a CFF file quickly with CFF::File::read:
ruby
cff = CFF::File.read('CITATION.cff')
And you can read a CFF file from memory with CFF::Index::read or CFF::Index::open - as with CFF::File a block can be passed in to open:
```ruby cffstring = ::File.read('CITATION.cff') cff = CFF::Index.read(cffstring)
CFF::Index.open(cff_string) do |cff| # Edit cff here... end ```
To quickly reference other software from your own CFF file, you can use CFF::Reference.from_cff. This example uses the CFF file from the core CFF repository as a reference for the Ruby CFF repository:
```ruby require 'open-uri'
uri = 'https://raw.githubusercontent.com/citation-file-format/citation-file-format/main/CITATION.cff' other_cff = URI(uri).open.read
ref = CFF::Reference.fromcff(CFF::Index.read(othercff))
CFF::File.open('CITATION.cff') do |cff| cff.references = [ref] end ```
Notes on CFF files with YAML anchors and aliases
Ruby CFF can read files that use YAML anchors and aliases. An anchor (&<label>) identifies a section of your file for reuse elsewhere. An alias (*<label>) is then used to mark where you want that section to be repeated. In this example, the &authors anchor marks an author list for reuse wherever the *authors alias is used:
```yaml cff-version: 1.2.0 title: Ruby CFF Library authors: &authors - family-names: Haines given-names: Robert affiliation: The University of Manchester, UK
...
references: - type: software title: Citation File Format authors: *authors ```
Ruby uses a single object to represent all aliases of an anchor. This means that once the above has been read in by Ruby CFF, if you add an author to either the top-level author list, or the author list in the reference, the new author will appear in both places. With this in mind, you should only use anchors and aliases where the relationship between sections is such that you are sure that exact repetition will always make sense.
When saving CFF files that use anchors and aliases the underlying YAML library will not preserve their names. For example, if the above is loaded into Ruby CFF and then immediately saved &authors/*authors will most likely become &1/*1.
Validating CFF files
To quickly validate a file and raise an error on failure, you can use CFF::File directly:
ruby
begin
CFF::File.validate!('CITATION.cff')
rescue CFF::ValidationError => e
# Handle validation errors here...
end
Both CFF::File and CFF::Index have instance methods to validate CFF files as well:
ruby
cff = CFF::File.read('CITATION.cff')
begin
cff.validate!(fail_fast: true)
rescue CFF::ValidationError => e
# Handle validation errors here...
end
Non-bang methods (validate) return an array, with true/false at index 0 to indicate pass/fail, and an array of errors at index 1 (if any).
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::Index provide the fail_fast option.
The validation methods (both class and instance) on File also validate the filename of a CFF file; in normal circumstances a CFF file should be named 'CITATION.cff'. You can switch this behaviour off by passing fail_on_filename: false. The non-bang methods (validate) on File return an extra value in the result array: true/false at index 2 to indicate whether the filename passed/failed validation.
Outputting citation text
This library can use CFF data to output text suitable for use when citing software. Currently the output formats supported are:
- BibTeX; and
- an APA-like format.
You can use this feature as follows: ```ruby cff = CFF::File.read('CITATION.cff')
cff.tobibtex cff.toapalike ```
These methods assume that the CFF data is valid - see the notes on validation above.
Assuming the same CFF data as above, the two formats will look something like this:
BibTeX format
tex
@software{Haines_Ruby_CFF_Library_2022,
author = {Haines, Robert},
license = {Apache-2.0},
month = {10},
title = {{Ruby CFF Library}},
url = {https://github.com/citation-file-format/ruby-cff},
version = {1.0.0},
year = {2022}
}
APA-like format
Haines, R. (2022). Ruby CFF Library (Version 1.0.0) [Computer software]. https://github.com/citation-file-format/ruby-cff
Citing a paper rather than software
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:
```ruby cff = CFF::File.read('CITATION.cff')
cff.tobibtex(preferredcitation: false) cff.toapalike(preferredcitation: false) ```
A note on citation formats
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, but please check against the BibTeX and APA standards first.
Library versions
From version 1.0.0 onwards, the principles of semantic versioning are applied when numbering releases with new features or breaking changes.
Minor or stylistic changes to output formats are not considered "breaking" for the purposes of library versioning.
Developing Ruby CFF
Please see our Code of Conduct and our contributor guidelines.
Licence
Apache 2.0. See LICENCE for details.
Research notice
Please note that this repository is participating in a study into sustainability of open source projects. Data will be gathered about this repository for approximately the next 12 months, starting from June 2021.
Data collected will include number of contributors, number of PRs, time taken to close/merge these PRs, and issues closed.
For more information, please visit our informational page or download our participant information sheet.
Owner
- Name: citation-file-format
- Login: citation-file-format
- Kind: organization
- Repositories: 13
- Profile: https://github.com/citation-file-format
Citation (CITATION.cff)
# This CITATION.cff file was created by ruby-cff (v 1.3.0).
# Gem: https://rubygems.org/gems/cff
# CFF: https://citation-file-format.github.io/
cff-version: 1.2.0
message: If you use ruby-cff in your work, please cite it using the following metadata
title: Ruby CFF Library
abstract: This library provides a Ruby interface to manipulate Citation File Format files
authors:
- family-names: Haines
given-names: Robert
orcid: https://orcid.org/0000-0002-9538-7919
affiliation: The University of Manchester, UK
- name: The Ruby Citation File Format Developers
keywords:
- ruby
- credit
- software citation
- research software
- software sustainability
- metadata
- citation file format
- CFF
version: 1.3.0
doi: 10.5281/zenodo.1184077
date-released: 2024-10-26
license: Apache-2.0
repository-artifact: https://rubygems.org/gems/cff
repository-code: https://github.com/citation-file-format/ruby-cff
references:
- type: software
title: Citation File Format
authors:
- family-names: Druskat
given-names: Stephan
orcid: https://orcid.org/0000-0003-4925-7248
- family-names: Spaaks
given-names: Jurriaan H.
orcid: https://orcid.org/0000-0002-7064-4069
- family-names: Chue Hong
given-names: Neil
orcid: https://orcid.org/0000-0002-8876-7606
- family-names: Haines
given-names: Robert
orcid: https://orcid.org/0000-0002-9538-7919
- family-names: Baker
given-names: James
orcid: https://orcid.org/0000-0002-2682-6922
- family-names: Bliven
given-names: Spencer
orcid: https://orcid.org/0000-0002-1200-1698
email: spencer.bliven@gmail.com
- family-names: Willighagen
given-names: Egon
orcid: https://orcid.org/0000-0001-7542-0286
- family-names: Pérez-Suárez
given-names: David
orcid: https://orcid.org/0000-0003-0784-6909
website: https://dpshelio.github.io
- family-names: Konovalov
given-names: Alexander
orcid: https://orcid.org/0000-0001-5299-3292
identifiers:
- type: doi
value: 10.5281/zenodo.1003149
description: The concept DOI for the collection containing all versions of the Citation File Format.
- type: doi
value: 10.5281/zenodo.5171937
description: The versioned DOI for the version 1.2.0 of the Citation File Format.
keywords:
- citation file format
- CFF
- citation files
- software citation
- file format
- YAML
- software sustainability
- research software
- credit
abstract: CITATION.cff files are plain text files with human- and machine-readable citation information for software. Code developers can include them in their repositories to let others know how to correctly cite their software. This is the specification for the Citation File Format.
date-released: 2021-08-09
license: CC-BY-4.0
version: 1.2.0
GitHub Events
Total
- Issues event: 3
- Watch event: 4
- Delete event: 1
- Issue comment event: 7
- Push event: 3
- Pull request event: 1
- Pull request review event: 1
- Fork event: 3
- Create event: 2
Last Year
- Issues event: 3
- Watch event: 4
- Delete event: 1
- Issue comment event: 7
- Push event: 3
- Pull request event: 1
- Pull request review event: 1
- Fork event: 3
- Create event: 2
Committers
Last synced: almost 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Robert Haines | r****s@m****k | 470 |
| Patrick Dinger | p****s@g****m | 23 |
| Arfon Smith | a****n@g****m | 9 |
| Jonathan Chan | j****z@c****a | 4 |
| HParker | H****r@g****m | 2 |
| Dorian Marié | d****n@d****r | 1 |
| Oliver Strickson | o****2 | 1 |
| Stephan Druskat | s****t | 1 |
| Thomas Morrell | t****l | 1 |
| Yo Yehudi | y****h@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 80
- Total pull requests: 31
- Average time to close issues: 3 months
- Average time to close pull requests: about 1 month
- Total issue authors: 39
- Total pull request authors: 11
- Average comments per issue: 3.41
- Average comments per pull request: 2.97
- Merged pull requests: 25
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 2
- Pull requests: 1
- Average time to close issues: 3 days
- Average time to close pull requests: N/A
- Issue authors: 2
- Pull request authors: 1
- Average comments per issue: 4.5
- Average comments per pull request: 0.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- hainesr (36)
- mr-c (3)
- arfon (3)
- mfenner (2)
- sdruskat (2)
- 1kastner (1)
- HannesWuensche (1)
- ddsjoberg (1)
- AdrienCorenflos (1)
- tvercaut (1)
- tmorrell (1)
- h4iku (1)
- olebole (1)
- zyrikby (1)
- B3J4y (1)
Pull Request Authors
- hainesr (15)
- arfon (4)
- HParker (3)
- paxos (2)
- ots22 (1)
- mfenner (1)
- SaaSCh (1)
- tmorrell (1)
- dorianmariefr (1)
- ionathanch (1)
- yochannah (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- rubygems 32,688 total
- Total dependent packages: 1
- Total dependent repositories: 4
- Total versions: 11
- Total maintainers: 1
rubygems.org: cff
See https://citation-file-format.github.io/ for more info.
- Homepage: https://github.com/citation-file-format/ruby-cff
- Documentation: http://www.rubydoc.info/gems/cff/
- License: Apache-2.0
-
Latest release: 1.3.0
published about 1 year ago
Rankings
Maintainers (1)
Dependencies
- minitest ~> 5.14 development
- rake ~> 13.0 development
- rdoc ~> 6.3.2 development
- rubocop ~> 1.25.0 development
- rubocop-minitest ~> 0.17.0 development
- rubocop-performance ~> 1.11.0 development
- rubocop-rake ~> 0.5.0 development
- simplecov ~> 0.20.0 development
- simplecov-lcov ~> 0.8.0 development
- test_construct ~> 2.0 development
- json_schema ~> 0.20.0
- language_list ~> 1.2
- JamesIves/github-pages-deploy-action v4 composite
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
- actions/checkout v3 composite
- ruby/setup-ruby v1 composite
- actions/checkout v3 composite
- coverallsapp/github-action master composite
- ruby/setup-ruby v1 composite