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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d39024b030308bfeb8bddbc31a34396f630967c375c5ee15e38ce76fefd97e5b
4
- data.tar.gz: 93e0dcceac66451bbcd81745ef829f2d489a83bad5bd9abd32f74c77efbcb200
3
+ metadata.gz: 575100d8bef2d51a19423453d3a5c3d7129903d5d7d23da7e7ac3c6c24ceb52b
4
+ data.tar.gz: 9146bae365bf7f79c1f3ce05e781942749b29257433ed1d37196b3d0d1d2bf21
5
5
  SHA512:
6
- metadata.gz: d5fc95306870e50f0db71d994fa41b2d776523535ec2e81f0d5ecac721cff5c0a0b4ead67a0910e7633e9bab66fc65cabc7362a411469c9d31a4fd1cb25d1af8
7
- data.tar.gz: 233a74b81551bd4951a3852b400c0fb07baf9bd0c8d557348a1f6c1d17483bc56c158f95a68063490929ff8e9078f67fe9f1094b8ce1b32ddccea6ed2406c1a4
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)
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.1)
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.1)
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.6.2)
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.10)
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.1.0)
222
+ tilt (2.2.0)
222
223
  tzinfo (2.0.6)
223
224
  concurrent-ruby (~> 1.0)
224
225
  unf (0.1.4)
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
3
+ require "thor"
4
4
 
5
- require_relative 'doi_utils'
6
- require_relative 'utils'
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 '--version, -v', 'print the version'
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 '', 'convert metadata'
28
- method_option :from, aliases: '-f'
29
- method_option :to, aliases: '-t', default: 'schema_org'
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: '-s', default: 'apa'
32
- method_option :locale, aliases: '-l', default: 'en-US'
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] || 'schema_org'
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 '', 'encode'
59
+ desc "", "encode"
60
60
 
61
61
  def encode(prefix)
62
62
  puts encode_doi(prefix)
63
63
  end
64
64
 
65
- desc '', 'encode_id'
65
+ desc "", "encode_id"
66
66
 
67
67
  def encode_id
68
68
  puts encode_container_id
69
69
  end
70
70
 
71
- desc '', 'decode'
71
+ desc "", "decode"
72
72
 
73
73
  def decode(doi)
74
74
  puts decode_doi(doi)
75
75
  end
76
76
 
77
- desc '', 'decode_id'
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 '', 'feed'
83
+ desc "", "json_feed"
84
84
 
85
- def json_feed(id)
86
- if id.present?
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(id = nil)
77
+ def get_json_feed
78
78
  # get JSON Feed items not registered as DOIs
79
-
80
- url = json_feed_url(id)
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
- if id.present?
85
- blog = JSON.parse(response.body.to_s)
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
@@ -1381,10 +1381,8 @@ module Commonmeta
1381
1381
  Base32::URL.decode(id)
1382
1382
  end
1383
1383
 
1384
- def json_feed_url(id = nil)
1385
- return "https://rogue-scholar.org/api/blogs/#{id}" if id.present?
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Commonmeta
4
- VERSION = '3.2.4'
4
+ VERSION = '3.2.6'
5
5
  end
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
- let(:input) { "prmb582" }
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