commonmeta-ruby 3.0.10 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +37 -36
  3. data/bin/commonmeta +1 -1
  4. data/commonmeta.gemspec +1 -1
  5. data/lib/commonmeta/cli.rb +7 -0
  6. data/lib/commonmeta/metadata_utils.rb +2 -0
  7. data/lib/commonmeta/readers/json_feed_reader.rb +90 -0
  8. data/lib/commonmeta/utils.rb +23 -0
  9. data/lib/commonmeta/version.rb +1 -1
  10. data/spec/author_utils_spec.rb +10 -0
  11. data/spec/cli_spec.rb +8 -0
  12. data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/blog_post.yml +360 -0
  13. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/citation_style_language.yml +360 -0
  14. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/citation_style_language_blog.yml +360 -0
  15. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/front-matter_blog.yml +1034 -0
  16. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/upstream.yml +2438 -0
  17. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/upstream_blog.yml +2438 -0
  18. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/blogger_post.yml +94 -0
  19. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/ghost_post_with_doi.yml +117 -0
  20. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/jekyll_post.yml +87 -0
  21. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/wordpress_post.yml +163 -0
  22. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_metadata/blogger_post.yml +141 -0
  23. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_metadata/ghost_post_with_doi.yml +164 -0
  24. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_metadata/jekyll_post.yml +134 -0
  25. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_metadata/wordpress_post.yml +210 -0
  26. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/blogger_post.yml +94 -0
  27. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/ghost_post.yml +117 -0
  28. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/ghost_post_with_doi.yml +117 -0
  29. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/jekyll_post.yml +170 -0
  30. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_item_metadata/wordpress_post.yml +163 -0
  31. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/blogger_post.yml +141 -0
  32. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/ghost_post_with_doi.yml +164 -0
  33. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/jekyll_post.yml +134 -0
  34. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_post_metadata/wordpress_post.yml +210 -0
  35. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_link/license.yml +221 -0
  36. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_link/url.yml +221 -0
  37. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/json_feed_url/front-matter_blog.yml +221 -0
  38. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_from_rogue_scholar_with_doi.yml +163 -0
  39. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_from_upstream_blog.yml +243 -0
  40. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_item_from_rogue_scholar_with_doi.yml +163 -0
  41. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_item_from_upstream_blog.yml +243 -0
  42. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_post_from_rogue_scholar_with_doi.yml +210 -0
  43. data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_post_from_upstream_blog.yml +290 -0
  44. data/spec/readers/json_feed_reader_spec.rb +110 -0
  45. data/spec/utils_spec.rb +338 -314
  46. data/spec/writers/crossref_xml_writer_spec.rb +183 -137
  47. metadata +39 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbd0cff9167f3cf4cbef16d1b2f344dfbaaaa0c5f121f385f8e2703fedd42b0d
4
- data.tar.gz: 601f92cc97809057378e7dd89e36d1918a18280201b25a25ad8a13ecd1412a04
3
+ metadata.gz: 6489e2d1d9225e98fbf809c51986da2d9959b25dadc51ab5637a8fa43181e743
4
+ data.tar.gz: 0b4d31c968f52baf74848fc51290123db1645503f55840172c01aacb43ec5753
5
5
  SHA512:
6
- metadata.gz: d0e2953f19c0364ad7f774fe38be92bf9df6b975c02568e980ac4cfb7a0fae590aeda39df9d3c80332701db4cc7bfd81648c987b1e96eed6cd1595baf758376d
7
- data.tar.gz: 76b133fe3e101ba09c62c362d41035fd323e262575338866bacdbd2e07544b4b1e63583c304c827f9c386c22c7ea45c7f2b0c6eb304cf060b10f8e32e77e3796
6
+ metadata.gz: c6224cacab63d37765875e6e23fe1c70b7443e603b895866d2b192fb5d823d7d98d8613eae03e56debf9fea1a02f7a13f45a4ed5b0d2f37990368a6fe18c8182
7
+ data.tar.gz: c07f1ff76a51a313a96a881077b1a3f5ee918a3cf7012c5edbdd8dce24381d856994b840b76563185fc220ac3f3c75c5edf4e06c6c69524ab48b526b63c1d5d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- commonmeta-ruby (3.0.10)
4
+ commonmeta-ruby (3.2.1)
5
5
  activesupport (>= 4.2.5, < 8.0)
