relaton-doi 0.1.pre1 → 1.14.0

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: 9d7543dff584536fb709c5a291fbdc7e5620167a065aed24acb42913e32d17ae
4
- data.tar.gz: 302928f0f388b4da0ac1b9b70f6d8b567c3467bd59a17385486608fd66f74bc4
3
+ metadata.gz: d864a698c9f38895e2d9c357d4d2d1cec68e645a08a6f440507fc3a236b1f671
4
+ data.tar.gz: ac0782cd81ba541658b97832c3f1efbf4d460c06ba1a720af369b28c70159795
5
5
  SHA512:
6
- metadata.gz: f80b7b5dcd73361411606b75ed1442db50934cf9a0fa2717ab1bc0b8dfcd7aefe0b06d135651cf060f16c3393ae6b705f053344530a177c4979ccff3eb5ac677
7
- data.tar.gz: 6bbccb587b7457f064da5b9720722a85568be5421096ff149aac217eeaeb6d0255e1d25b7c7f7b1c82fb7d54ed2ae83ee6ca5a538b7bb453f703d3ce5003749c
6
+ metadata.gz: 2e59c3acb8542e99deae9493eec3fdb364f8372feb24ab6f614a62dd8045deb56a12e17013cd21bc7fb33b587fb94e808e53f0bd0c0a44b169985e285312e4d6
7
+ data.tar.gz: d0c79b69008ffe853814235600a9c6c693bd027d8c7a38c9813d24933903faa29064f46a54ca6984b0dc14644f74e7a121ba9b2ec223bd2a4aa09625c67b424b
@@ -10,27 +10,4 @@ on:
10
10
 
11
11
  jobs:
12
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
13
+ uses: relaton/support/.github/workflows/rake.yml@master
@@ -0,0 +1,22 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: release
4
+
5
+ on:
6
+ workflow_dispatch:
7
+ inputs:
8
+ next_version:
9
+ description: |
10
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
+ required: true
12
+ default: 'skip'
13
+ push:
14
+ tags: [ v* ]
15
+
16
+ jobs:
17
+ release:
18
+ uses: relaton/support/.github/workflows/release.yml@master
19
+ with:
20
+ next_version: ${{ github.event.inputs.next_version }}
21
+ secrets:
22
+ rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
data/README.adoc CHANGED
@@ -1,4 +1,4 @@
1
- = RelatonDoi retrieve Standards for bibliographic use using the BibliographicItem model
1
+ = Relaton-DOI: retrieve bibliographic items using DOI
2
2
 
3
3
  image:https://img.shields.io/gem/v/relaton-doi.svg["Gem Version", link="https://rubygems.org/gems/relaton-doi"]
4
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"]
@@ -8,9 +8,11 @@ image:https://codeclimate.com/github/relaton/relaton-doi/badges/gpa.svg["Code Cl
8
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
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
10
 
11
- RelatonDoi is a Ruby gem that implements the https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
11
+ RelatonDoi is a Ruby gem that implements the
12
+ https://github.com/metanorma/metanorma-model-iso#iso-bibliographic-item[IsoBibliographicItem model].
12
13
 
13
- You can use it to retrieve metadata of Standards from https://crossref.org, and access such metadata through the `BibliographicItem` object.
14
+ You can use it to retrieve metadata of Standards from https://crossref.org, and
15
+ access such metadata through the `BibliographicItem` object.
14
16
 
15
17
  == Installation
16
18
 
@@ -23,15 +25,25 @@ gem 'relaton-doi'
23
25
 
24
26
  And then execute:
25
27
 
26
- $ bundle install
28
+ [source,sh]
29
+ ----
30
+ $ bundle install
31
+ ----
27
32
 
28
33
  Or install it yourself as:
29
34
 
30
- $ gem install relaton-doi
35
+ [source,ruby]
36
+ ----
37
+ $ gem install relaton-doi
38
+ ----
31
39
 
32
40
  == Usage
33
41
 
34
- === Search for a standard using DOI
42
+ === Retrieving items of known type using DOI
43
+
44
+ If the resulting bibliographic item returned from CrossRef is a known Relaton
45
+ flavor, such as a NIST or IEEE standard, the corresponding Relaton class object
46
+ will be returned via the call.
35
47
 
