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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fb0000a0778a5f22bfa139290c2d117c514548da3a3399d8c9dbd8f5255ad7d
4
- data.tar.gz: 6571f7f69a6898a28a509603c262d2de56cfd4513aa3484e2eedf63037341c2e
3
+ metadata.gz: 0c7ac4f2270bdd15aecdf4990d564864e4d0e432f14c7b8a8ac8dfc947c7e416
4
+ data.tar.gz: a1933aa0d63f225b74ab4b2a5445fdf43c5d4c5cfa9c6fad607a6793627e8a7f
5
5
  SHA512:
6
- metadata.gz: e63100f48bcd4cf82d86e6538c6f0d54d7bfd5e6ba622374cdd4baaa7a62c7e90b9d7c1f9477d6689b3433bb1bbb11babd92d23953cf0b5ed9eb4489b4518e1c
7
- data.tar.gz: fd724c156cf3c0d6d19fee2bc9a5aee426ce2634b4af2c224cbbc6dd22896e313a4ba18e2c908a17db5d83b3ccb093b9a3940ddce971744fe3a9df8135a20142
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
- [![Build Status](https://travis-ci.com/ninoseki/zoomeye-rb.svg?branch=master)](https://travis-ci.com/ninoseki/zoomeye-rb)
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 usernamem & password via ENV["ZOOMEYE_USERNAME"] and ENV["ZOOMEYE_PASSWORD"]
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(username: "USERNAME", password: "PASSWORD")
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
@@ -6,7 +6,6 @@ require "zoomeye/clients/base"
6
6
 
7
7
  require "zoomeye/clients/host"
8
8
  require "zoomeye/clients/resource_info"
9
- require "zoomeye/clients/user"
10
9
  require "zoomeye/clients/web"
11
10
 
12
11
  require "zoomeye/api"
data/lib/zoomeye/api.rb CHANGED
@@ -2,34 +2,21 @@
2
2
 
3
3
  module ZoomEye
4
4
  class API
5
- def initialize(username: ENV["ZOOMEYE_USERNAME"], password: ENV["ZOOMEYE_PASSWORD"])
6
- @username = username
7
- raise ArgumentError, "No usernamme has been found or provided!" unless @username
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(access_token: access_token)
11
+ @web ||= Clients::Web.new(@api_key)
19
12
  end
20
13
 
21
14
  def host
22
- @host ||= Clients::Host.new(access_token: access_token)
15
+ @host ||= Clients::Host.new(@api_key)
23
16
  end
24
17
 
25
18
  def resource_info
26
- @resource_info ||= Clients::ResourceInfo.new(access_token: access_token)
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
@@ -10,10 +10,8 @@ module ZoomEye
10
10
  HOST = "api.zoomeye.org"
11
11
  BASE_URL = "https://#{HOST}"
12
12
 
13
- def initialize(username: nil, password: nil, access_token: nil)
14
- @username = username
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.dig("message") || body
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 token_headers
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 = path == "/user/login" ? {} : token_headers
59
+ headers = { "API-KEY": @api_key }
68
60
 
69
61
  request = case type
70
62
  when "GET"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZoomEye
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/renovate.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
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.0"
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.9"
31
- spec.add_development_dependency "vcr", "~> 5.0"
32
- spec.add_development_dependency "webmock", "~> 3.7"
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.1.1
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: 2019-10-17 00:00:00.000000000 Z
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.0'
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.0'
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.9'
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.9'
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: '5.0'
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: '5.0'
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.7'
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.7'
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.0.6
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
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.4
7
- before_install: gem install bundler -v 2.0.2
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ZoomEye
4
- module Clients
5
- class User < Base
6
- def access_token
7
- _post("/user/login", username: @username, password: @password) { |json| json.dig("access_token") }
8
- end
9
- end
10
- end
11
- end