6
6
  addressable (~> 2.8.1, < 2.8.2)
7
7
  base32-url (>= 0.5.0, < 1)
@@ -13,7 +13,7 @@ PATH
13
13
  gender_detector (~> 2.0)
14
14
  http (~> 5.1, >= 5.1.1)
15
15
  json-ld-preloaded (~> 3.2, >= 3.2.2)
16
- json_schemer (~> 0.2.23)
16
+ json_schemer (~> 1.0.1)
17
17
  jsonlint (~> 0.3.0)
18
18
  loofah (~> 2.19)
19
19
  namae (~> 1.0)
@@ -25,7 +25,7 @@ PATH
25
25
  GEM
26
26
  remote: https://rubygems.org/
27
27
  specs:
28
- activesupport (7.0.4.3)
28
+ activesupport (7.0.5)
29
29
  concurrent-ruby (~> 1.0, >= 1.0.2)
30
30
  i18n (>= 1.6, < 2)
31
31
  minitest (>= 5.1)
@@ -57,14 +57,12 @@ GEM
57
57
  docile (1.4.0)
58
58
  domain_name (0.5.20190701)
59
59
  unf (>= 0.0.5, < 1.0.0)
60
- ebnf (2.3.2)
60
+ ebnf (2.3.3)
61
61
  htmlentities (~> 4.3)
62
62
  rdf (~> 3.2)
63
63
  scanf (~> 1.0)
64
64
  sxp (~> 1.2)
65
65
  unicode-types (~> 1.8)
66
- ecma-re-validator (0.4.0)
67
- regexp_parser (~> 2.2)
68
66
  edtf (3.1.1)
69
67
  activesupport (>= 3.0, < 8.0)
70
68
  ffi (1.15.5)
@@ -86,25 +84,24 @@ GEM
86
84
  http-cookie (1.0.5)
87
85
  domain_name (~> 0.5)
88
86
  http-form_data (2.3.0)
89
- i18n (1.12.0)
87
+ i18n (1.14.0)
90
88
  concurrent-ruby (~> 1.0)
91
89
  json (2.6.3)
92
- json-canonicalization (0.3.1)
93
- json-ld (3.2.3)
90
+ json-canonicalization (0.3.2)
91
+ json-ld (3.2.5)
94
92
  htmlentities (~> 4.3)
95
- json-canonicalization (~> 0.3)
93
+ json-canonicalization (~> 0.3, >= 0.3.2)
96
94
  link_header (~> 0.0, >= 0.0.8)
97
95
  multi_json (~> 1.15)
98
- rack (~> 2.2)
99
- rdf (~> 3.2, >= 3.2.9)
96
+ rack (>= 2.2, < 4)
97
+ rdf (~> 3.2, >= 3.2.10)
100
98
  json-ld-preloaded (3.2.2)
101
99
  json-ld (~> 3.2)
102
100
  rdf (~> 3.2)
103
- json_schemer (0.2.24)
104
- ecma-re-validator (~> 0.3)
101
+ json_schemer (1.0.1)
105
102
  hana (~> 1.3)
106
103
  regexp_parser (~> 2.0)
107
- uri_template (~> 0.7)
104
+ simpleidn (~> 0.2)
108
105
  jsonlint (0.3.0)
109
106
  oj (~> 3)
110
107
  optimist (~> 3)
@@ -113,19 +110,19 @@ GEM
113
110
  llhttp-ffi (0.4.0)
114
111
  ffi-compiler (~> 1.0)
115
112
  rake (~> 13.0)
116
- loofah (2.20.0)
113
+ loofah (2.21.3)
117
114
  crass (~> 1.0.2)
