spyonweb 0.0.1 → 0.0.2
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/README.md +8 -4
- data/lib/spyonweb/response.rb +4 -3
- data/lib/spyonweb/version.rb +1 -1
- data/spec/lib/api_spec.rb +69 -0
- data/spec/lib/response_spec.rb +28 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/spyonweb_spec.rb +16 -0
- data/spyonweb.gemspec +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c8bb1167410964c9f419ce57e6981a67b3f3235
|
4
|
+
data.tar.gz: 5f28bd828ffa840c1d5fb27c3890c4467eedfebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fae0c9af3d08b386ee2f4faea95bdcd124c3a1abf5f33f409d89c7c695b308bd8f3520d7ecfa397e53fc8b330c62f5c5800eb7dc57d27822698e0e6844593d85
|
7
|
+
data.tar.gz: ce31dcb21f056f52d84638b29d96f5c72a3eeff8924ed9efe52545fae2b17cf00ea4615102701ff0b2683812b2bb5561f216a675296506af94b311ce00c313bd
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
## Spyonweb.com ruby bindings
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/spyonweb) [](https://codeclimate.com/github/bogdanovich/spyonweb-ruby)
|
2
4
|
|
3
5
|
## Installation
|
4
6
|
|
@@ -19,10 +21,12 @@ Or install it yourself as:
|
|
19
21
|
## Usage
|
20
22
|
|
21
23
|
```ruby
|
22
|
-
|
24
|
+
require 'spyonweb'
|
25
|
+
|
23
26
|
Spyonweb.api_token = 'MY_TOKEN'
|
24
27
|
|
25
|
-
#
|
28
|
+
# Available methods
|
29
|
+
|
26
30
|
Spyonweb.summary('fullmooncalendar.net')
|
27
31
|
|
28
32
|
Spyonweb.domain('fullmooncalendar.net')
|
@@ -40,7 +44,7 @@ Spyonweb.ip_dns('8.8.8.8')
|
|
40
44
|
|
41
45
|
## Contributing
|
42
46
|
|
43
|
-
1. Fork it ( https://github.com/
|
47
|
+
1. Fork it ( https://github.com/bogdanovich/spyonweb-ruby/fork )
|
44
48
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
49
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
50
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/spyonweb/response.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
module Spyonweb
|
2
2
|
|
3
|
-
class Response < Struct.new(:status, :result, :response)
|
3
|
+
class Response < Struct.new(:status, :result, :message, :response)
|
4
4
|
def self.parse(response)
|
5
5
|
begin
|
6
6
|
hash = JSON.parse(response.body)
|
7
7
|
status = hash['status']
|
8
8
|
result = hash['result']
|
9
|
+
message = hash['message']
|
9
10
|
rescue JSON::ParserError => e
|
10
11
|
status = "error"
|
11
|
-
|
12
|
+
message = e.inspect
|
12
13
|
end
|
13
|
-
Response.new(status, result, response)
|
14
|
+
Response.new(status, result, message, response)
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
data/lib/spyonweb/version.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spyonweb::API do
|
4
|
+
|
5
|
+
describe '.get' do
|
6
|
+
it "performs get request" do
|
7
|
+
Spyonweb.api_token = 'TOKEN'
|
8
|
+
response = OpenStruct.new(body: {status: 'error', message: 'unauthorized'}.to_json)
|
9
|
+
|
10
|
+
allow_any_instance_of(RestClient::Resource).to receive(:get) { |arg|
|
11
|
+
expect(arg.url).to eq Spyonweb.api_base + "/domain/spyonweb.com"
|
12
|
+
}.and_return(response)
|
13
|
+
|
14
|
+
expect(Spyonweb::Response).to receive(:parse).with(response)
|
15
|
+
|
16
|
+
Spyonweb.send(:get, 'domain', 'spyonweb.com')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.summary' do
|
21
|
+
it "calls get summary" do
|
22
|
+
expect(Spyonweb).to receive(:get).with('summary', 'spyonweb.com') {}
|
23
|
+
Spyonweb.summary('spyonweb.com')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.domain' do
|
28
|
+
it "calls get domain" do
|
29
|
+
expect(Spyonweb).to receive(:get).with('domain', 'spyonweb.com') {}
|
30
|
+
Spyonweb.domain('spyonweb.com')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.ip' do
|
35
|
+
it "calls get ip" do
|
36
|
+
expect(Spyonweb).to receive(:get).with('ip', 'spyonweb.com', {}) {}
|
37
|
+
Spyonweb.ip('spyonweb.com')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '.adsense' do
|
42
|
+
it "calls get adsense" do
|
43
|
+
expect(Spyonweb).to receive(:get).with('adsense', 'spyonweb.com', { start: 'test.com', limit: 10}) {}
|
44
|
+
Spyonweb.adsense('spyonweb.com', start: 'test.com', limit: 10)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '.analytics' do
|
49
|
+
it "calls get analytics" do
|
50
|
+
expect(Spyonweb).to receive(:get).with('analytics', 'spyonweb.com', { start: 'test.com', limit: 10}) {}
|
51
|
+
Spyonweb.analytics('spyonweb.com', start: 'test.com', limit: 10)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '.dns_domain' do
|
56
|
+
it "calls get dns_domain" do
|
57
|
+
expect(Spyonweb).to receive(:get).with('dns_domain', 'spyonweb.com', { start: 'test.com', limit: 10}) {}
|
58
|
+
Spyonweb.dns_domain('spyonweb.com', start: 'test.com', limit: 10)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.ip_dns' do
|
63
|
+
it "calls get ip_dns" do
|
64
|
+
expect(Spyonweb).to receive(:get).with('ip_dns', 'spyonweb.com', { start: 'test.com', limit: 10}) {}
|
65
|
+
Spyonweb.ip_dns('spyonweb.com', start: 'test.com', limit: 10)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spyonweb::Response do
|
4
|
+
|
5
|
+
let(:successful_response) { OpenStruct.new(body: { status: "found", result: "something" }.to_json) }
|
6
|
+
let(:unauthorized_response) { OpenStruct.new(body: { status: "error", message: "unauthorized" }.to_json) }
|
7
|
+
let(:broken_json) { Struct.new(:body).new("not a json") }
|
8
|
+
|
9
|
+
describe ".parse" do
|
10
|
+
it "returns successful response object" do
|
11
|
+
response = Spyonweb::Response.parse(successful_response)
|
12
|
+
expect(response.status).to eq 'found'
|
13
|
+
expect(response.result).to eq 'something'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns unauthorized response object" do
|
17
|
+
response = Spyonweb::Response.parse(unauthorized_response)
|
18
|
+
expect(response.status).to eq 'error'
|
19
|
+
expect(response.message).to eq 'unauthorized'
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns unauthorized response object" do
|
23
|
+
response = Spyonweb::Response.parse(broken_json)
|
24
|
+
expect(response.status).to eq 'error'
|
25
|
+
expect(response.message).to match 'JSON::ParserError'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/spyonweb_spec.rb
CHANGED
@@ -10,4 +10,20 @@ describe '#api_token' do
|
|
10
10
|
Spyonweb.api_token = 'LkvWvMuzlJYG'
|
11
11
|
expect(Spyonweb.api_token).to eq 'LkvWvMuzlJYG'
|
12
12
|
end
|
13
|
+
|
14
|
+
it "has default api_base url" do
|
15
|
+
expect(Spyonweb.api_base).to eq 'https://api.spyonweb.com/v1'
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.resource' do
|
19
|
+
it 'responds_to resource' do
|
20
|
+
expect(Spyonweb).to respond_to(:resource)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns RestClient::Resource' do
|
24
|
+
resource = Spyonweb.resource
|
25
|
+
expect(resource.class.name).to eq "RestClient::Resource"
|
26
|
+
expect(resource.url).to eq Spyonweb.api_base
|
27
|
+
end
|
28
|
+
end
|
13
29
|
end
|
data/spyonweb.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Anton Bogdanovich"]
|
10
10
|
spec.email = ["27bogdanovich@gmail.com"]
|
11
11
|
spec.summary = %q{Spyonweb.com Ruby bindings}
|
12
|
-
spec.description = %q{Spyonweb.com
|
12
|
+
spec.description = %q{Spyonweb.com Ruby bindings}
|
13
13
|
spec.homepage = "https://github.com/bogdanovich/spyonweb-ruby"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spyonweb
|
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
|
- Anton Bogdanovich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description: Spyonweb.com
|
111
|
+
description: Spyonweb.com Ruby bindings
|
112
112
|
email:
|
113
113
|
- 27bogdanovich@gmail.com
|
114
114
|
executables: []
|
@@ -125,6 +125,8 @@ files:
|
|
125
125
|
- lib/spyonweb/api.rb
|
126
126
|
- lib/spyonweb/response.rb
|
127
127
|
- lib/spyonweb/version.rb
|
128
|
+
- spec/lib/api_spec.rb
|
129
|
+
- spec/lib/response_spec.rb
|
128
130
|
- spec/spec_helper.rb
|
129
131
|
- spec/spyonweb_spec.rb
|
130
132
|
- spyonweb.gemspec
|
@@ -153,6 +155,8 @@ signing_key:
|
|
153
155
|
specification_version: 4
|
154
156
|
summary: Spyonweb.com Ruby bindings
|
155
157
|
test_files:
|
158
|
+
- spec/lib/api_spec.rb
|
159
|
+
- spec/lib/response_spec.rb
|
156
160
|
- spec/spec_helper.rb
|
157
161
|
- spec/spyonweb_spec.rb
|
158
162
|
has_rdoc:
|