spyonweb 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 267187c6a12dbe928091e0f27764e094b20ffa3d
4
- data.tar.gz: da141339fdfd0707c9019c87fff7430994947ebb
3
+ metadata.gz: 2c8bb1167410964c9f419ce57e6981a67b3f3235
4
+ data.tar.gz: 5f28bd828ffa840c1d5fb27c3890c4467eedfebb
5
5
  SHA512:
6
- metadata.gz: 38c36b368115c1637377486769eeebc4c8c09741c616486f741d1664c94594d6a4cecd4e4c7a1b7a035580c5402db9d18acba3a9672def404539ee5eee1c176c
7
- data.tar.gz: b8a07399d60f93f9b0a9fdf0fa87b4efcb382dfba8da8706d38340eb99970ba60d72411bed2d224d4dc36936e67fb5ac68573d9562fa069826c4a84c31cc2824
6
+ metadata.gz: fae0c9af3d08b386ee2f4faea95bdcd124c3a1abf5f33f409d89c7c695b308bd8f3520d7ecfa397e53fc8b330c62f5c5800eb7dc57d27822698e0e6844593d85
7
+ data.tar.gz: ce31dcb21f056f52d84638b29d96f5c72a3eeff8924ed9efe52545fae2b17cf00ea4615102701ff0b2683812b2bb5561f216a675296506af94b311ce00c313bd
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # Spyonweb.com Ruby bindings
1
+ ## Spyonweb.com ruby bindings
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/spyonweb.svg)](http://badge.fury.io/rb/spyonweb) [![Code Climate](https://codeclimate.com/github/bogdanovich/spyonweb-ruby/badges/gpa.svg)](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
- # initialize
24
+ require 'spyonweb'
25
+
23
26
  Spyonweb.api_token = 'MY_TOKEN'
24
27
 
25
- # queries
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/[my-github-username]/spyonweb-ruby/fork )
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`)
@@ -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
- result = e.message
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
 
@@ -1,3 +1,3 @@
1
1
  module Spyonweb
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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
@@ -1,5 +1,8 @@
1
1
  require 'spyonweb'
2
2
 
3
+ require 'pry'
4
+ require 'pry-byebug'
5
+
3
6
  RSpec.configure do |config|
4
7
  config.expect_with :rspec do |expectations|
5
8
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
@@ -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
@@ -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 API ruby bindings}
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.1
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-26 00:00:00.000000000 Z
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 API ruby bindings
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: