commonmeta-ruby 3.3.15 → 3.3.17
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/commonmeta/readers/json_feed_reader.rb +8 -8
- data/lib/commonmeta/utils.rb +14 -0
- data/lib/commonmeta/version.rb +1 -1
- data/spec/cli_spec.rb +2 -2
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/json_feed_by_blog.yml +189 -1704
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/json_feed_unregistered.yml +54 -1969
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/by_blog_id.yml +210 -518
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/not_indexed_posts.yml +6 -1450
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/unregistered_posts.yml +54 -8
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/blog_post_with_non-url_id.yml +18 -88
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/blogger_post.yml +11 -50
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/ghost_post_with_author_name_suffix.yml +64 -173
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/ghost_post_with_doi.yml +13 -75
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/ghost_post_with_institutional_author.yml +15 -11
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/ghost_post_with_organizational_author.yml +15 -46
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/ghost_post_without_doi.yml +17 -155
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/jekyll_post.yml +14 -45
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/jekyll_post_with_anonymous_author.yml +13 -16
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/substack_post_with_broken_reference.yml +938 -1865
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/syldavia_gazette_post_with_references.yml +128 -267
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/upstream_post_with_references.yml +570 -1279
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/wordpress_post.yml +12 -119
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/wordpress_post_with_many_references.yml +4095 -5759
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/wordpress_post_with_references.yml +24 -220
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed_item_metadata/wordpress_post_with_tracking_code_on_url.yml +13 -12
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_from_rogue_scholar_with_anonymous_author.yml +13 -16
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_from_rogue_scholar_with_doi.yml +12 -119
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_from_rogue_scholar_with_organizational_author.yml +15 -46
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_from_upstream_blog.yml +13 -201
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/write_metadata_as_crossref/json_feed_item_with_references.yml +104 -813
- data/spec/readers/json_feed_reader_spec.rb +22 -24
- data/spec/utils_spec.rb +40 -0
- data/spec/writers/crossref_xml_writer_spec.rb +4 -4
- metadata +2 -5
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/blog_post.yml +0 -360
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/blog_post_uuid.yml +0 -980
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed_unregistered/blog_post_uuid.yml +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d9089eaa55c76c89411f0b252418860d40c498b77ad5e07ff6937d26364fff4
|
4
|
+
data.tar.gz: b251346f6fd8fe1714632587ee46196b00c3c4bb8c4ba7bf0fe6decd54c5a9e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87733ee7cf23b71317df6c8ef7ad2eea099db43a6291a948f93b18220aeff5f3cf72e8ec9a9b0e36b3f243fe7b651d1b7d401341d0cf0524d0a6c3ea0db1bc7f
|
7
|
+
data.tar.gz: 131dbb14b63cca5c62acce085746f0dc13ef99252bd9243a84c0565a5e671e45c613cc12903df297e4c9df8bd0f5a6d69b645d18e622dd895c0d120e0d7b7f46
|
data/Gemfile.lock
CHANGED
@@ -21,7 +21,7 @@ module Commonmeta
|
|
21
21
|
meta = string.present? ? JSON.parse(string) : {}
|
22
22
|
|
23
23
|
url = normalize_url(meta.fetch("url", nil))
|
24
|
-
id = options[:doi] ? normalize_doi(options[:doi]) : normalize_id(meta.fetch("
|
24
|
+
id = options[:doi] ? normalize_doi(options[:doi]) : normalize_id(meta.fetch("doi", nil))
|
25
25
|
id = url if id.blank? && url.present?
|
26
26
|
|
27
27
|
type = "Article"
|
@@ -34,8 +34,8 @@ module Commonmeta
|
|
34
34
|
publisher = { "name" => meta.dig("blog", "title") }
|
35
35
|
|
36
36
|
date = {}
|
37
|
-
date["published"] =
|
38
|
-
date["updated"] =
|
37
|
+
date["published"] = get_date_from_unix_timestamp(meta.dig("published_at")) if meta.dig("published_at").present?
|
38
|
+
date["updated"] = get_date_from_unix_timestamp(meta.dig("updated_at")) if meta.dig("updated_at").present?
|
39
39
|
|
40
40
|
license = if meta.dig("blog", "license").present?
|
41
41
|
hsh_to_spdx("rightsURI" => meta.dig("blog", "license"))
|
@@ -62,7 +62,7 @@ module Commonmeta
|
|
62
62
|
sum
|
63
63
|
end
|
64
64
|
references = get_references(meta)
|
65
|
-
alternate_identifiers = [{ "alternateIdentifier" => meta["
|
65
|
+
alternate_identifiers = [{ "alternateIdentifier" => meta["id"], "alternateIdentifierType" => "UUID" }]
|
66
66
|
|
67
67
|
{ "id" => id,
|
68
68
|
"type" => type,
|
@@ -83,7 +83,7 @@ module Commonmeta
|
|
83
83
|
|
84
84
|
def get_references(meta)
|
85
85
|
# check that references resolve
|
86
|
-
Array.wrap(meta["
|
86
|
+
Array.wrap(meta["reference"]).reduce([]) do |sum, reference|
|
87
87
|
begin
|
88
88
|
if reference["doi"] && validate_doi(reference["doi"])
|
89
89
|
response = HTTP.follow
|
@@ -111,7 +111,7 @@ module Commonmeta
|
|
111
111
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
112
112
|
|
113
113
|
posts = JSON.parse(response.body.to_s)
|
114
|
-
posts.map { |post| post["
|
114
|
+
posts.map { |post| post["id"] }.first
|
115
115
|
end
|
116
116
|
|
117
117
|
def get_json_feed_not_indexed
|
@@ -122,7 +122,7 @@ module Commonmeta
|
|
122
122
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
123
123
|
|
124
124
|
posts = JSON.parse(response.body.to_s)
|
125
|
-
posts.map { |post| post["
|
125
|
+
posts.map { |post| post["id"] }.first
|
126
126
|
end
|
127
127
|
|
128
128
|
def get_json_feed_by_blog(blog_id)
|
@@ -133,7 +133,7 @@ module Commonmeta
|
|
133
133
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
134
134
|
|
135
135
|
blog = JSON.parse(response.body.to_s)
|
136
|
-
blog["items"].map { |item| item["
|
136
|
+
blog["items"].map { |item| item["id"] }.first
|
137
137
|
end
|
138
138
|
|
139
139
|
def get_doi_prefix_by_blog_id(blog_id)
|
data/lib/commonmeta/utils.rb
CHANGED
@@ -1094,6 +1094,20 @@ module Commonmeta
|
|
1094
1094
|
nil
|
1095
1095
|
end
|
1096
1096
|
|
1097
|
+
# parsing of unix timestamps such as 1427846400
|
1098
|
+
def get_datetime_from_unix_timestamp(unix_timestamp)
|
1099
|
+
strip_milliseconds(DateTime.strptime(unix_timestamp.to_s, '%s').iso8601)
|
1100
|
+
rescue StandardError
|
1101
|
+
nil
|
1102
|
+
end
|
1103
|
+
|
1104
|
+
# parsing of unix timestamps such as 1427846400
|
1105
|
+
def get_date_from_unix_timestamp(unix_timestamp)
|
1106
|
+
DateTime.strptime(unix_timestamp.to_s, '%s').strftime('%Y-%m-%d')
|
1107
|
+
rescue StandardError
|
1108
|
+
nil
|
1109
|
+
end
|
1110
|
+
|
1097
1111
|
# strip milliseconds if there is a time, as it interferes with edtc parsing
|
1098
1112
|
# keep dates unchanged
|
1099
1113
|
def strip_milliseconds(iso8601_time)
|
data/lib/commonmeta/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -367,7 +367,7 @@ describe Commonmeta::CLI do
|
|
367
367
|
|
368
368
|
describe "json_feed", vcr: true do
|
369
369
|
it "json_feed_unregistered" do
|
370
|
-
expect { subject.json_feed_unregistered }.to output(/
|
370
|
+
expect { subject.json_feed_unregistered }.to output(/3023e24a-817d-452e-bb6e-ddadecce94c6/).to_stdout
|
371
371
|
end
|
372
372
|
|
373
373
|
it "json_feed_not_indexed" do
|
@@ -376,7 +376,7 @@ describe Commonmeta::CLI do
|
|
376
376
|
|
377
377
|
it "json_feed_by_blog" do
|
378
378
|
input = "tyfqw20"
|
379
|
-
expect { subject.json_feed_by_blog input }.to output(/
|
379
|
+
expect { subject.json_feed_by_blog input }.to output(/37538c38-66e6-4ac4-ab5c-679684622ade/).to_stdout
|
380
380
|
end
|
381
381
|
end
|
382
382
|
end
|