commonmeta-ruby 3.2.4 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -6
- data/lib/commonmeta/cli.rb +17 -21
- data/lib/commonmeta/readers/json_feed_reader.rb +6 -11
- data/lib/commonmeta/utils.rb +2 -4
- data/lib/commonmeta/version.rb +1 -1
- data/spec/cli_spec.rb +2 -4
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/blog_post_uuid.yml +980 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/all_posts.yml +977 -0
- data/spec/readers/json_feed_reader_spec.rb +1 -19
- data/spec/utils_spec.rb +1 -7
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 575100d8bef2d51a19423453d3a5c3d7129903d5d7d23da7e7ac3c6c24ceb52b
|
4
|
+
data.tar.gz: 9146bae365bf7f79c1f3ce05e781942749b29257433ed1d37196b3d0d1d2bf21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82f95b057c1b28d1dd344f31207fc43d43f6db65705bbdc3609b02c90b9a4ed8ffd2d6a3538f090589c615e9207ad78046625344b99a1e592e9a4a624f414e4e
|
7
|
+
data.tar.gz: a6ff2bbe08b29b2641f35520e8fc46c8827f502e747b03b53f100235e7c0d639b8de4729ecfb6c7e41d1eee69e23fd9a6c0479e86471824797fe7bda1c78cc85
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
commonmeta-ruby (3.2.
|
4
|
+
commonmeta-ruby (3.2.6)
|
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)
|
@@ -98,7 +98,7 @@ GEM
|
|
98
98
|
json-ld-preloaded (3.2.2)
|
99
99
|
json-ld (~> 3.2)
|
100
100
|
rdf (~> 3.2)
|
101
|
-
json_schemer (1.0.
|
101
|
+
json_schemer (1.0.2)
|
102
102
|
hana (~> 1.3)
|
103
103
|
regexp_parser (~> 2.0)
|
104
104
|
simpleidn (~> 0.2)
|
@@ -122,20 +122,21 @@ GEM
|
|
122
122
|
oj (3.15.0)
|
123
123
|
optimist (3.0.1)
|
124
124
|
parallel (1.23.0)
|
125
|
-
parser (3.2.2.
|
125
|
+
parser (3.2.2.3)
|
126
126
|
ast (~> 2.4.1)
|
127
|
+
racc
|
127
128
|
postrank-uri (1.1)
|
128
129
|
addressable (>= 2.4.0)
|
129
130
|
nokogiri (>= 1.8.0)
|
130
131
|
public_suffix (>= 4.0.0, < 5)
|
131
132
|
public_suffix (4.0.7)
|
132
|
-
racc (1.
|
133
|
+
racc (1.7.0)
|
133
134
|
rack (3.0.7)
|
134
135
|
rack-test (2.1.0)
|
135
136
|
rack (>= 1.3)
|
136
137
|
rainbow (3.1.1)
|
137
138
|
rake (13.0.6)
|
138
|
-
rdf (3.2.
|
139
|
+
rdf (3.2.11)
|
139
140
|
link_header (~> 0.0, >= 0.0.8)
|
140
141
|
rdf-aggregate-repo (3.2.1)
|
141
142
|
rdf (~> 3.2)
|
@@ -218,7 +219,7 @@ GEM
|
|
218
219
|
rdf (~> 3.2)
|
219
220
|
temple (0.10.2)
|
220
221
|
thor (1.2.2)
|
221
|
-
tilt (2.
|
222
|
+
tilt (2.2.0)
|
222
223
|
tzinfo (2.0.6)
|
223
224
|
concurrent-ruby (~> 1.0)
|
224
225
|
unf (0.1.4)
|
data/lib/commonmeta/cli.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "thor"
|
4
4
|
|
5
|
-
require_relative
|
6
|
-
require_relative
|
5
|
+
require_relative "doi_utils"
|
6
|
+
require_relative "utils"
|
7
7
|
|
8
8
|
module Commonmeta
|
9
9
|
class CLI < Thor
|
@@ -18,18 +18,18 @@ module Commonmeta
|
|
18
18
|
# from http://stackoverflow.com/questions/22809972/adding-a-version-option-to-a-ruby-thor-cli
|
19
19
|
map %w[--version -v] => :__print_version
|
20
20
|
|
21
|
-
desc
|
21
|
+
desc "--version, -v", "print the version"
|
22
22
|
|
23
23
|
def __print_version
|
24
24
|
puts Commonmeta::VERSION
|
25
25
|
end
|
26
26
|
|
27
|
-
desc
|
28
|
-
method_option :from, aliases:
|
29
|
-
method_option :to, aliases:
|
27
|
+
desc "", "convert metadata"
|
28
|
+
method_option :from, aliases: "-f"
|
29
|
+
method_option :to, aliases: "-t", default: "schema_org"
|
30
30
|
method_option :regenerate, type: :boolean, force: false
|
31
|
-
method_option :style, aliases:
|
32
|
-
method_option :locale, aliases:
|
31
|
+
method_option :style, aliases: "-s", default: "apa"
|
32
|
+
method_option :locale, aliases: "-l", default: "en-US"
|
33
33
|
method_option :show_errors, type: :boolean, force: false
|
34
34
|
method_option :doi
|
35
35
|
method_option :depositor
|
@@ -47,7 +47,7 @@ module Commonmeta
|
|
47
47
|
depositor: options[:depositor],
|
48
48
|
email: options[:email],
|
49
49
|
registrant: options[:registrant])
|
50
|
-
to = options[:to] ||
|
50
|
+
to = options[:to] || "schema_org"
|
51
51
|
|
52
52
|
if options[:show_errors] && !metadata.valid?
|
53
53
|
warn metadata.errors
|
@@ -56,38 +56,34 @@ module Commonmeta
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
desc
|
59
|
+
desc "", "encode"
|
60
60
|
|
61
61
|
def encode(prefix)
|
62
62
|
puts encode_doi(prefix)
|
63
63
|
end
|
64
64
|
|
65
|
-
desc
|
65
|
+
desc "", "encode_id"
|
66
66
|
|
67
67
|
def encode_id
|
68
68
|
puts encode_container_id
|
69
69
|
end
|
70
70
|
|
71
|
-
desc
|
71
|
+
desc "", "decode"
|
72
72
|
|
73
73
|
def decode(doi)
|
74
74
|
puts decode_doi(doi)
|
75
75
|
end
|
76
76
|
|
77
|
-
desc
|
77
|
+
desc "", "decode_id"
|
78
78
|
|
79
79
|
def decode_id(id)
|
80
80
|
puts decode_container_id(id)
|
81
81
|
end
|
82
82
|
|
83
|
-
desc
|
83
|
+
desc "", "json_feed"
|
84
84
|
|
85
|
-
def json_feed
|
86
|
-
|
87
|
-
puts get_json_feed(id)
|
88
|
-
else
|
89
|
-
puts get_json_feed
|
90
|
-
end
|
85
|
+
def json_feed
|
86
|
+
puts get_json_feed
|
91
87
|
end
|
92
88
|
|
93
89
|
default_task :convert
|
@@ -9,7 +9,7 @@ module Commonmeta
|
|
9
9
|
url = normalize_id(id)
|
10
10
|
response = HTTP.get(url)
|
11
11
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
12
|
-
|
12
|
+
|
13
13
|
{ "string" => response.body.to_s }
|
14
14
|
end
|
15
15
|
|
@@ -74,20 +74,15 @@ module Commonmeta
|
|
74
74
|
"state" => state }.compact.merge(read_options)
|
75
75
|
end
|
76
76
|
|
77
|
-
def get_json_feed
|
77
|
+
def get_json_feed
|
78
78
|
# get JSON Feed items not registered as DOIs
|
79
|
-
|
80
|
-
url = json_feed_url
|
79
|
+
|
80
|
+
url = json_feed_url
|
81
81
|
response = HTTP.get(url)
|
82
82
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
blog["items"].select { |item| !validate_doi(item["id"]) }.map { |item| item["uuid"] }.first
|
87
|
-
else
|
88
|
-
posts = JSON.parse(response.body.to_s)
|
89
|
-
posts.select { |post| !validate_doi(post["id"]) }.map { |post| post["uuid"] }.first
|
90
|
-
end
|
84
|
+
posts = JSON.parse(response.body.to_s)
|
85
|
+
posts.map { |post| post["uuid"] }.first
|
91
86
|
end
|
92
87
|
end
|
93
88
|
end
|
data/lib/commonmeta/utils.rb
CHANGED
@@ -1381,10 +1381,8 @@ module Commonmeta
|
|
1381
1381
|
Base32::URL.decode(id)
|
1382
1382
|
end
|
1383
1383
|
|
1384
|
-
def json_feed_url
|
1385
|
-
|
1386
|
-
|
1387
|
-
"https://rogue-scholar.org/api/posts"
|
1384
|
+
def json_feed_url
|
1385
|
+
"https://rogue-scholar.org/api/posts/unregistered"
|
1388
1386
|
end
|
1389
1387
|
end
|
1390
1388
|
end
|
data/lib/commonmeta/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -342,10 +342,8 @@ describe Commonmeta::CLI do
|
|
342
342
|
end
|
343
343
|
|
344
344
|
describe "json_feed", vcr: true do
|
345
|
-
|
346
|
-
|
347
|
-
it "blog post" do
|
348
|
-
expect { subject.json_feed input }.to output(/89a326c6-f5d1-443a-99b8-ea75e705ce11\n/).to_stdout
|
345
|
+
it "blog post uuid" do
|
346
|
+
expect { subject.json_feed }.to output(/e4872b3e-cd15-407d-8406-33642c1a98b0\n/).to_stdout
|
349
347
|
end
|
350
348
|
end
|
351
349
|
end
|