118
- nokogiri (>= 1.5.9)
115
+ nokogiri (>= 1.12.0)
119
116
  matrix (0.4.2)
120
117
  minitest (5.18.0)
121
118
  multi_json (1.15.0)
122
119
  namae (1.1.1)
123
- nokogiri (1.14.3-arm64-darwin)
120
+ nokogiri (1.15.2-arm64-darwin)
124
121
  racc (~> 1.4)
125
- oj (3.14.3)
122
+ oj (3.15.0)
126
123
  optimist (3.0.1)
127
- parallel (1.22.1)
128
- parser (3.2.2.0)
124
+ parallel (1.23.0)
125
+ parser (3.2.2.1)
129
126
  ast (~> 2.4.1)
130
127
  postrank-uri (1.1)
131
128
  addressable (>= 2.4.0)
@@ -133,12 +130,12 @@ GEM
133
130
  public_suffix (>= 4.0.0, < 5)
134
131
  public_suffix (4.0.7)
135
132
  racc (1.6.2)
136
- rack (2.2.6.4)
133
+ rack (3.0.7)
137
134
  rack-test (2.1.0)
138
135
  rack (>= 1.3)
139
136
  rainbow (3.1.1)
140
137
  rake (13.0.6)
141
- rdf (3.2.9)
138
+ rdf (3.2.10)
142
139
  link_header (~> 0.0, >= 0.0.8)
143
140
  rdf-aggregate-repo (3.2.1)
144
141
  rdf (~> 3.2)
@@ -158,20 +155,20 @@ GEM
158
155
  rdf-turtle (3.2.1)
159
156
  ebnf (~> 2.3)
160
157
  rdf (~> 3.2)
161
- rdf-vocab (3.2.5)
158
+ rdf-vocab (3.2.6)
162
159
  rdf (~> 3.2, >= 3.2.4)
163
160
  rdf-xsd (3.2.1)
164
161
  rdf (~> 3.2)
165
162
  rexml (~> 3.2)
166
- regexp_parser (2.7.0)
163
+ regexp_parser (2.8.0)
167
164
  rexml (3.2.5)
168
165
  rspec (3.12.0)
169
166
  rspec-core (~> 3.12.0)
170
167
  rspec-expectations (~> 3.12.0)
171
168
  rspec-mocks (~> 3.12.0)
172
- rspec-core (3.12.1)
169
+ rspec-core (3.12.2)
173
170
  rspec-support (~> 3.12.0)
174
- rspec-expectations (3.12.2)
171
+ rspec-expectations (3.12.3)
175
172
  diff-lcs (>= 1.2.0, < 2.0)
176
173
  rspec-support (~> 3.12.0)
177
174
  rspec-mocks (3.12.5)
@@ -181,7 +178,7 @@ GEM
181
178
  rspec-xsd (0.1.0)
182
179
  nokogiri (~> 1.6)
183
180
  rspec (~> 3)
184
- rubocop (1.50.1)
181
+ rubocop (1.52.0)
185
182
  json (~> 2.3)
186
183
  parallel (~> 1.10)
187
184
  parser (>= 3.2.0.0)
@@ -191,18 +188,21 @@ GEM
191
188
  rubocop-ast (>= 1.28.0, < 2.0)
192
189
  ruby-progressbar (~> 1.7)
193
190
  unicode-display_width (>= 2.4.0, < 3.0)
194
- rubocop-ast (1.28.0)
191
+ rubocop-ast (1.29.0)
195
192
  parser (>= 3.2.1.0)
196
- rubocop-capybara (2.17.1)
193
+ rubocop-capybara (2.18.0)
197
194
  rubocop (~> 1.41)
198
- rubocop-performance (1.17.1)
195
+ rubocop-factory_bot (2.23.1)
196
+ rubocop (~> 1.33)
197
+ rubocop-performance (1.18.0)
199
198
  rubocop (>= 1.7.0, < 2.0)
200
199
  rubocop-ast (>= 0.4.0)
201
200
  rubocop-rake (0.6.0)
202
201
  rubocop (~> 1.0)
203
- rubocop-rspec (2.19.0)
202
+ rubocop-rspec (2.22.0)
204
203
  rubocop (~> 1.33)
205
204
  rubocop-capybara (~> 2.17)
205
+ rubocop-factory_bot (~> 2.22)
206
206
  ruby-progressbar (1.13.0)
207
207
  scanf (1.0.0)
208
208
  simplecov (0.22.0)
@@ -211,11 +211,13 @@ GEM
211
211
  simplecov_json_formatter (~> 0.1)
212
212
  simplecov-html (0.12.3)
213
213
  simplecov_json_formatter (0.1.4)
214
- sxp (1.2.3)
214
+ simpleidn (0.2.1)
215
+ unf (~> 0.1.4)
216
+ sxp (1.2.4)
215
217
  matrix (~> 0.4)
216
218
  rdf (~> 3.2)
217
- temple (0.10.0)
218
- thor (1.2.1)
219
+ temple (0.10.2)
220
+ thor (1.2.2)
219
221
  tilt (2.1.0)
220
222
  tzinfo (2.0.6)
221
223
  concurrent-ruby (~> 1.0)
@@ -224,7 +226,6 @@ GEM
224
226
  unf_ext (0.0.8.2)
225
227
  unicode-display_width (2.4.2)
226
228
  unicode-types (1.8.0)
227
- uri_template (0.7.0)
228
229
  vcr (6.1.0)
229
230
  webmock (3.18.1)
230
231
  addressable (>= 2.8.0)
data/bin/commonmeta CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.expand_path("../../lib/commonmeta", __FILE__)
4
4
 
5
- if (ARGV & %w(--version -v help --help encode decode encode_id decode_id)).empty?
5
+ if (ARGV & %w(--version -v help --help encode decode encode_id decode_id json_feed)).empty?
6
6
  Commonmeta::CLI.start(ARGV.dup.unshift("convert"))
7
7
  else
8
8
  Commonmeta::CLI.start
data/commonmeta.gemspec CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.add_dependency 'http', '~> 5.1', '>= 5.1.1'
31
31
  s.add_dependency 'json-ld-preloaded', '~> 3.2', '>= 3.2.2'
32
32
  s.add_dependency 'jsonlint', '~> 0.3.0'
33
- s.add_dependency 'json_schemer', '~> 0.2.23'
33
+ s.add_dependency 'json_schemer', '~> 1.0.1'
34
34
  s.add_dependency 'loofah', '~> 2.19'
35
35
  s.add_dependency 'namae', '~> 1.0'
36
36
  s.add_dependency 'postrank-uri', '~> 1.1'
@@ -9,6 +9,7 @@ module Commonmeta
9
9
  class CLI < Thor
10
10
  include Commonmeta::DoiUtils
11
11
  include Commonmeta::Utils
12
+ include Commonmeta::Readers::JsonFeedReader
12
13
 
13
14
  def self.exit_on_failure?
14
15
  true
@@ -79,6 +80,12 @@ module Commonmeta
79
80
  puts decode_container_id(id)
80
81
  end
81
82
 
83
+ desc '', 'feed'
84
+
85
+ def json_feed(id)
86
+ puts get_json_feed(id)
87
+ end
88
+
82
89
  default_task :convert
83
90
  end
84
91
  end
@@ -13,6 +13,7 @@ require_relative 'readers/codemeta_reader'
13
13
  require_relative 'readers/crossref_reader'
14
14
  require_relative 'readers/crossref_xml_reader'
15
15
  require_relative 'readers/datacite_reader'
16
+ require_relative 'readers/json_feed_reader'
16
17
  require_relative 'readers/npm_reader'
17
18
  require_relative 'readers/ris_reader'
18
19
  require_relative 'readers/schema_org_reader'
@@ -46,6 +47,7 @@ module Commonmeta
46
47
  include Commonmeta::Readers::CrossrefXmlReader
47
48
  include Commonmeta::Readers::CslReader
48
49
  include Commonmeta::Readers::DataciteReader
