check_http 0.0.8 → 0.0.9
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.
- data/.rspec +2 -0
- data/README.md +2 -0
- data/Rakefile +5 -1
- data/check_http.gemspec +2 -0
- data/lib/check_http/checker.rb +16 -2
- data/lib/check_http/version.rb +1 -1
- data/spec/check_http/checker_spec.rb +39 -0
- data/spec/spec_helper.rb +8 -0
- metadata +40 -3
data/.rspec
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/check_http.gemspec
CHANGED
data/lib/check_http/checker.rb
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
module CheckHTTP
|
2
2
|
class Checker
|
3
|
-
|
3
|
+
attr_accessor :blacklist
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
self.blacklist = default_blacklist
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_blacklist
|
4
10
|
[:response_header, :response_body, :httpauth_avail, :starttransfer_time, :appconnect_time, :pretransfer_time]
|
5
11
|
end
|
6
12
|
|
7
13
|
def check(url)
|
14
|
+
clean(sample(url)).merge(:url => url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def clean(result)
|
18
|
+
result.reject { |k,v| blacklist.include?(k) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def sample(url)
|
8
22
|
ethon = Ethon::Easy.new
|
9
23
|
ethon.url = url
|
10
24
|
ethon.prepare
|
11
25
|
ethon.perform
|
12
|
-
ethon.to_hash
|
26
|
+
ethon.to_hash
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
data/lib/check_http/version.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CheckHTTP::Checker do
|
4
|
+
let(:checker) { CheckHTTP::Checker.new }
|
5
|
+
let(:url) { 'http://example.com' }
|
6
|
+
let(:mock_result) { {:return_code=>:ok,
|
7
|
+
:total_time=>0.037439,
|
8
|
+
:connect_time=>0.009433,
|
9
|
+
:namelookup_time=>0.003042,
|
10
|
+
:effective_url=>"http://google.com",
|
11
|
+
:primary_ip=>"74.125.224.98",
|
12
|
+
:response_code=>301,
|
13
|
+
:redirect_count=>0} }
|
14
|
+
|
15
|
+
it 'should be able to sample a url' do
|
16
|
+
checker.should_receive(:sample).with(url) { {} }
|
17
|
+
checker.sample(url)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return sampled results with url merged in' do
|
21
|
+
checker.stub(:sample).with(url) { mock_result }
|
22
|
+
checker.check(url).should eq(mock_result.merge(:url => url))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should clean sampled results before returning' do
|
26
|
+
checker.stub(:sample).with(url) { mock_result }
|
27
|
+
checker.should_receive(:clean).with(mock_result) { mock_result }
|
28
|
+
checker.check(url)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be able to remove blacklisted items' do
|
32
|
+
checker.blacklist = [:foo]
|
33
|
+
checker.clean({:foo => 1, :baz => 2}).should eq({:baz => 2})
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should set the default blacklist upon initialization' do
|
37
|
+
checker.blacklist.should eq(checker.default_blacklist)
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ethon
|
@@ -43,6 +43,38 @@ dependencies:
|
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 0.0.4
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
46
78
|
description: a simple interface to gather curl stats against an HTTP resource
|
47
79
|
email:
|
48
80
|
- michael.gorsuch@gmail.com
|
@@ -52,6 +84,7 @@ extensions: []
|
|
52
84
|
extra_rdoc_files: []
|
53
85
|
files:
|
54
86
|
- .gitignore
|
87
|
+
- .rspec
|
55
88
|
- Gemfile
|
56
89
|
- LICENSE.txt
|
57
90
|
- README.md
|
@@ -62,6 +95,8 @@ files:
|
|
62
95
|
- lib/check_http/checker.rb
|
63
96
|
- lib/check_http/cli.rb
|
64
97
|
- lib/check_http/version.rb
|
98
|
+
- spec/check_http/checker_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
65
100
|
homepage: https://github.com/gorsuch/check_http
|
66
101
|
licenses: []
|
67
102
|
post_install_message:
|
@@ -86,4 +121,6 @@ rubygems_version: 1.8.23
|
|
86
121
|
signing_key:
|
87
122
|
specification_version: 3
|
88
123
|
summary: a simple interface to gather curl stats against an HTTP resource
|
89
|
-
test_files:
|
124
|
+
test_files:
|
125
|
+
- spec/check_http/checker_spec.rb
|
126
|
+
- spec/spec_helper.rb
|