relaton-doi 0.1.pre1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9d7543dff584536fb709c5a291fbdc7e5620167a065aed24acb42913e32d17ae
4
+ data.tar.gz: 302928f0f388b4da0ac1b9b70f6d8b567c3467bd59a17385486608fd66f74bc4
5
+ SHA512:
6
+ metadata.gz: f80b7b5dcd73361411606b75ed1442db50934cf9a0fa2717ab1bc0b8dfcd7aefe0b06d135651cf060f16c3393ae6b705f053344530a177c4979ccff3eb5ac677
7
+ data.tar.gz: 6bbccb587b7457f064da5b9720722a85568be5421096ff149aac217eeaeb6d0255e1d25b7c7f7b1c82fb7d54ed2ae83ee6ca5a538b7bb453f703d3ce5003749c
@@ -0,0 +1,36 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ steps:
23
+ - uses: actions/checkout@v2
24
+ with:
25
+ submodules: true
26
+
27
+ # https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
28
+ - if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
29
+ run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
30
+
31
+ - uses: ruby/setup-ruby@v1
32
+ with:
33
+ ruby-version: ${{ matrix.ruby }}
34
+ bundler-cache: true
35
+
36
+ - run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .rubocop-https---raw-githubusercontent-com-riboseinc-oss-guides-master-ci-rubocop-yml
13
+ Gemfile.lock
14
+ .vscode/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ # This project follows the Ribose OSS style guide.
2
+ # https://github.com/riboseinc/oss-guides
3
+ # All project-specific additions and overrides should be specified in this file.
4
+
5
+ require: rubocop-rails
6
+
7
+ inherit_from:
8
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
+ AllCops:
10
+ TargetRubyVersion: 2.5
11
+ Rails:
12
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in relaton-doi.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Andrei Kislichenko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.adoc ADDED
@@ -0,0 +1,83 @@
1
+ = RelatonDoi retrieve Standards for bibliographic use using the BibliographicItem model
2
+
3
+ image:https://img.shields.io/gem/v/relaton-doi.svg["Gem Version", link="https://rubygems.org/gems/relaton-doi"]
4
+ image:https://github.com/relaton/relaton-doi/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-doi/actions?workflow=macos"]
5
+ image:https://github.com/relaton/relaton-doi/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-doi/actions?workflow=windows"]
6
+ image:https://github.com/relaton/relaton-doi/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-doi/actions?workflow=ubuntu"]
7
+ image:https://codeclimate.com/github/relaton/relaton-doi/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-doi"]
8
+ image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-doi.svg["Pull Requests", link="https://github.com/relaton/relaton-doi/pulls"]
9
+ image:https://img.shields.io/github/commits-since/relaton/relaton-doi/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-doi/releases"]
10
+
11
+ RelatonDoi is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
12
+
13
+ You can use it to retrieve metadata of Standards from https://crossref.org, and access such metadata through the `BibliographicItem` object.
14
+
15
+ == Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ [source,ruby]
20
+ ----
21
+ gem 'relaton-doi'
22
+ ----
23
+
24
+ And then execute:
25
+
26
+ $ bundle install
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install relaton-doi
31
+
32
+ == Usage
33
+
34
+ === Search for a standard using DOI
35
+
36
+ [source,ruby]
37
+ ----
38
+ require 'relaton_doi'
39
+ => true
40
+
41
+ # get NIST standard
42
+ RelatonDoi::Crossref.get "10.6028/nist.ir.8245"
43
+ [relaton-doi] ["10.6028/nist.ir.8245"] fetching...
44
+ [relaton-doi] ["10.6028/nist.ir.8245"] found 10.6028/nist.ir.8245
45
+ => #<RelatonNist::NistBibliographicItem:0x00007f9c813b6a58
46
+ ...
47
+
48
+ # get RFC standard
49
+ RelatonDoi::Crossref.get "10.17487/RFC0001"
50
+ [relaton-doi] ["10.17487/RFC0001"] fetching...
51
+ [relaton-doi] ["10.17487/RFC0001"] found 10.17487/rfc0001
52
+ [relaton-ietf] WARNING: invalid doctype report
53
+ => #<RelatonIetf::IetfBibliographicItem:0x00007f9c8143d058
54
+ ...
55
+
56
+ # get BIPM standard
57
+ RelatonDoi::Crossref.get "10.1088/0026-1394/29/6/001"
58
+ [relaton-doi] ["10.1088/0026-1394/29/6/001"] fetching...
59
+ [relaton-doi] ["10.1088/0026-1394/29/6/001"] found 10.1088/0026-1394/29/6/001
60
+ => #<RelatonBipm::BipmBibliographicItem:0x00007f9c846f0a68
61
+ ...
62
+
63
+ # get IEEE standard
64
+ RelatonDoi::Crossref.get "10.1109/ieeestd.2014.6835311"
65
+ [relaton-doi] ["10.1109/ieeestd.2014.6835311"] fetching...
66
+ [relaton-doi] ["10.1109/ieeestd.2014.6835311"] found 10.1109/ieeestd.2014.6835311
67
+ => #<RelatonIeee::IeeeBibliographicItem:0x00007f9cb46db688
68
+ ...
69
+ ----
70
+
71
+ == Development
72
+
73
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
74
+
75
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
76
+
77
+ == Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/relaton-doi.
80
+
81
+ == License
82
+
83
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "relaton/doi"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,333 @@
1
+ module RelatonDoi
2
+ class Crossref
3
+ REALATION_TYPES = {
4
+ "is-preprint-of" => "reprintOf",
5
+ "is-review-of" => "reviewOf",
6
+ "has-review" => "hasReview",
7
+ "is-identical-to" => "identicalTo", # ?
8
+ "is-supplement-to" => "complements",
9
+ }.freeze
10
+
11
+ #
12
+ # Get a document by DOI from the CrossRef API.
13
+ #
14
+ # @param [String] doi The DOI.
15
+ #
16
+ # @return [RelatonBib::BibliographicItem, RelatonIetf::IetfBibliographicItem,
17
+ # RelatonBipm::BipmBibliographicItem, RelatonIeee::IeeeBibliographicItem,
18
+ # RelatonNist::NistBibliographicItem] The bibitem.
19
+ #
20
+ def self.get(doi)
21
+ new.get doi
22
+ end
23
+
24
+ #
25
+ # Get a document by DOI from the CrossRef API.
26
+ #
27
+ # @param [String] doi The DOI.
28
+ #
29
+ # @return [RelatonBib::BibliographicItem, RelatonIetf::IetfBibliographicItem,
30
+ # RelatonBipm::BipmBibliographicItem, RelatonIeee::IeeeBibliographicItem,
31
+ # RelatonNist::NistBibliographicItem] The bibitem.
32
+ #
33
+ def get(doi)
34
+ warn "[relaton-doi] [\"#{doi}\"] fetching..."
35
+ resp = Serrano.works ids: doi
36
+ @message = resp[0]["message"]
37
+ warn "[relaton-doi] [\"#{doi}\"] found #{@message['DOI']}"
38
+ create_bibitem @message["DOI"], bibitem_hash
39
+ end
40
+
41
+ #
42
+ # Create a bibitem from the bibitem hash.
43
+ #
44
+ # @param [String] doi The DOI.
45
+ # @param [Hash] bibitem The bibitem hash.
46
+ #
47
+ # @return [RelatonBib::BibliographicItem, RelatonIetf::IetfBibliographicItem,
48
+ # RelatonBipm::BipmBibliographicItem, RelatonIeee::IeeeBibliographicItem,
49
+ # RelatonNist::NistBibliographicItem] The bibitem.
50
+ #
51
+ # @raise [RelatonDoi::Error] if the document type is not supported.
52
+ #
53
+ def create_bibitem(doi, bibitem) # rubocop:disable Metrics/CyclomaticComplexity
54
+ # case @message["institution"]&.first&.fetch("acronym")&.first
55
+ case doi
56
+ when /\/nist/ then RelatonNist::NistBibliographicItem.new(**bibitem)
57
+ when /\/rfc\d+/ then RelatonIetf::IetfBibliographicItem.new(**bibitem)
58
+ when /\/0026-1394\// then RelatonBipm::BipmBibliographicItem.new(**bibitem)
59
+ # when "ISO" then RelatonIso::IsoBibliographicItem.new(**bibitem)
60
+ # when "W3C" then RelatonW3c::W3cBibliographicItem.new(**bibitem)
61
+ when /\/ieee/ then RelatonIeee::IeeeBibliographicItem.new(**bibitem)
62
+ else RelatonBib::BibliographicItem.new(**bibitem)
63
+ end
64
+ end
65
+
66
+ #
67
+ # Create a bibitem hash from the message hash.
68
+ #
69
+ # @return [Hash] The bibitem hash.
70
+ #
71
+ def bibitem_hash # rubocop:disable Metrics/MethodLength
72
+ {
73
+ type: "standard",
74
+ fetched: Date.today.to_s,
75
+ title: create_title,
76
+ docid: create_docid,
77
+ date: create_date,
78
+ link: create_link,
79
+ abstract: create_abstract,
80
+ contributor: create_contributors,
81
+ doctype: @message["type"],
82
+ place: create_place,
83
+ relation: create_relation,
84
+ }
85
+ end
86
+
87
+ #
88
+ # Create a title and a subtitle from the message hash.
89
+ #
90
+ # @return [Array<RelatonBib::TypedTitleString>] The title and subtitle.
91
+ #
92
+ def create_title
93
+ @message["title"].map do |t|
94
+ RelatonBib::TypedTitleString.new(
95
+ type: "main", content: t, language: "en", script: "Latn",
96
+ )
97
+ end + @message["subtitle"].map do |t|
98
+ RelatonBib::TypedTitleString.new(
99
+ type: "subtitle", content: t, language: "en", script: "Latn",
100
+ )
101
+ end
102
+ end
103
+
104
+ #
105
+ # Create a docid from the message hash.
106
+ #
107
+ # @return [Array<RelatonBib::DocumentIdentifier>] The docid.
108
+ #
109
+ def create_docid
110
+ %w[DOI ISBN].each_with_object([]) do |type, obj|
111
+ id = @message[type].is_a?(Array) ? @message[type].first : @message[type]
112
+ next unless id
113
+
114
+ primary = type == "DOI"
115
+ obj << RelatonBib::DocumentIdentifier.new(type: type, id: id, primary: primary)
116
+ end
117
+ end
118
+
119
+ #
120
+ # Create dates from the message hash.
121
+ #
122
+ # @return [Array<RelatonBib::BibliographicDate>] The dates.
123
+ #
124
+ def create_date
125
+ %w[created issued published approved].each_with_object([]) do |type, obj|
126
+ next unless @message[type]
127
+
128
+ on = @message[type]["date-parts"][0].map { |d| d.to_s.rjust(2, "0") }.join "-"
129
+ obj << RelatonBib::BibliographicDate.new(type: type, on: on)
130
+ end
131
+ end
132
+
133
+ #
134
+ # Create a link from the message hash.
135
+ #
136
+ # @return [Array<RelatonBib::TypedUri>] The link.
137
+ #
138
+ def create_link
139
+ return [] unless @message["URL"]
140
+
141
+ [RelatonBib::TypedUri.new(type: "DOI", content: @message["URL"])]
142
+ end
143
+
144
+ #
145
+ # Create an abstract from the message hash.
146
+ #
147
+ # @return [Array<RelatonBib::FormattedString>] The abstract.
148
+ #
149
+ def create_abstract
150
+ return [] unless @message["abstract"]
151
+
152
+ content = @message["abstract"]
153
+ abstract = RelatonBib::FormattedString.new(
154
+ content: content, language: "en", script: "Latn", format: "text/html",
155
+ )
156
+ [abstract]
157
+ end
158
+
159
+ #
160
+ # Create contributors from the message hash.
161
+ #
162
+ # @return [Array<RelatonBib::ContributionInfo>] The contributors.
163
+ #
164
+ def create_contributors
165
+ contribs = %w[author editor translator].each_with_object([]) do |type, obj|
166
+ @message[type]&.each do |contrib|
167
+ obj << contributor(person(contrib), type)
168
+ end
169
+ end
170
+ contribs << contributor(org_publisher, "publisher")
171
+ end
172
+
173
+ #
174
+ # Cerate an organization publisher from the message hash.
175
+ #
176
+ # @return [RelatonBib::Organization] The organization.
177
+ #
178
+ def org_publisher
179
+ pbr = @message["institution"]&.detect do |i|
180
+ @message["publisher"].include?(i["name"]) ||
181
+ i["name"].include?(@message["publisher"])
182
+ end
183
+ a = pbr["acronym"]&.first if pbr
184
+ RelatonBib::Organization.new name: @message["publisher"], abbreviation: a
185
+ end
186
+
187
+ #
188
+ # Create contributor from an entity and a role type.
189
+ #
190
+ # @param [RelatonBib::Person, RelatonBib::Organization] entity The entity.
191
+ # @param [String] type The role type.
192
+ #
193
+ # @return [RelatonBib::ContributionInfo] The contributor.
194
+ #
195
+ def contributor(entity, type)
196
+ RelatonBib::ContributionInfo.new(entity: entity, role: [type: type])
197
+ end
198
+
199
+ #
200
+ # Create a person from a person hash.
201
+ #
202
+ # @param [Hash] person The person hash.
203
+ #
204
+ # @return [RelatonBib::Person] The person.
205
+ #
206
+ def person(person)
207
+ RelatonBib::Person.new(
208
+ name: person_name(person), affiliation: affiliation(person),
209
+ identifier: person_id(person)
210
+ )
211
+ end
212
+
213
+ #
214
+ # Create person affiliations from a person hash.
215
+ #
216
+ # @param [Hash] person The person hash.
217
+ #
218
+ # @return [Array<RelatonBib::Affiliation>] The affiliations.
219
+ #
220
+ def affiliation(person)
221
+ (person["affiliation"] || []).map do |a|
222
+ org = RelatonBib::Organization.new(name: a["name"])
223
+ RelatonBib::Affiliation.new organization: org
224
+ end
225
+ end
226
+
227
+ #
228
+ # Create a person full name from a person hash.
229
+ #
230
+ # @param [Hash] person The person hash.
231
+ #
232
+ # @return [RelatonBib::FullName] The full name.
233
+ #
234
+ def person_name(person)
235
+ sn = RelatonBib::LocalizedString.new(person["family"], "en", "Latn")
236
+ RelatonBib::FullName.new(
237
+ surname: sn, forename: forename(person), addition: nameaddition(person),
238
+ completename: completename(person), prefix: nameprefix(person)
239
+ )
240
+ end
241
+
242
+ #
243
+ # Create a person name prefix from a person hash.
244
+ #
245
+ # @param [Hash] person The person hash.
246
+ #
247
+ # @return [Array<RelatonBib::LocalizedString>] The name prefix.
248
+ #
249
+ def nameprefix(person)
250
+ return [] unless person["prefix"]
251
+
252
+ [RelatonBib::LocalizedString.new(person["prefix"], "en", "Latn")]
253
+ end
254
+
255
+ #
256
+ # Create a complete name from a person hash.
257
+ #
258
+ # @param [Hash] person The person hash.
259
+ #
260
+ # @return [RelatonBib::LocalizedString] The complete name.
261
+ #
262
+ def completename(person)
263
+ return unless person["name"]
264
+
265
+ RelatonBib::LocalizedString.new(person["name"], "en", "Latn")
266
+ end
267
+
268
+ #
269
+ # Create a forename from a person hash.
270
+ #
271
+ # @param [Hash] person The person hash.
272
+ #
273
+ # @return [Array<RelatonBib::LocalizedString>] The forename.
274
+ #
275
+ def forename(person)
276
+ return [] unless person["given"]
277
+
278
+ [RelatonBib::LocalizedString.new(person["given"], "en", "Latn")]
279
+ end
280
+
281
+ #
282
+ # Create an addition from a person hash.
283
+ #
284
+ # @param [Hash] person The person hash.
285
+ #
286
+ # @return [Array<RelatonBib::LocalizedString>] The addition.
287
+ #
288
+ def nameaddition(person)
289
+ return [] unless person["suffix"]
290
+
291
+ [RelatonBib::LocalizedString.new(person["suffix"], "en", "Latn")]
292
+ end
293
+
294
+ #
295
+ # Create a person identifier from a person hash.
296
+ #
297
+ # @param [Hash] person The person hash.
298
+ #
299
+ # @return [Array<RelatonBib::PersonIdentifier>] The person identifier.
300
+ #
301
+ def person_id(person)
302
+ return [] unless person["ORCID"]
303
+
304
+ [RelatonBib::PersonIdentifier.new("orcid", person["ORCID"])]
305
+ end
306
+
307
+ #
308
+ # Create a place from the message hash.
309
+ #
310
+ # @return [Array<RelatonBib::Place>] The place.
311
+ #
312
+ def create_place
313
+ return [] unless @message["publisher-location"]
314
+
315
+ name, region = @message["publisher-location"].split(", ")
316
+ [RelatonBib::Place.new(name: name, region: region)]
317
+ end
318
+
319
+ #
320
+ # Crerate relations from the message hash.
321
+ #
322
+ # @return [Array<RelatonBib::DocumentRelation>] The relations.
323
+ #
324
+ def create_relation
325
+ @message["relation"].map do |k, v|
326
+ fref = RelatonBib::FormattedRef.new(content: v["id"])
327
+ bib = create_bibitem v["id"], formattedref: fref
328
+ type = REALATION_TYPES[k] || k
329
+ RelatonBib::DocumentRelation.new(type: type, bibitem: bib)
330
+ end
331
+ end
332
+ end
333
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RelatonDoi
4
+ VERSION = "0.1.pre1"
5
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "serrano"
4
+ require "relaton_bipm"
5
+ # require "relaton_iso_bib"
6
+ # require "relaton_w3c"
7
+ require "relaton_ietf"
8
+ require "relaton_ieee"
9
+ require "relaton_nist"
10
+ require_relative "relaton_doi/version"
11
+ require_relative "relaton_doi/crossref"
12
+
13
+ Serrano.configuration do |config|
14
+ config.mailto = "open.source@ribose.com"
15
+ end
16
+
17
+ module RelatonDoi
18
+ class Error < StandardError; end
19
+ # Your code goes here...
20
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/relaton_doi/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "relaton-doi"
7
+ spec.version = RelatonDoi::VERSION
8
+ spec.authors = ["Ribose Inc."]
9
+ spec.email = ["open.source@ribose.com"]
10
+
11
+ spec.summary = "RelatonDOI: retrieve Standards for bibliographic "\
12
+ "using DOI through Crossrefand provide Relaton object."
13
+ spec.description = "RelatonDOI: retrieve Standards for bibliographic "\
14
+ "using DOI through Crossrefand provide Relaton object."
15
+ spec.homepage = "https://github.com/relaton/relaton-doi"
16
+ spec.license = "BSD-2-Clause"
17
+ spec.required_ruby_version = ">= 2.5.0"
18
+
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
23
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ # Uncomment to register a new dependency of your gem
35
+ # spec.add_dependency "example-gem", "~> 1.0"
36
+ spec.add_development_dependency "equivalent-xml", "~> 0.6"
37
+ # spec.add_development_dependency "ruby-jing"
38
+ spec.add_development_dependency "rubocop-performance"
39
+ spec.add_development_dependency "rubocop-rails"
40
+ spec.add_development_dependency "simplecov"
41
+ spec.add_development_dependency "vcr"
42
+ spec.add_development_dependency "webmock"
43
+
44
+ spec.add_dependency "relaton-bipm", "~> 1.10.0"
45
+ spec.add_dependency "relaton-ieee", "~> 1.10.0"
46
+ spec.add_dependency "relaton-ietf", "~> 1.10.0"
47
+ # spec.add_dependency "relaton-iso-bib", "~> 1.10.0"
48
+ spec.add_dependency "relaton-nist", "~> 1.10.0"
49
+ # spec.add_dependency "relaton-w3c", "~> 1.10.0"
50
+ spec.add_dependency "serrano", "~> 1.0.0"
51
+
52
+ # For more information and examples about making a new gem, checkout our
53
+ # guide at: https://bundler.io/guides/creating_gem.html
54
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relaton-doi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Ribose Inc.
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: equivalent-xml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-performance
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: relaton-bipm
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.10.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.10.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: relaton-ieee
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.10.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.10.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: relaton-ietf
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.10.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.10.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: relaton-nist
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 1.10.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 1.10.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: serrano
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 1.0.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 1.0.0
167
+ description: 'RelatonDOI: retrieve Standards for bibliographic using DOI through Crossrefand
168
+ provide Relaton object.'
169
+ email:
170
+ - open.source@ribose.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - ".github/workflows/rake.yml"
176
+ - ".gitignore"
177
+ - ".rspec"
178
+ - ".rubocop.yml"
179
+ - Gemfile
180
+ - LICENSE.txt
181
+ - README.adoc
182
+ - Rakefile
183
+ - bin/console
184
+ - bin/rspec
185
+ - bin/setup
186
+ - lib/relaton_doi.rb
187
+ - lib/relaton_doi/crossref.rb
188
+ - lib/relaton_doi/version.rb
189
+ - relaton-doi.gemspec
190
+ homepage: https://github.com/relaton/relaton-doi
191
+ licenses:
192
+ - BSD-2-Clause
193
+ metadata:
194
+ homepage_uri: https://github.com/relaton/relaton-doi
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: 2.5.0
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">"
207
+ - !ruby/object:Gem::Version
208
+ version: 1.3.1
209
+ requirements: []
210
+ rubygems_version: 3.2.3
211
+ signing_key:
212
+ specification_version: 4
213
+ summary: 'RelatonDOI: retrieve Standards for bibliographic using DOI through Crossrefand
214
+ provide Relaton object.'
215
+ test_files: []