foobara-ruby-gems-api 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/lib/foobara/ruby_gems_api.rb +1 -0
- data/src/foobara/ruby_gems_api/get_owners.rb +2 -52
- data/src/foobara/ruby_gems_api/get_versions.rb +2 -52
- data/src/foobara/ruby_gems_api/search.rb +2 -41
- metadata +18 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eb4a32c2a31c3001bef72e988723a1b5c4a02eb2ff389f12ff4123fbeb0c3c9
|
4
|
+
data.tar.gz: 72314d43a32877402bbecbed0a2a3eae112e08b29d96e7841452e4aa06b5db9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d57c245f1a4afff071368fce58901b92489762fb2859c7e35d18042b04f9167393f76582ec6000e7720deb258c9a74fb1a8075417ea4171f69f85d0bb3d6ee9d
|
7
|
+
data.tar.gz: a2d9ef0a79ae39035f1273a83c29be0c3f477d6f86b374b0b41ef64a5d3f97d82075d5c0b5aa68341b45f26c3f7756b92d31df84b9da0aa8a9f4bc19e959f8d5
|
data/CHANGELOG.md
CHANGED
@@ -1,65 +1,15 @@
|
|
1
|
-
require "uri"
|
2
|
-
require "net/http"
|
3
|
-
|
4
1
|
module Foobara
|
5
2
|
module RubyGemsApi
|
6
3
|
class GetOwners < Foobara::Command
|
7
|
-
API_URL = ->(gem_name) { "https://rubygems.org/api/v1/gems/#{gem_name}/owners.json" }
|
8
|
-
|
9
4
|
inputs do
|
10
5
|
gem_name :string, :required
|
11
6
|
end
|
12
7
|
|
13
8
|
result [User]
|
14
9
|
|
15
|
-
|
16
|
-
build_request_body
|
17
|
-
build_request_headers
|
18
|
-
issue_http_request
|
19
|
-
parse_response
|
20
|
-
build_gems
|
21
|
-
|
22
|
-
gems
|
23
|
-
end
|
24
|
-
|
25
|
-
attr_accessor :request_body, :request_headers, :response, :response_body, :gems
|
26
|
-
|
27
|
-
def build_request_body
|
28
|
-
self.request_body = {}
|
29
|
-
end
|
30
|
-
|
31
|
-
def build_request_headers
|
32
|
-
self.request_headers = {
|
33
|
-
"Content-Type" => "application/json"
|
34
|
-
}
|
35
|
-
end
|
10
|
+
include HttpApiGetCommand
|
36
11
|
|
37
|
-
|
38
|
-
API_URL.call(gem_name)
|
39
|
-
end
|
40
|
-
|
41
|
-
def issue_http_request
|
42
|
-
uri = URI(url)
|
43
|
-
uri.query = URI.encode_www_form(request_body)
|
44
|
-
self.response = Net::HTTP.get_response(uri, request_headers)
|
45
|
-
end
|
46
|
-
|
47
|
-
def parse_response
|
48
|
-
json = if response.is_a?(Net::HTTPSuccess)
|
49
|
-
response.body
|
50
|
-
else
|
51
|
-
# :nocov:
|
52
|
-
raise "Could not successfully hit #{url}: " \
|
53
|
-
"#{response.code} #{response.message}"
|
54
|
-
# :nocov:
|
55
|
-
end
|
56
|
-
|
57
|
-
self.response_body = JSON.parse(json)
|
58
|
-
end
|
59
|
-
|
60
|
-
def build_gems
|
61
|
-
self.gems = response_body
|
62
|
-
end
|
12
|
+
url { "https://rubygems.org/api/v1/gems/#{gem_name}/owners.json" }
|
63
13
|
end
|
64
14
|
end
|
65
15
|
end
|
@@ -1,65 +1,15 @@
|
|
1
|
-
require "uri"
|
2
|
-
require "net/http"
|
3
|
-
|
4
1
|
module Foobara
|
5
2
|
module RubyGemsApi
|
6
3
|
class GetVersions < Foobara::Command
|
7
|
-
API_URL = ->(gem_name) { "https://rubygems.org/api/v1/versions/#{gem_name}.json" }
|
8
|
-
|
9
4
|
inputs do
|
10
5
|
gem_name :string, :required
|
11
6
|
end
|
12
7
|
|
13
8
|
result [Version]
|
14
9
|
|
15
|
-
|
16
|
-
build_request_body
|
17
|
-
build_request_headers
|
18
|
-
issue_http_request
|
19
|
-
parse_response
|
20
|
-
build_versions
|
21
|
-
|
22
|
-
versions
|
23
|
-
end
|
24
|
-
|
25
|
-
attr_accessor :request_body, :request_headers, :response, :response_body, :versions
|
26
|
-
|
27
|
-
def build_request_body
|
28
|
-
self.request_body = {}
|
29
|
-
end
|
30
|
-
|
31
|
-
def build_request_headers
|
32
|
-
self.request_headers = {
|
33
|
-
"Content-Type" => "application/json"
|
34
|
-
}
|
35
|
-
end
|
10
|
+
include HttpApiGetCommand
|
36
11
|
|
37
|
-
|
38
|
-
API_URL.call(gem_name)
|
39
|
-
end
|
40
|
-
|
41
|
-
def issue_http_request
|
42
|
-
uri = URI(url)
|
43
|
-
uri.query = URI.encode_www_form(request_body)
|
44
|
-
self.response = Net::HTTP.get_response(uri, request_headers)
|
45
|
-
end
|
46
|
-
|
47
|
-
def parse_response
|
48
|
-
json = if response.is_a?(Net::HTTPSuccess)
|
49
|
-
response.body
|
50
|
-
else
|
51
|
-
# :nocov:
|
52
|
-
raise "Could not successfully hit #{url}: " \
|
53
|
-
"#{response.code} #{response.message}"
|
54
|
-
# :nocov:
|
55
|
-
end
|
56
|
-
|
57
|
-
self.response_body = JSON.parse(json)
|
58
|
-
end
|
59
|
-
|
60
|
-
def build_versions
|
61
|
-
self.versions = response_body
|
62
|
-
end
|
12
|
+
url { "https://rubygems.org/api/v1/versions/#{gem_name}.json" }
|
63
13
|
end
|
64
14
|
end
|
65
15
|
end
|
@@ -4,58 +4,19 @@ require "net/http"
|
|
4
4
|
module Foobara
|
5
5
|
module RubyGemsApi
|
6
6
|
class Search < Foobara::Command
|
7
|
-
API_URL = "https://rubygems.org/api/v1/search.json".freeze
|
8
|
-
|
9
7
|
inputs do
|
10
8
|
query :string, :required
|
11
9
|
end
|
12
10
|
|
13
11
|
result [Gem]
|
14
12
|
|
15
|
-
|
16
|
-
build_request_body
|
17
|
-
build_request_headers
|
18
|
-
issue_http_request
|
19
|
-
parse_response
|
20
|
-
build_gems
|
21
|
-
|
22
|
-
gems
|
23
|
-
end
|
13
|
+
include HttpApiGetCommand
|
24
14
|
|
25
|
-
|
15
|
+
url "https://rubygems.org/api/v1/search.json"
|
26
16
|
|
27
17
|
def build_request_body
|
28
18
|
self.request_body = { query: }
|
29
19
|
end
|
30
|
-
|
31
|
-
def build_request_headers
|
32
|
-
self.request_headers = {
|
33
|
-
"Content-Type" => "application/json"
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def issue_http_request
|
38
|
-
uri = URI(API_URL)
|
39
|
-
uri.query = URI.encode_www_form(request_body)
|
40
|
-
self.response = Net::HTTP.get_response(uri, request_headers)
|
41
|
-
end
|
42
|
-
|
43
|
-
def parse_response
|
44
|
-
json = if response.is_a?(Net::HTTPSuccess)
|
45
|
-
response.body
|
46
|
-
else
|
47
|
-
# :nocov:
|
48
|
-
raise "Could not successfully hit #{API_URL}: " \
|
49
|
-
"#{response.code} #{response.message}"
|
50
|
-
# :nocov:
|
51
|
-
end
|
52
|
-
|
53
|
-
self.response_body = JSON.parse(json)
|
54
|
-
end
|
55
|
-
|
56
|
-
def build_gems
|
57
|
-
self.gems = response_body
|
58
|
-
end
|
59
20
|
end
|
60
21
|
end
|
61
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-ruby-gems-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: foobara
|
@@ -24,7 +23,20 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '0'
|
27
|
-
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: foobara-http-api-command
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
28
40
|
email:
|
29
41
|
- azimux@gmail.com
|
30
42
|
executables: []
|
@@ -50,7 +62,6 @@ metadata:
|
|
50
62
|
source_code_uri: https://github.com/foobara/ruby-gems-api
|
51
63
|
changelog_uri: https://github.com/foobara/ruby-gems-api/blob/main/CHANGELOG.md
|
52
64
|
rubygems_mfa_required: 'true'
|
53
|
-
post_install_message:
|
54
65
|
rdoc_options: []
|
55
66
|
require_paths:
|
56
67
|
- lib
|
@@ -58,15 +69,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
69
|
requirements:
|
59
70
|
- - ">="
|
60
71
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
72
|
+
version: 3.4.0
|
62
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
74
|
requirements:
|
64
75
|
- - ">="
|
65
76
|
- !ruby/object:Gem::Version
|
66
77
|
version: '0'
|
67
78
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
69
|
-
signing_key:
|
79
|
+
rubygems_version: 3.6.2
|
70
80
|
specification_version: 4
|
71
81
|
summary: No description. Add one.
|
72
82
|
test_files: []
|