36
48
  [source,ruby]
37
49
  ----
@@ -39,45 +51,66 @@ require 'relaton_doi'
39
51
  => true
40
52
 
41
53
  # 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
54
+ RelatonDoi::Crossref.get "doi:10.6028/nist.ir.8245"
55
+ [relaton-doi] ["doi:10.6028/nist.ir.8245"] fetching...
56
+ [relaton-doi] ["doi:10.6028/nist.ir.8245"] found 10.6028/nist.ir.8245
57
+ => #<RelatonNist::NistBibliographicItem:0x00007ff22420d820
46
58
  ...
47
59
 
48
60
  # 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
61
+ RelatonDoi::Crossref.get "doi:10.17487/RFC0001"
62
+ [relaton-doi] ["doi:10.17487/RFC0001"] fetching...
63
+ [relaton-doi] ["doi:10.17487/RFC0001"] found 10.17487/rfc0001
52
64
  [relaton-ietf] WARNING: invalid doctype report
53
- => #<RelatonIetf::IetfBibliographicItem:0x00007f9c8143d058
65
+ => #<RelatonIetf::IetfBibliographicItem:0x00007ff2241be6d0
54
66
  ...
55
67
 
56
68
  # 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
69
+ RelatonDoi::Crossref.get "doi:10.1088/0026-1394/29/6/001"
70
+ [relaton-doi] ["doi:10.1088/0026-1394/29/6/001"] fetching...
71
+ [relaton-doi] ["doi:10.1088/0026-1394/29/6/001"] found 10.1088/0026-1394/29/6/001
60
72
  => #<RelatonBipm::BipmBibliographicItem:0x00007f9c846f0a68
61
73
  ...
62
74
 
63
75
  # 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
76
+ RelatonDoi::Crossref.get "doi:10.1109/ieeestd.2014.6835311"
77
+ [relaton-doi] ["doi:10.1109/ieeestd.2014.6835311"] fetching...
78
+ [relaton-doi] ["doi:10.1109/ieeestd.2014.6835311"] found 10.1109/ieeestd.2014.6835311
67
79
  => #<RelatonIeee::IeeeBibliographicItem:0x00007f9cb46db688
68
80
  ...
69
81
  ----
70
82
 
83
+ === Retrieving items of unknown types via DOI
84
+
85
+ If the resulting bibliographic item returned from CrossRef is of an unknown type
86
+ to Relaton, an instance of RelatonBib::BibliographicItem will be returned.
87
+
88
+ [source,ruby]
89
+ ----
90
+ RelatonDoi::Crossref.get "doi:10.1109/ACCESS.2017.2739804"
91
+ [relaton-doi] ["doi:10.1109/ACCESS.2017.2739804"] fetching...
92
+ [relaton-doi] ["doi:10.1109/ACCESS.2017.2739804"] found 10.1109/access.2017.2739804
93
+ => #<RelatonBib::BibliographicItem:0x00007ff22435e490
94
+ ...
95
+ ----
96
+
97
+
71
98
  == Development
72
99
 
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.
100
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
101
+ `rake spec` to run the tests. You can also run `bin/console` for an interactive
102
+ prompt that will allow you to experiment.
74
103
 
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).
104
+ To install this gem onto your local machine, run `bundle exec rake install`. To
105
+ release a new version, update the version number in `version.rb`, and then run
106
+ `bundle exec rake release`, which will create a git tag for the version, push
107
+ git commits and the created tag, and push the `.gem` file to
108
+ https://rubygems.org[rubygems.org].
76
109
 
77
110
  == Contributing
78
111
 
79
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/relaton-doi.
112
+ Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-doi.
80
113
 
81
114
  == License
82
115
 
83
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
116
+ The gem is available as open source under the terms of the https://opensource.org/licenses/MIT[MIT License].
@@ -1,5 +1,33 @@
1
1
  module RelatonDoi
2
2
  class Crossref
