briard 2.2 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 277672725deb5879eab67ba97ad3790a8af6444e3ff1d16f95c174f3f6229c8d
4
- data.tar.gz: ea82a2e0a0cb6e1ecbdc85fae4502111dfc0b2c6a6e7a87ad8af0dea89def161
3
+ metadata.gz: 349614e729e9bd290b3ca0c48eb91d49043e182a207bbbbfbfd7e1657348d362
4
+ data.tar.gz: f70c334067e2da787d68fccc1cdeb0100fc0de03c927f2eac88f63c37a598f78
5
5
  SHA512:
6
- metadata.gz: d6172b62c3f60e047b0c11204d452919f7ce4a6348f50ecc8dafd2117c920600b06c2508d0af018d0aa88b8c96d0138978f0efdd8d8ce9ad621a91e4db296118
7
- data.tar.gz: 881202c95ffad90050b687a581ffc87861397c7d861e47b898e609589243b7d3c773a8597004f54794899a8a917ea10827bf2350d64e78513a21fb39a496c916
6
+ metadata.gz: eb860b30e945398009874041f24e5ae5406db7d3e673cff493f5546ea4e867a582f5446f107026e9b1a3487b239b5c388090a4249c7311c77c709243cf9bfdb7
7
+ data.tar.gz: 445a74956b47895317231d9b231c9a1e43a0c12f5981cae4e0ffe804d74342e7adf56d1ead143732ff73acbdb6f2aac74bb0e249122f5cdda15b349b0e512066
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2](https://github.com/front-matter/briard/tree/2.2) (2021-12-07)
4
+
5
+ [Full Changelog](https://github.com/front-matter/briard/compare/2.1...2.2)
6
+
3
7
  ## [2.1](https://github.com/front-matter/briard/tree/2.1) (2021-12-07)
4
8
 
5
9
  [Full Changelog](https://github.com/front-matter/briard/compare/2.0.2...2.1)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- briard (2.2)
4
+ briard (2.2.1)
5
5
  activesupport (>= 4.2.5)
6
6
  benchmark_methods (~> 0.7)
7
7
  bibtex-ruby (>= 5.1.0)
@@ -49,7 +49,8 @@ module Briard
49
49
  sum
50
50
  end
51
51
 
52
- titles = meta.fetch("title", nil).present? ? [{ "title" => meta.fetch("title", nil) }] : []
52
+ titles = meta.fetch("title", nil).present? ? [{ "title" => meta.fetch("title", nil) }] : []
53
+ related_identifiers = Array.wrap(cff_references(meta.fetch("references", nil)))
53
54
  rights_list = meta.fetch("license", nil).present? ? [hsh_to_spdx("rightsIdentifier" => meta.fetch("license"))] : nil
54
55
 
55
56
  { "id" => id,
@@ -60,6 +61,7 @@ module Briard
60
61
  "titles" => titles,
61
62
  "creators" => creators,
62
63
  "publisher" => publisher,
64
+ "related_identifiers" => related_identifiers,
63
65
  "dates" => dates,
64
66
  "publication_year" => publication_year,
65
67
  "descriptions" => meta.fetch("abstract", nil).present? ? [{ "description" => sanitize(meta.fetch("abstract")), "descriptionType" => "Abstract" }] : nil,
@@ -73,7 +75,7 @@ module Briard
73
75
  def cff_creators(creators)
74
76
  Array.wrap(creators).map do |a|
75
77
  name_identifiers = normalize_orcid(parse_attributes(a["orcid"])).present? ? [{ "nameIdentifier" => normalize_orcid(parse_attributes(a["orcid"])), "nameIdentifierScheme" => "ORCID", "schemeUri"=>"https://orcid.org" }] : nil
76
- if a["given-names"].present? || name_identifiers.present?
78
+ if a["given-names"].present? || a["family-names"].present? || name_identifiers.present?
77
79
  given_name = parse_attributes(a["given-names"])
78
80
  family_name = parse_attributes(a["family-names"])
79
81
  affiliation = Array.wrap(a["affiliation"]).map do |a|
@@ -102,6 +104,20 @@ module Briard
102
104
  end
103
105
  end
104
106
  end
107
+
108
+ def cff_references(references)
109
+ Array.wrap(references).map do |r|
110
+ identifier = Array.wrap(r["identifiers"]).find { |i| i["type"] == "doi" }
111
+
112
+ if identifier.present?
113
+ { "relatedIdentifier" => normalize_id(parse_attributes(identifier["value"])),
114
+ "relationType" => "References",
115
+ "relatedIdentifierType" => "DOI" }.compact
116
+ else
117
+ nil
118
+ end
119
+ end.compact.unwrap
120
+ end
105
121
  end
106
122
  end
107
123
  end
@@ -1,3 +1,3 @@
1
1
  module Briard
2
- VERSION = "2.2"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -8,20 +8,47 @@ module Briard
8
8
 
9
9
  # only use CFF for software
10
10
  return nil unless types["resourceTypeGeneral"] == "Software"
11
+
12
+ title = parse_attributes(titles, content: "title", first: true)
11
13
 
12
14
  hsh = {
15
+ "cff-version" => "1.2.0",
16
+ "message" => "If you use #{title} in your work, please cite it using the following metadata",
13
17
  "doi" => normalize_doi(doi),
14
18
  "repository-code" => url,
15
19
  "title" => parse_attributes(titles, content: "title", first: true),
16
- "authors" => creators,
20
+ "authors" => write_cff_creators(creators),
17
21
  "abstract" => parse_attributes(descriptions, content: "description", first: true),
18
22
  "version" => version_info,
19
23
  "keywords" => subjects.present? ? Array.wrap(subjects).map { |k| parse_attributes(k, content: "subject", first: true) } : nil,
20
24
  "date-released" => get_date(dates, "Issued") || publication_year,
21
- "license" => Array.wrap(rights_list).map { |l| l["rightsUri"] }.compact.unwrap,
25
+ "license" => Array.wrap(rights_list).map { |l| l["rightsIdentifier"] }.compact.unwrap,
26
+ "references" => write_references(related_identifiers)
22
27
  }.compact
23
28
  hsh.to_yaml
24
29
  end
30
+
31
+ def write_cff_creators(creators)
32
+ Array.wrap(creators).map do |a|
33
+ if a["givenName"].present? || a["nameIdentifiers"].present?
34
+ { "given-names" => a["givenName"],
35
+ "family-names" => a["familyName"],
36
+ "orcid" => parse_attributes(a["nameIdentifiers"], content: "nameIdentifier", first: true),
37
+ "affiliation" => parse_attributes(a["affiliation"], content: "name", first: true) }.compact
38
+ else
39
+ { "name" => a["name"] }
40
+ end
41
+ end
42
+ end
43
+
44
+ def write_references(related_identifiers)
45
+ { "identifiers" =>
46
+ Array.wrap(related_identifiers).map do |r|
47
+ {
48
+ "type" => r["relatedIdentifierType"].downcase,
49
+ "value" => r["relatedIdentifierType"] == "DOI" ? doi_from_url(r["relatedIdentifier"]) : r["relatedIdentifier"] }
50
+ end }
51
+ end
25
52
  end
26
53
  end
27
54
  end
@@ -0,0 +1,75 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://raw.githubusercontent.com/citation-file-format/ruby-cff/main/CITATION.cff
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Mozilla/5.0 (compatible; Maremma/4.9.6; mailto:info@front-matter.io)
12
+ Accept:
13
+ - application/json;charset=UTF-8
14
+ Accept-Encoding:
15
+ - gzip,deflate
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Connection:
22
+ - keep-alive
23
+ Content-Length:
24
+ - '1100'
25
+ Cache-Control:
26
+ - max-age=300
27
+ Content-Security-Policy:
28
+ - default-src 'none'; style-src 'unsafe-inline'; sandbox
29
+ Content-Type:
30
+ - text/plain; charset=utf-8
31
+ Etag:
32
+ - W/"0c65d88dd50bd96382850237735a8e2d6c0826d4497c8aafd6c28a2bacdb4127"
33
+ Strict-Transport-Security:
34
+ - max-age=31536000
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Frame-Options:
38
+ - deny
39
+ X-Xss-Protection:
40
+ - 1; mode=block
41
+ X-Github-Request-Id:
42
+ - C94A:D42F:40C4B0:4FF047:61AF689B
43
+ Content-Encoding:
44
+ - gzip
45
+ Accept-Ranges:
46
+ - bytes
47
+ Date:
48
+ - Tue, 07 Dec 2021 13:58:52 GMT
49
+ Via:
50
+ - 1.1 varnish
51
+ X-Served-By:
52
+ - cache-hhn4041-HHN
53
+ X-Cache:
54
+ - MISS
55
+ X-Cache-Hits:
56
+ - '0'
57
+ X-Timer:
58
+ - S1638885532.881150,VS0,VE231
59
+ Vary:
60
+ - Authorization,Accept-Encoding,Origin
61
+ Access-Control-Allow-Origin:
62
+ - "*"
63
+ X-Fastly-Request-Id:
64
+ - 226be732c5d156ff9846cc2a7b43c4ec2f4643b9
65
+ Expires:
66
+ - Tue, 07 Dec 2021 14:03:52 GMT
67
+ Source-Age:
68
+ - '0'
69
+ body:
70
+ encoding: ASCII-8BIT
71
+ string: !binary |-
72
+ H4sIAAAAAAAAA5VW247bNhB911cMkJcWCGVJ67UkP3Xj7Xa3uRXZDYo80tLIIkyLAknZcf4mj/2O/FiHlC9bW0lcw4ZkcjjXwznzAp5qYWD28HTz9PD+XVhUFVRCImy4gUIjt1jCfAu6m2+Z2/xlDVGYh9GvYfAC/sDVFGprWzMdjZzIAlcmVHoxci8jkieh2d3dUagQlluhGuaMsErpFbfhQti6m4dCjYKAzrA1akMyU4jDJIyCFRrDFziFhwq2qoPO4NEf0bg1DRully+hlchpl6wgCEuSolmArREqJaXauH8rtLzklgdWWElKP5Am5yO8EXPN9Tbgc2M1L+y0T43sl6HVai1KNMD7I6KxqCteIFgFK96ItpOULZjtIoQ7l8Y7H6FPqQl4Z2ulzTRgUPGVkFvWcApuCvdcNLQPsBBrbParH9QctaVVpQtRHnPo//osR/Rh9EtYfn2VsTSPcxLnFZkT3gkXA8LHRviU2i2oCt7ypqjRkPcv4eNr8sWZ6wX7XAwFcItrlKolLcESt5Ts0ofhykAPAkopLL0YVdkN174CXomTQYNcF/Vh87mc6Yyl4PmcPLZO1aE87KCjB2SPFVqmWgUHhHgsBqUSBJYovE6yePQFG1WqMI6zcZSmASlDptEDg5KYREnMoozFWSBFgY2h0G9aThlhDmsaW0WJUnrLuLai8jj4McKfHSlUiUfxHawLtRqE/WiPYdJQocamQJ9Tu21JySFZADugDtXFVXsPKoBTWN3qziy90AmyHi22NW/8xk/BdcXGeXLN0mScDdh4bDlfmnMTf3ZaC84buA8vM5OwNJqM2Tia5ANmZnWHcK+axbmldyjkpSayLJ2wdBJNBkwcLuH3ruH/voinFl7xJeqBVLnHpfqTSZawSZ4kQ/qlUztQ7taBS19qIk7oLZ7kmT+AKy4k4bHXEc69jd8WbtVBe8CNv4WUYlFTyx7w5feFuhB3MUuvxwmLkmyoWn99+0fjF/bYfftKz3M7t5y69aUAj9JsTEmNcn9gg3O6z88uctmaGqVQR6IacOi1atSaS7U+9+VG4mfelJdWIGbXSZ6zqyR3RSbOaagRCdzf8b4/UMvz2shkh+fNj6KKx304xFmFFu2RDgpFlWypp79/cF3V82NB/IiFby+07Vqy40ouJexarXHU4SSH2lB4sWPXcRrnV+mwYztTNHE8d2232g8DP/PiSE7Oo0EGcRuOQ84EjF86pzBf6xMFn27evvmv+AmTub1z5vM2e7Kkzn0YNM7GL5oySGUrSSFY/LwbIGBD+IO6o2mDAQGKxo6ipqZF9EacOZdHn2k66Z31sVEi9x6EMCOOotTv6RwK7qQL2dEyZXblJip6Cg0HYhNkmoYciRYUbdGhZaM2UNOPlgulNUFHbvuxqz97tOeHKPq6qlETKQjKxdGvH9XyO8ztb+mBu2cz9uoTGxN1A5zMjf8CsnKrBdwKAAA=
73
+ http_version:
74
+ recorded_at: Tue, 07 Dec 2021 13:58:52 GMT
75
+ recorded_with: VCR 3.0.3
@@ -36,6 +36,7 @@ describe Briard::Metadata, vcr: true do
36
36
  "rightsIdentifierScheme"=>"SPDX",
37
37
  "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
38
38
  "schemeUri"=>"https://spdx.org/licenses/"}])
39
+ expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1003149", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
39
40
  end
40
41
 
41
42
  it "cff-converter-python" do
@@ -101,6 +102,7 @@ describe Briard::Metadata, vcr: true do
101
102
  "rightsIdentifierScheme"=>"SPDX",
102
103
  "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
103
104
  "schemeUri"=>"https://spdx.org/licenses/"}])
