commonmeta-ruby 3.3.4 → 3.3.6
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 +2 -2
- data/commonmeta.gemspec +1 -1
- data/lib/commonmeta/cli.rb +1 -5
- data/lib/commonmeta/utils.rb +15 -10
- data/lib/commonmeta/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edf931672f4de5668583515c8d61aff5b4538cf86b929d961866691dc56c0850
|
4
|
+
data.tar.gz: fcd58d117198ee30dd0387bd96ff38ad4c82d1b67b538fcf997661ed3d2019e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 466b00b27e4382baeccab8c5bc82adb516e9a68a2651ba4cb9bbeb6f3e5cc7d6665a25fcf07142dc19fa5ef1dabf4ab273c4c6a75d8377070ea5f54f96af3e5e
|
7
|
+
data.tar.gz: 07634a0d50aed5280e6536cafa0a68fbe267d5d4b1065039aa1d433b305cfd220379e8fb9eab66385b2aa15eea01afb02c974643eb98d6aeb12e399eb9d03b60
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
commonmeta-ruby (3.3.
|
4
|
+
commonmeta-ruby (3.3.6)
|
5
5
|
activesupport (>= 4.2.5, < 8.0)
|
6
6
|
addressable (~> 2.8.1, < 2.8.2)
|
7
7
|
base32-url (>= 0.7.0, < 1)
|
@@ -22,7 +22,7 @@ PATH
|
|
22
22
|
postrank-uri (~> 1.1)
|
23
23
|
rdf-rdfxml (~> 3.2)
|
24
24
|
rdf-turtle (~> 3.2)
|
25
|
-
thor (~> 1.
|
25
|
+
thor (~> 1.2, >= 1.2.2)
|
26
26
|
|
27
27
|
GEM
|
28
28
|
remote: https://rubygems.org/
|
data/commonmeta.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.add_dependency 'postrank-uri', '~> 1.1'
|
39
39
|
s.add_dependency 'rdf-rdfxml', '~> 3.2'
|
40
40
|
s.add_dependency 'rdf-turtle', '~> 3.2'
|
41
|
-
s.add_dependency 'thor', '~> 1.
|
41
|
+
s.add_dependency 'thor', '~> 1.2', '>= 1.2.2'
|
42
42
|
s.add_development_dependency 'bundler', '~> 2.3', '>= 2.3.1'
|
43
43
|
s.add_development_dependency 'code-scanning-rubocop', '~> 0.6.1'
|
44
44
|
s.add_development_dependency 'hashdiff', '~> 1.0.1'
|
data/lib/commonmeta/cli.rb
CHANGED
@@ -117,12 +117,8 @@ module Commonmeta
|
|
117
117
|
|
118
118
|
desc "", "update_ghost_post"
|
119
119
|
|
120
|
-
method_option :api_key, required: true
|
121
|
-
method_option :api_url, required: true
|
122
|
-
method_option :doi, required: true
|
123
|
-
|
124
120
|
def update_ghost_post(uuid)
|
125
|
-
puts update_ghost_post(uuid
|
121
|
+
puts update_ghost_post(uuid)
|
126
122
|
end
|
127
123
|
|
128
124
|
default_task :convert
|
data/lib/commonmeta/utils.rb
CHANGED
@@ -1473,25 +1473,30 @@ module Commonmeta
|
|
1473
1473
|
JWT.encode payload, [secret].pack("H*"), "HS256", header
|
1474
1474
|
end
|
1475
1475
|
|
1476
|
-
def update_ghost_post(uuid
|
1477
|
-
|
1476
|
+
def update_ghost_post(uuid)
|
1477
|
+
api_key = ENV["API_KEY"]
|
1478
|
+
api_url = ENV["API_URL"]
|
1479
|
+
|
1480
|
+
return nil unless uuid.present? && api_key.present? && api_url.present?
|
1478
1481
|
|
1479
1482
|
# generate short lived jwt for ghost admin api
|
1480
|
-
ghost_jwt = generate_ghost_token(
|
1483
|
+
ghost_jwt = generate_ghost_token(api_key)
|
1481
1484
|
|
1482
|
-
# get post url from Rogue Scholar API
|
1485
|
+
# get post url and doi from Rogue Scholar API
|
1483
1486
|
url = json_feed_item_by_uuid_url(uuid)
|
1484
1487
|
response = HTTP.get(url)
|
1485
1488
|
return nil unless response.status.success?
|
1486
1489
|
|
1487
1490
|
post = JSON.parse(response.body.to_s)
|
1488
1491
|
url = post.to_h.dig("url")
|
1489
|
-
|
1490
|
-
|
1492
|
+
doi = validate_doi(post.to_h.dig("id"))
|
1493
|
+
doi = doi_as_url(doi)
|
1494
|
+
|
1495
|
+
return nil unless url.present? && doi.present?
|
1491
1496
|
|
1492
1497
|
# get id and updated_at from ghost api
|
1493
1498
|
slug = url.chomp("/").split("/").last
|
1494
|
-
ghost_url = "#{
|
1499
|
+
ghost_url = "#{api_url}/ghost/api/admin/posts/slug/#{slug}/"
|
1495
1500
|
response = HTTP.auth("Ghost #{ghost_jwt}").get(ghost_url)
|
1496
1501
|
return nil unless response.status.success?
|
1497
1502
|
|
@@ -1502,9 +1507,9 @@ module Commonmeta
|
|
1502
1507
|
return nil unless id.present? && updated_at.present?
|
1503
1508
|
|
1504
1509
|
# update post canonical_url with new doi
|
1505
|
-
ghost_url = "#{
|
1506
|
-
response = HTTP.auth("Ghost #{ghost_jwt}").headers('Content-Type' => "application/json", 'Accept-Version' => 'v5').put(ghost_url, :json => { 'posts' => [{ 'canonical_url' =>
|
1507
|
-
"#{response.status} DOI #{
|
1510
|
+
ghost_url = "#{api_url}/ghost/api/admin/posts/#{id}/"
|
1511
|
+
response = HTTP.auth("Ghost #{ghost_jwt}").headers('Content-Type' => "application/json", 'Accept-Version' => 'v5').put(ghost_url, :json => { 'posts' => [{ 'canonical_url' => doi, 'updated_at' => updated_at }] })
|
1512
|
+
"#{response.status} DOI #{doi} added to post #{uuid}"
|
1508
1513
|
end
|
1509
1514
|
end
|
1510
1515
|
end
|
data/lib/commonmeta/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commonmeta-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Fenner
|
@@ -344,20 +344,20 @@ dependencies:
|
|
344
344
|
requirements:
|
345
345
|
- - "~>"
|
346
346
|
- !ruby/object:Gem::Version
|
347
|
-
version: '1.
|
347
|
+
version: '1.2'
|
348
348
|
- - ">="
|
349
349
|
- !ruby/object:Gem::Version
|
350
|
-
version: 1.
|
350
|
+
version: 1.2.2
|
351
351
|
type: :runtime
|
352
352
|
prerelease: false
|
353
353
|
version_requirements: !ruby/object:Gem::Requirement
|
354
354
|
requirements:
|
355
355
|
- - "~>"
|
356
356
|
- !ruby/object:Gem::Version
|
357
|
-
version: '1.
|
357
|
+
version: '1.2'
|
358
358
|
- - ">="
|
359
359
|
- !ruby/object:Gem::Version
|
360
|
-
version: 1.
|
360
|
+
version: 1.2.2
|
361
361
|
- !ruby/object:Gem::Dependency
|
362
362
|
name: bundler
|
363
363
|
requirement: !ruby/object:Gem::Requirement
|