3
+ TYPES = {
4
+ "book-chapter" => "inbook",
5
+ "book-part" => "inbook",
6
+ "book-section" => "inbook",
7
+ "book-series" => "book",
8
+ "book-set" => "book",
9
+ "book-track" => "inbook",
10
+ "component" => "misc",
11
+ "database" => "dataset",
12
+ "dissertation" => "thesis",
13
+ "edited-book" => "book",
14
+ "grant" => "misc",
15
+ "journal-article" => "article",
16
+ "journal-issue" => "journal",
17
+ "journal-volume" => "journal",
18
+ "monograph" => "book",
19
+ "other" => "misc",
20
+ "peer-review" => "article",
21
+ "posted-content" => "social_media",
22
+ "proceedings-article" => "inproceedings",
23
+ "proceedings-series" => "proceedings",
24
+ "reference-book" => "book",
25
+ "reference-entry" => "inbook",
26
+ "report-component" => "techreport",
27
+ "report-series" => "techreport",
28
+ "report" => "techreport",
29
+ }.freeze
30
+
3
31
  REALATION_TYPES = {
4
32
  "is-preprint-of" => "reprintOf",
5
33
  "is-review-of" => "reviewOf",
@@ -32,7 +60,8 @@ module RelatonDoi
32
60
  #
33
61
  def get(doi)
34
62
  warn "[relaton-doi] [\"#{doi}\"] fetching..."
35
- resp = Serrano.works ids: doi
63
+ id = doi.sub(%r{^doi:}, "")
64
+ resp = Serrano.works ids: id
36
65
  @message = resp[0]["message"]
37
66
  warn "[relaton-doi] [\"#{doi}\"] found #{@message['DOI']}"
38
67
  create_bibitem @message["DOI"], bibitem_hash
@@ -70,7 +99,7 @@ module RelatonDoi
70
99
  #
71
100
  def bibitem_hash # rubocop:disable Metrics/MethodLength
72
101
  {
73
- type: "standard",
102
+ type: parse_type,
74
103
  fetched: Date.today.to_s,
75
104
  title: create_title,
76
105
  docid: create_docid,
@@ -84,6 +113,10 @@ module RelatonDoi
84
113
  }
85
114
  end
86
115
 
116
+ def parse_type
117
+ TYPES[@message["type"]] || @message["type"]
118
+ end
119
+
87
120
  #
88
121
  # Create a title and a subtitle from the message hash.
89
122
  #
@@ -275,7 +308,7 @@ module RelatonDoi
275
308
  def forename(person)
276
309
  return [] unless person["given"]
277
310
 
278
- [RelatonBib::LocalizedString.new(person["given"], "en", "Latn")]
311
+ [RelatonBib::Forename.new(content: person["given"], language: "en", script: "Latn")]
279
312
  end
280
313
 
281
314
  #
@@ -312,8 +345,9 @@ module RelatonDoi
312
345
  def create_place
313
346
  return [] unless @message["publisher-location"]
314
347
 
315
- name, region = @message["publisher-location"].split(", ")
316
- [RelatonBib::Place.new(name: name, region: region)]
348
+ city, rg = @message["publisher-location"].split(", ")
349
+ region = RelatonBib::Place::RegionType.new(name: rg)
350
+ [RelatonBib::Place.new(city: city, region: [region])]
317
351
  end
318
352
 
319
353
  #
@@ -0,0 +1,51 @@
1
+ require "relaton/processor"
2
+
3
+ module RelatonDoi
4
+ class Processor < Relaton::Processor
5
+ attr_reader :idtype
6
+
7
+ def initialize
8
+ @short = :relaton_doi
9
+ @prefix = "DOI"
10
+ @defaultprefix = %r{^doi:}
11
+ @idtype = "DOI"
12
+ # @datasets = %w[bipm-data-outcomes bipm-si-brochure]
13
+ end
14
+
15
+ # @param code [String] DOI
16
+ # @param date [String, nil] year
17
+ # @param opts [Hash]
18
+ # @return [RelatonBib::BibliographicItem]
19
+ def get(code, _date, _opts)
20
+ Crossref.get(code)
21
+ end
22
+
23
+ #
24
+ # @param [String] source source name
25
+ # @param [Hash] opts
26
+ # @option opts [String] :output directory to output documents
27
+ # @option opts [String] :format
28
+ #
29
+ # def fetch_data(source, opts)
30
+ # DataFetcher.fetch(source, **opts)
31
+ # end
32
+
33
+ # @param xml [String]
34
+ # @return [RelatonBipm::BipmBibliographicItem]
35
+ def from_xml(xml)
36
+ ::RelatonBib::XMLParser.from_xml xml
37
+ end
38
+
39
+ # @param hash [Hash]
40
+ # @return [RelatonBipm::BipmBibliographicItem]
41
+ def hash_to_bib(hash)
42
+ ::RelatonBib::BibliographicItem.from_hash hash
43
+ end
44
+
45
+ # Returns hash of XML grammar
46
+ # @return [String]
47
+ def grammar_hash
48
+ @grammar_hash ||= ::RelatonBib.grammar_hash
49
+ end
50
+ end
51
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonDoi
4
- VERSION = "0.1.pre1"
4
+ VERSION = "1.14.0"
5
5
  end
data/relaton-doi.gemspec CHANGED
@@ -41,11 +41,11 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency "vcr"
42
42
  spec.add_development_dependency "webmock"
43
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"
44
+ spec.add_dependency "relaton-bib", "~> 1.14.1"
45
+ spec.add_dependency "relaton-bipm", "~> 1.14.0"
46
+ spec.add_dependency "relaton-ieee", "~> 1.14.0"
47
+ spec.add_dependency "relaton-ietf", "~> 1.14.0"
48
+ spec.add_dependency "relaton-nist", "~> 1.14.0"
49
49
  # spec.add_dependency "relaton-w3c", "~> 1.10.0"
50
50
  spec.add_dependency "serrano", "~> 1.0.0"
51
51
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-doi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.pre1
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-22 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -94,62 +94,76 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: relaton-bib
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.14.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.14.1
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: relaton-bipm
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 1.10.0
117
+ version: 1.14.0
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 1.10.0
124
+ version: 1.14.0
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: relaton-ieee
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
129
  - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: 1.10.0
131
+ version: 1.14.0
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: 1.10.0
138
+ version: 1.14.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: relaton-ietf
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 1.10.0
145
+ version: 1.14.0
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: 1.10.0
152
+ version: 1.14.0
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: relaton-nist
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
157
  - - "~>"
144
158
  - !ruby/object:Gem::Version
145
- version: 1.10.0
159
+ version: 1.14.0
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
- version: 1.10.0
166
+ version: 1.14.0
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: serrano
155
169
  requirement: !ruby/object:Gem::Requirement
@@ -173,6 +187,7 @@ extensions: []
173
187
  extra_rdoc_files: []
174
188
  files:
175
189
  - ".github/workflows/rake.yml"
190
+ - ".github/workflows/release.yml"
176
191
  - ".gitignore"
177
192
  - ".rspec"
178
193
  - ".rubocop.yml"
@@ -185,6 +200,7 @@ files:
185
200
  - bin/setup
186
201
  - lib/relaton_doi.rb
187
202
  - lib/relaton_doi/crossref.rb
203
+ - lib/relaton_doi/processor.rb
188
204
  - lib/relaton_doi/version.rb
189
205
  - relaton-doi.gemspec
190
206
  homepage: https://github.com/relaton/relaton-doi
@@ -192,7 +208,7 @@ licenses:
192
208
  - BSD-2-Clause
193
209
  metadata:
194
210
  homepage_uri: https://github.com/relaton/relaton-doi
195
- post_install_message:
211
+ post_install_message:
196
212
  rdoc_options: []
197
213
  require_paths:
198
214
  - lib
@@ -203,12 +219,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
219
  version: 2.5.0
204
220
  required_rubygems_version: !ruby/object:Gem::Requirement
205
221
  requirements:
206
- - - ">"
222
+ - - ">="
207
223
  - !ruby/object:Gem::Version
208
- version: 1.3.1
224
+ version: '0'
209
225
  requirements: []
210
- rubygems_version: 3.2.3
211
- signing_key:
226
+ rubygems_version: 3.1.6
227
+ signing_key:
212
228
  specification_version: 4
213
229
  summary: 'RelatonDOI: retrieve Standards for bibliographic using DOI through Crossrefand
214
230
  provide Relaton object.'