50
+ include Commonmeta::Readers::JsonFeedReader
49
51
  include Commonmeta::Readers::NpmReader
50
52
  include Commonmeta::Readers::RisReader
51
53
  include Commonmeta::Readers::SchemaOrgReader
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Commonmeta
4
+ module Readers
5
+ module JsonFeedReader
6
+ def get_json_feed_item(id: nil, **_options)
7
+ return { "string" => nil, "state" => "not_found" } unless id.present?
8
+
9
+ url = normalize_id(id)
10
+ response = HTTP.get(url)
11
+ return { "string" => nil, "state" => "not_found" } unless response.status.success?
12
+
13
+ { "string" => response.body.to_s }
14
+ end
15
+
16
+ def read_json_feed_item(string: nil, **options)
17
+ read_options = ActiveSupport::HashWithIndifferentAccess.new(options.except(:doi, :id, :url,
18
+ :sandbox, :validate, :ra))
19
+
20
+ meta = string.present? ? JSON.parse(string) : {}
21
+
22
+ id = options[:doi] ? normalize_doi(options[:doi]) : normalize_id(meta.fetch("id", nil))
23
+ url = normalize_url(meta.fetch("url", nil))
24
+ type = "Article"
25
+ creators = if meta.fetch("authors", nil).present?
26
+ get_authors(from_json_feed(Array.wrap(meta.fetch("authors"))))
27
+ else
28
+ [{ "type" => "Organization", "name" => ":(unav)" }]
29
+ end
30
+ titles = [{ "title" => meta.fetch("title", nil) }]
31
+ publisher = { "name" => meta.dig("blog", "title") }
32
+
33
+ date = {}
34
+ date["published"] = get_iso8601_date(meta.dig("date_published")) if meta.dig("date_published").present?
35
+ date["updated"] = get_iso8601_date(meta.dig("date_modified")) if meta.dig("date_modified").present?
36
+
37
+ license = if meta.dig("blog", "license").present?
38
+ hsh_to_spdx("rightsURI" => meta.dig("blog", "license"))
39
+ end
40
+ home_page_url = normalize_url(meta.dig("blog", "home_page_url"))
41
+ container = if meta.dig("blog", "title").present?
42
+ { "type" => "Periodical",
43
+ "title" => meta.dig("blog", "title"),
44
+ "identifier" => home_page_url,
45
+ "identifierType" => "URL" }
46
+ end
47
+
48
+ descriptions = if meta.fetch("summary", nil).present?
49
+ [{ "description" => sanitize(meta.fetch("summary", nil)),
50
+ "descriptionType" => "Abstract" }]
51
+ else
52
+ []
53
+ end
54
+ language = meta.fetch("language", nil) || meta.fetch("blog", "language", nil)
55
+ state = id.present? || read_options.present? ? "findable" : "not_found"
56
+ subjects = Array.wrap(meta.fetch("tags", nil)).reduce([]) do |sum, subject|
57
+ sum += name_to_fos(subject)
58
+
59
+ sum
60
+ end
61
+
62
+ { "id" => id,
63
+ "type" => type,
64
+ "url" => url,
65
+ "titles" => titles,
66
+ "creators" => creators,
67
+ "publisher" => publisher,
68
+ "container" => container,
69
+ "date" => date,
70
+ "language" => language,
71
+ "descriptions" => descriptions,
72
+ "license" => license,
73
+ "subjects" => subjects.presence,
74
+ "state" => state }.compact.merge(read_options)
75
+ end
76
+
77
+ def get_json_feed(id)
78
+ # get JSON Feed items not registered as DOIs
79
+ return { "string" => nil, "state" => "not_found" } unless id.present?
80
+
81
+ url = json_feed_url(id)
82
+ response = HTTP.get(url)
83
+ return { "string" => nil, "state" => "not_found" } unless response.status.success?
84
+
85
+ blog = JSON.parse(response.body.to_s)
86
+ blog["items"].select { |item| !validate_doi(item["id"]) }.map { |item| item["short_id"] }.join(",").presence
87
+ end
88
+ end
89
+ end
90
+ end
@@ -468,6 +468,8 @@ module Commonmeta
468
468
  "cff"
