commonmeta-ruby 3.2.10 → 3.2.12
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/bin/commonmeta +1 -1
- data/lib/commonmeta/cli.rb +13 -1
- data/lib/commonmeta/readers/json_feed_reader.rb +14 -3
- data/lib/commonmeta/utils.rb +8 -0
- data/lib/commonmeta/version.rb +1 -1
- data/spec/cli_spec.rb +6 -5
- data/spec/fixtures/vcr_cassettes/Commonmeta_CLI/json_feed/json_feed_by_blog.yml +1791 -0
- data/spec/fixtures/vcr_cassettes/Commonmeta_Metadata/get_json_feed/by_blog_id.yml +1791 -0
- data/spec/readers/json_feed_reader_spec.rb +6 -0
- data/spec/utils_spec.rb +0 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb3a97138b6b57a503b29202613fd81d5124c66ef2523ba9ef7cccccb78d7ff8
|
4
|
+
data.tar.gz: 0b9f6d3b310604ff2bb567b0ae13ae025d9c954c77669d9adec2f3e1bd36f307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8262107294fc3be73c4b39ed45a662f1cd0e6a98702deb5bbc65fe91b8e9a31e890d33e38246c5852232be35746ce40d3cc9c77a9314a979dbf7c659b8826b56
|
7
|
+
data.tar.gz: 5d68d6084d2a0257147346cc68837ed64955691141dcef7568fa7de3f5fffcd9b7573201ab9b4e26bbd0c6fcb7aee6cc4abadaf766c9344da5383e42dcbf2223
|
data/Gemfile.lock
CHANGED
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
|
5
|
+
if (ARGV & %w(--version -v help --help encode decode encode_id decode_id json_feed_updated json_feed_unregistered json_feed_by_blog)).empty?
|
6
6
|
Commonmeta::CLI.start(ARGV.dup.unshift("convert"))
|
7
7
|
else
|
8
8
|
Commonmeta::CLI.start
|
data/lib/commonmeta/cli.rb
CHANGED
@@ -80,12 +80,24 @@ module Commonmeta
|
|
80
80
|
puts decode_container_id(id)
|
81
81
|
end
|
82
82
|
|
83
|
-
desc "", "
|
83
|
+
desc "", "json_feed_unregistered"
|
84
84
|
|
85
85
|
def json_feed_unregistered
|
86
86
|
puts get_json_feed_unregistered
|
87
87
|
end
|
88
88
|
|
89
|
+
desc "", "json_feed_updated"
|
90
|
+
|
91
|
+
def json_feed_updated
|
92
|
+
puts get_json_feed_updated
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "", "json_feed_by_blog"
|
96
|
+
|
97
|
+
def json_feed_by_blog(id)
|
98
|
+
puts get_json_feed_by_blog(id)
|
99
|
+
end
|
100
|
+
|
89
101
|
default_task :convert
|
90
102
|
end
|
91
103
|
end
|
@@ -96,18 +96,29 @@ module Commonmeta
|
|
96
96
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
97
97
|
|
98
98
|
posts = JSON.parse(response.body.to_s)
|
99
|
-
posts.map { |post| post["uuid"] }.
|
99
|
+
posts.map { |post| post["uuid"] }.join('\n')
|
100
100
|
end
|
101
101
|
|
102
102
|
def get_json_feed_updated
|
103
103
|
# get JSON Feed items updated since last check
|
104
104
|
|
105
|
-
url =
|
105
|
+
url = json_feed_updated_url
|
106
106
|
response = HTTP.get(url)
|
107
107
|
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
108
108
|
|
109
109
|
posts = JSON.parse(response.body.to_s)
|
110
|
-
posts.map { |post| post["uuid"] }.
|
110
|
+
posts.map { |post| post["uuid"] }.join('\n')
|
111
|
+
end
|
112
|
+
|
113
|
+
def get_json_feed_by_blog(blog_id)
|
114
|
+
# get all JSON Feed items from a particular blog
|
115
|
+
|
116
|
+
url = json_feed_by_blog_url(blog_id)
|
117
|
+
response = HTTP.get(url)
|
118
|
+
return { "string" => nil, "state" => "not_found" } unless response.status.success?
|
119
|
+
|
120
|
+
blog = JSON.parse(response.body.to_s)
|
121
|
+
blog["items"].map { |item| item["uuid"] }.join('\n')
|
111
122
|
end
|
112
123
|
end
|
113
124
|
end
|
data/lib/commonmeta/utils.rb
CHANGED
@@ -1401,8 +1401,16 @@ module Commonmeta
|
|
1401
1401
|
Base32::URL.decode(id)
|
1402
1402
|
end
|
1403
1403
|
|
1404
|
+
def json_feed_updated_url
|
1405
|
+
"https://rogue-scholar.org/api/posts/updated"
|
1406
|
+
end
|
1407
|
+
|
1404
1408
|
def json_feed_unregistered_url
|
1405
1409
|
"https://rogue-scholar.org/api/posts/unregistered"
|
1406
1410
|
end
|
1411
|
+
|
1412
|
+
def json_feed_by_blog_url(blog_id)
|
1413
|
+
"https://rogue-scholar.org/api/blogs/#{blog_id}"
|
1414
|
+
end
|
1407
1415
|
end
|
1408
1416
|
end
|
data/lib/commonmeta/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -341,9 +341,10 @@ describe Commonmeta::CLI do
|
|
341
341
|
end
|
342
342
|
end
|
343
343
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
344
|
+
describe "json_feed", vcr: true do
|
345
|
+
it "json_feed_by_blog" do
|
346
|
+
input = "tyfqw20"
|
347
|
+
expect { subject.json_feed_by_blog input }.to output(/3e1278f6-e7c0-43e1-bb54-6829e1344c0d/).to_stdout
|
348
|
+
end
|
349
|
+
end
|
349
350
|
end
|