105
+ expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1310751", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
104
106
  end
105
107
 
106
108
  it "ruby-cff" do
@@ -131,6 +133,7 @@ describe Briard::Metadata, vcr: true do
131
133
  "rightsIdentifierScheme"=>"SPDX",
132
134
  "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
133
135
  "schemeUri"=>"https://spdx.org/licenses/"}])
136
+ expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1003149", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
134
137
  end
135
138
 
136
139
  it "ruby-cff repository url" do
@@ -163,6 +166,7 @@ describe Briard::Metadata, vcr: true do
163
166
  "rightsIdentifierScheme"=>"SPDX",
164
167
  "rightsUri"=>"http://www.apache.org/licenses/LICENSE-2.0",
165
168
  "schemeUri"=>"https://spdx.org/licenses/"}])
169
+ expect(subject.related_identifiers).to eq([{"relatedIdentifier"=>"https://doi.org/10.5281/zenodo.1003149", "relatedIdentifierType"=>"DOI", "relationType"=>"References"}])
166
170
  end
167
171
  end
168
172
  end
@@ -10,24 +10,22 @@ describe Briard::Metadata, vcr: true do
10
10
  expect(subject.valid?).to be true
11
11
  json = Psych.safe_load(subject.cff, permitted_classes: [Date])