469
469
  elsif %r{\A(http|https):/(/)?github\.com/(.+)\z}.match?(id)
470
470
  "cff"
471
+ elsif %r{\A(http|https):/(/)?rogue-scholar\.org/api/posts/(.+)\z}.match?(id)
472
+ "json_feed_item"
471
473
  else
472
474
  "schema_org"
473
475
  end
@@ -875,6 +877,12 @@ module Commonmeta
875
877
  }
876
878
  end
877
879
 
880
+ def from_json_feed(element)
881
+ mapping = { "url" => "id" }
882
+
883
+ map_hash_keys(element: element, mapping: mapping)
884
+ end
885
+
878
886
  def from_csl(element)
879
887
  Array.wrap(element).map do |a|
880
888
  if a["literal"].present?
@@ -1068,6 +1076,8 @@ module Commonmeta
1068
1076
 
1069
1077
  return iso8601_time.split(".").first + "Z" if iso8601_time.to_s.include? "."
1070
1078
 
1079
+ return iso8601_time.split("+").first + "Z" if iso8601_time.to_s.include? "+"
1080
+
1071
1081
  iso8601_time
1072
1082
  end
1073
1083
 
@@ -1084,6 +1094,15 @@ module Commonmeta
1084
1094
  dd.fetch("date", nil)
1085
1095
  end
1086
1096
 
1097
+ def get_link(links, link_type)
1098
+ ll = Array.wrap(links).find { |d| d["rel"] == link_type } || {}
1099
+ ll.fetch("href", nil)
1100
+ end
1101
+
1102
+ def rogue_scholar_api_url(id, _options = {})
1103
+ "https://rogue-scholar.org/api/posts/#{id}"
1104
+ end
1105
+
1087
1106
  # convert commonmeta dates to DataCite format
1088
1107
  def get_dates_from_date(date)
1089
1108
  return nil if date.nil?
@@ -1361,5 +1380,9 @@ module Commonmeta
1361
1380
  def decode_container_id(id)
1362
1381
  Base32::URL.decode(id)
1363
1382
  end
1383
+
1384
+ def json_feed_url(id)
1385
+ "https://rogue-scholar.org/api/blogs/#{id}"
1386
+ end
1364
1387
  end
1365
1388
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmeta
4
- VERSION = '3.0.10'
4
+ VERSION = '3.2.1'
5
5
  end
@@ -40,6 +40,16 @@ describe Commonmeta::Metadata, vcr: true do
40
40
  expect(subject.is_personal_name?(name: author['name'])).to be true
41
41
  end
42
42
 
43
+ it 'has unknown given name' do
44
+ author = { 'name' => 'Rintze Zelle' }
45
+ expect(subject.is_personal_name?(name: author['name'])).to be false
46
+ end
47
+
48
+ it 'has middle initial' do
49
+ author = { 'name' => 'Martin H. Fenner' }
50
+ expect(subject.is_personal_name?(name: author['name'])).to be true
51
+ end
52
+
43
53
  it 'has no info' do
44
54
  author = { 'name' => 'M Fenner' }
45
55
  expect(subject.is_personal_name?(name: author['name'])).to be false
data/spec/cli_spec.rb CHANGED
@@ -340,4 +340,12 @@ describe Commonmeta::CLI do
340
340
  expect { subject.decode_id input }.to output(/18397685862\n/).to_stdout
341
341
  end
342
342
  end
343
+
344
+ describe "json_feed", vcr: true do
345
+ let(:input) { "prmb582" }
346
+
347
+ it "blog post" do
348
+ expect { subject.json_feed input }.to output(/1jdkoe52,4qe9ypg1,1jdkwod5,56glp9d9,1xdnk0d0,56glmmd9,1xdnoje0,31epl0dn,q0dqm6go\n/).to_stdout
349
+ end
350
+ end
343
351
  end