zoomeye-rb 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +25 -0
- data/README.md +3 -3
- data/lib/zoomeye.rb +0 -1
- data/lib/zoomeye/api.rb +6 -19
- data/lib/zoomeye/clients/base.rb +5 -13
- data/lib/zoomeye/version.rb +1 -1
- data/renovate.json +5 -0
- data/zoomeye.gemspec +5 -4
- metadata +30 -16
- data/.travis.yml +0 -7
- data/lib/zoomeye/clients/user.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7ac4f2270bdd15aecdf4990d564864e4d0e432f14c7b8a8ac8dfc947c7e416
|
4
|
+
data.tar.gz: a1933aa0d63f225b74ab4b2a5445fdf43c5d4c5cfa9c6fad607a6793627e8a7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7b6e4ba66407cdc41e28535d924c7d8a5f2bf899827653d9ef005e247f28594ff81a9a665c3631e8cbf51b1e58e69f4f3192169e7f5778e98678d0f6c761a84
|
7
|
+
data.tar.gz: f0930c95f9391e32ada4e327261520054a18ed85e931554e50bdf830bb532c6abd5931286656c4550bea2a2a505514d9b8dce5d1d66fa1b1a0f4a941928103fb
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on: [pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby: [2.7, "3.0"]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
bundler-cache: true
|
21
|
+
- name: Build and test with Rake
|
22
|
+
run: |
|
23
|
+
gem install bundler
|
24
|
+
bundle install
|
25
|
+
bundle exec rake
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# zoomeye-rb
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Ruby CI](https://github.com/ninoseki/zoomeye-rb/actions/workflows/test.yml/badge.svg)](https://github.com/ninoseki/zoomeye-rb/actions/workflows/test.yml)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/zoomeye-rb/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/zoomeye-rb?branch=master)
|
5
5
|
[![CodeFactor](https://www.codefactor.io/repository/github/ninoseki/zoomeye-rb/badge)](https://www.codefactor.io/repository/github/ninoseki/zoomeye-rb)
|
6
6
|
|
@@ -17,11 +17,11 @@ gem install zoomeye
|
|
17
17
|
```ruby
|
18
18
|
require "zoomeye"
|
19
19
|
|
20
|
-
# when given nothing, it tries to load your
|
20
|
+
# when given nothing, it tries to load your API key via ENV["ZOOMEYE_API_KEY"]
|
21
21
|
api = ZoomEye::API.new
|
22
22
|
|
23
23
|
# or you can set them manually
|
24
|
-
api = ZoomEye::API.new(
|
24
|
+
api = ZoomEye::API.new(api_key: "YOUR_API_KEY")
|
25
25
|
|
26
26
|
# Host search
|
27
27
|
api.host.search("port:80 nginx")
|
data/lib/zoomeye.rb
CHANGED
data/lib/zoomeye/api.rb
CHANGED
@@ -2,34 +2,21 @@
|
|
2
2
|
|
3
3
|
module ZoomEye
|
4
4
|
class API
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
raise ArgumentError, "No
|
8
|
-
|
9
|
-
@password = password
|
10
|
-
raise ArgumentError, "No password has been found or provided!" unless @password
|
11
|
-
end
|
12
|
-
|
13
|
-
def user
|
14
|
-
@user ||= Clients::User.new(username: @username, password: @password)
|
5
|
+
def initialize(api_key: ENV["ZOOMEYE_API_KEY"])
|
6
|
+
@api_key = api_key
|
7
|
+
raise ArgumentError, "No API key has been found or provided!" unless @api_key
|
15
8
|
end
|
16
9
|
|
17
10
|
def web
|
18
|
-
@web ||= Clients::Web.new(
|
11
|
+
@web ||= Clients::Web.new(@api_key)
|
19
12
|
end
|
20
13
|
|
21
14
|
def host
|
22
|
-
@host ||= Clients::Host.new(
|
15
|
+
@host ||= Clients::Host.new(@api_key)
|
23
16
|
end
|
24
17
|
|
25
18
|
def resource_info
|
26
|
-
@resource_info ||= Clients::ResourceInfo.new(
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def access_token
|
32
|
-
@access_token ||= user.access_token
|
19
|
+
@resource_info ||= Clients::ResourceInfo.new(@api_key)
|
33
20
|
end
|
34
21
|
end
|
35
22
|
end
|
data/lib/zoomeye/clients/base.rb
CHANGED
@@ -10,10 +10,8 @@ module ZoomEye
|
|
10
10
|
HOST = "api.zoomeye.org"
|
11
11
|
BASE_URL = "https://#{HOST}"
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
@
|
15
|
-
@password = password
|
16
|
-
@access_token = access_token
|
13
|
+
def initialize(api_key)
|
14
|
+
@api_key = api_key
|
17
15
|
end
|
18
16
|
|
19
17
|
private
|
@@ -48,23 +46,17 @@ module ZoomEye
|
|
48
46
|
when 200
|
49
47
|
yield json
|
50
48
|
else
|
51
|
-
error = json
|
49
|
+
error = json["message"] || body
|
52
50
|
raise Error, "Unsupported response code returned: #{code} - #{error}"
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
|
-
def
|
58
|
-
{
|
59
|
-
Authorization: "JWT #{@access_token}"
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def build_request(type: "GET", path:, params: {})
|
55
|
+
def build_request(path:, type: "GET", params: {})
|
64
56
|
uri = url_for(path)
|
65
57
|
uri.query = URI.encode_www_form(params) if type == "GET"
|
66
58
|
|
67
|
-
headers =
|
59
|
+
headers = { "API-KEY": @api_key }
|
68
60
|
|
69
61
|
request = case type
|
70
62
|
when "GET"
|
data/lib/zoomeye/version.rb
CHANGED
data/zoomeye.gemspec
CHANGED
@@ -24,10 +24,11 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler", "~> 2.
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
28
28
|
spec.add_development_dependency "coveralls", "~> 0.8"
|
29
|
+
spec.add_development_dependency "httplog", "~> 1.4"
|
29
30
|
spec.add_development_dependency "rake", "~> 13.0"
|
30
|
-
spec.add_development_dependency "rspec", "~> 3.
|
31
|
-
spec.add_development_dependency "vcr", "~>
|
32
|
-
spec.add_development_dependency "webmock", "~> 3.
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.10"
|
32
|
+
spec.add_development_dependency "vcr", "~> 6.0"
|
33
|
+
spec.add_development_dependency "webmock", "~> 3.12"
|
33
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoomeye-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: coveralls
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httplog
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,42 +72,42 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
75
|
+
version: '3.10'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
82
|
+
version: '3.10'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: vcr
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
89
|
+
version: '6.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
96
|
+
version: '6.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: webmock
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '3.
|
103
|
+
version: '3.12'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '3.
|
110
|
+
version: '3.12'
|
97
111
|
description: ZoomEye API wrapper for Ruby
|
98
112
|
email:
|
99
113
|
- manabu.niseki@gmail.com
|
@@ -101,9 +115,9 @@ executables: []
|
|
101
115
|
extensions: []
|
102
116
|
extra_rdoc_files: []
|
103
117
|
files:
|
118
|
+
- ".github/workflows/test.yml"
|
104
119
|
- ".gitignore"
|
105
120
|
- ".rspec"
|
106
|
-
- ".travis.yml"
|
107
121
|
- Gemfile
|
108
122
|
- LICENSE
|
109
123
|
- README.md
|
@@ -115,15 +129,15 @@ files:
|
|
115
129
|
- lib/zoomeye/clients/base.rb
|
116
130
|
- lib/zoomeye/clients/host.rb
|
117
131
|
- lib/zoomeye/clients/resource_info.rb
|
118
|
-
- lib/zoomeye/clients/user.rb
|
119
132
|
- lib/zoomeye/clients/web.rb
|
120
133
|
- lib/zoomeye/version.rb
|
134
|
+
- renovate.json
|
121
135
|
- zoomeye.gemspec
|
122
136
|
homepage: https://github.com/ninoseki/zoomeye-rb
|
123
137
|
licenses:
|
124
138
|
- MIT
|
125
139
|
metadata: {}
|
126
|
-
post_install_message:
|
140
|
+
post_install_message:
|
127
141
|
rdoc_options: []
|
128
142
|
require_paths:
|
129
143
|
- lib
|
@@ -138,8 +152,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
152
|
- !ruby/object:Gem::Version
|
139
153
|
version: '0'
|
140
154
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
142
|
-
signing_key:
|
155
|
+
rubygems_version: 3.2.15
|
156
|
+
signing_key:
|
143
157
|
specification_version: 4
|
144
158
|
summary: ZoomEye API wrapper for Ruby
|
145
159
|
test_files: []
|
data/.travis.yml
DELETED
data/lib/zoomeye/clients/user.rb
DELETED