12
12
  expect(json["doi"]).to eq("https://doi.org/10.5281/zenodo.10164")
13
- expect(json["authors"]).to eq([{"affiliation"=>[{"name"=>"Juelich Supercomputing Centre, Jülich, Germany"}],
14
- "familyName"=>"Klatt",
15
- "givenName"=>"Torbjörn",
16
- "name"=>"Klatt, Torbjörn"},
17
- {"affiliation"=>[{"name"=>"Juelich Supercomputing Centre, Jülich, Germany"}],
18
- "familyName"=>"Moser",
19
- "givenName"=>"Dieter",
20
- "name"=>"Moser, Dieter"},
21
- {"affiliation"=>[{"name"=>"Juelich Supercomputing Centre, Jülich, Germany"}],
22
- "familyName"=>"Speck",
23
- "givenName"=>"Robert",
24
- "name"=>"Speck, Robert"}])
13
+ expect(json["authors"]).to eq([{"affiliation"=>"Juelich Supercomputing Centre, Jülich, Germany",
14
+ "family-names"=>"Klatt",
15
+ "given-names"=>"Torbjörn"},
16
+ {"affiliation"=>"Juelich Supercomputing Centre, Jülich, Germany",
17
+ "family-names"=>"Moser",
18
+ "given-names"=>"Dieter"},
19
+ {"affiliation"=>"Juelich Supercomputing Centre, Jülich, Germany",
20
+ "family-names"=>"Speck",
21
+ "given-names"=>"Robert"}])
25
22
  expect(json["title"]).to eq("Pypint -- Python Framework For Parallel-In-Time Methods")
26
23
  expect(json["abstract"]).to eq("<em>PyPinT</em> is a framework for Parallel-in-Time integration routines. The main purpose of <em>PyPinT</em> is to provide a framework for educational use and prototyping new parallel-in-time algorithms. As well it will aid in developing a high-performance C++ implementation for massively parallel computers providing the benefits of parallel-in-time routines to a zoo of time integrators in various applications.")
27
24
  expect(json["date-released"]).to eq("2014-05-27")
28
25
  expect(json["repository-code"]).to eq("https://zenodo.org/record/10164")
29
26
  expect(json["keywords"]).to eq(["Parallel-in-Time Integration", "Spectral Deferred Corrections", "Multigrid", "Multi-Level Spectral Deferred Corrections", "Python Framework"])
30
- expect(json["license"]).to eq(["http://www.opensource.org/licenses/MIT", "info:eu-repo/semantics/openAccess"])
27
+ expect(json["license"]).to be_nil
28
+ expect(json["references"]).to eq("identifiers"=>[{"type"=>"url", "value"=>"https://github.com/Parallel-in-Time/PyPinT/tree/release-v0.0.4"}])
31
29
  end
32
30
 
33
31
  it "SoftwareSourceCode also Zenodo" do
@@ -37,29 +35,44 @@ describe Briard::Metadata, vcr: true do
37
35
  json = Psych.safe_load(subject.cff, permitted_classes: [Date])
38
36
  expect(json["doi"]).to eq("https://doi.org/10.5281/zenodo.15497")
39
37
  expect(json["authors"]).to eq([{"affiliation"=>
40
- [{"name"=>
41
- "Instituut voor Kern- en Stralingsfysica, KU Leuven, 3001 Leuven, België"}],
42
- "familyName"=>"Gins",
43
- "givenName"=>"Wouter",
44
- "name"=>"Gins, Wouter"},
45
- {"affiliation"=>
46
- [{"name"=>
47
- "Instituut voor Kern- en Stralingsfysica, KU Leuven, 3001 Leuven, België"}],
48
- "familyName"=>"de Groote",
49
- "givenName"=>"Ruben",
50
- "name"=>"de Groote, Ruben"},
51
- {"affiliation"=>
52
- [{"name"=>
53
- "Instituut voor Kern- en Stralingsfysica, KU Leuven, 3001 Leuven, België"}],
54
- "familyName"=>"Heylen",
55
- "givenName"=>"Hanne",
56
- "name"=>"Heylen, Hanne"}])
38
+ "Instituut voor Kern- en Stralingsfysica, KU Leuven, 3001 Leuven, België",
39
+ "family-names"=>"Gins",
40
+ "given-names"=>"Wouter"},
41
+ {"affiliation"=>
42
+ "Instituut voor Kern- en Stralingsfysica, KU Leuven, 3001 Leuven, België",
43
+ "family-names"=>"de Groote",
44
+ "given-names"=>"Ruben"},
45
+ {"affiliation"=>
46
+ "Instituut voor Kern- en Stralingsfysica, KU Leuven, 3001 Leuven, België",
47
+ "family-names"=>"Heylen",
48
+ "given-names"=>"Hanne"}])
57
49
  expect(json["title"]).to eq("Satlas: Simulation And Analysis Toolbox For Laser Spectroscopy And Nmr Experiments")
58
50
  expect(json["abstract"]).to eq("Initial release of the satlas Python package for the analysis and simulation for laser spectroscopy experiments. For the documentation, see http://woutergins.github.io/satlas/")
59
51
  expect(json["date-released"]).to eq("2015-02-18")
60
52
  expect(json["repository-code"]).to eq("https://zenodo.org/record/15497")
61
53
  expect(json["keywords"]).to be_nil
62
- expect(json["license"]).to eq(["http://www.opensource.org/licenses/MIT", "info:eu-repo/semantics/openAccess"])
54
+ expect(json["license"]).to be_nil
55
+ expect(json["references"]).to eq("identifiers"=>[{"type"=>"url", "value"=>"https://github.com/woutergins/satlas/tree/v1.0.0"}])
56
+ end
57
+
58
+ it "ruby-cff" do
59
+ input = "https://github.com/citation-file-format/ruby-cff"
60
+ subject = Briard::Metadata.new(input: input)
61
+ expect(subject.valid?).to be true
62
+ json = Psych.safe_load(subject.cff, permitted_classes: [Date])
63
+ expect(json["doi"]).to eq("https://doi.org/10.5281/zenodo.1184077")
64
+ expect(json["authors"]).to eq([{"affiliation"=>"The University of Manchester, UK",
65
+ "family-names"=>"Haines",
66
+ "given-names"=>"Robert",
67
+ "orcid"=>"https://orcid.org/0000-0002-9538-7919"},
68
+ {"name"=>"The Ruby Citation File Format Developers"}])
69
+ expect(json["title"]).to eq("Ruby CFF Library")
70
+ expect(json["abstract"]).to eq("This library provides a Ruby interface to manipulate Citation File Format files")
71
+ expect(json["date-released"]).to eq("2021-08-18")
72
+ expect(json["repository-code"]).to eq("https://github.com/citation-file-format/ruby-cff")
73
+ expect(json["keywords"]).to eq(["ruby", "credit", "software citation", "research software", "software sustainability", "metadata", "citation file format", "CFF"])
74
+ expect(json["license"]).to eq("apache-2.0")
75
+ expect(json["references"]).to eq("identifiers"=>[{"type"=>"doi", "value"=>"10.5281/zenodo.1003149"}])
63
76
  end
64
77
  end
65
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: briard
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.2'
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
@@ -1215,6 +1215,7 @@ files:
1215
1215
  - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/SoftwareSourceCode_DataCite.yml
1216
1216
  - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/SoftwareSourceCode_Zenodo.yml
1217
1217
  - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/SoftwareSourceCode_also_Zenodo.yml
1218
+ - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_cff/ruby-cff.yml
1218
1219
  - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Dataset.yml
1219
1220
  - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Journal_article.yml
1220
1221
  - spec/fixtures/vcr_cassettes/Briard_Metadata/write_metadata_as_citation/Journal_article_vancouver_style.yml