http_response_code-test 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/http_response_code-test +30 -0
- data/http_response_code-test.gemspec +24 -0
- data/lib/http_response_code/test.rb +4 -0
- data/lib/http_response_code/test/presence_tester.rb +70 -0
- data/lib/http_response_code/test/version.rb +5 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0061bca033fe1974acd9639971097a93663703d
|
4
|
+
data.tar.gz: 850eec90a1633ca6fa80fd1498e165d98b8b601f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50320eef7fdecf303863ae93518c5c1dcaa67d8fbd385fa9fc5cb61fdcc59ed143e23078f4696984b2a27b226bd8fe0042af33b88b5bbd29616bfe9c53670073
|
7
|
+
data.tar.gz: 76f957da02d11f4c64b512530ee86eb960783d1a6369be54e9b8ac624b6e037733b4b2e79410044ada6a84e3c512d506de5d590e9e6e16894e73f6ae8721701e
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ian Ker-Seymer
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# HTTPResponseCode::Test
|
2
|
+
|
3
|
+
A simple way to bulk test the response codes of sites on a server.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'http_response_code-test'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install http_response_code-test
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This is meant to mostly be used as a command-line tool to check the response of a ton of pages.
|
22
|
+
|
23
|
+
1. First, make a .txt file of all of your sites
|
24
|
+
* `$ find /var/www -name index.php > sites.txt`
|
25
|
+
2. Now, run the CL tool to test the HTTP Response Codes
|
26
|
+
* `$ http_response_code-test -s sites.txt -d http://foobar.example.com`
|
27
|
+
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/[my-github-username]/http_response_code-test/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'http_response_code/test'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opt_parser = OptionParser.new do |opts|
|
9
|
+
include HTTPResponseCode::Test
|
10
|
+
|
11
|
+
opts.banner = "Usage: test -s SITES_FILES -d DOMAIN"
|
12
|
+
|
13
|
+
options[:site] = nil
|
14
|
+
opts.on("-s", "--sites SITES", "Include a sites file SITES") do |sites|
|
15
|
+
options[:site] = sites.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
options[:domain] = nil
|
19
|
+
opts.on("-d", "--domain DOMAIN", "Include domain of site DOMAIN") do |domain|
|
20
|
+
options[:domain] = domain.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
# site = AdGenomics::Test::PresenceTester.new(site: options[:site], domain: options[:domain])
|
24
|
+
# site.run_test
|
25
|
+
end
|
26
|
+
|
27
|
+
opt_parser.parse!
|
28
|
+
|
29
|
+
site = HTTPResponseCode::Test::PresenceTester.new(site: options[:site], domain: options[:domain])
|
30
|
+
site.run_test
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'http_response_code/test/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "http_response_code-test"
|
8
|
+
spec.version = HTTPResponseCode::Test::VERSION
|
9
|
+
spec.authors = ["Ian Ker-Seymer"]
|
10
|
+
spec.email = ["i.kerseymer@gmail.com"]
|
11
|
+
spec.summary = %q{Tests HTTP response codes of given .txt file}
|
12
|
+
spec.homepage = "https://github.com/ianks/http_response_code-test"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
|
23
|
+
spec.add_dependency "colorize"
|
24
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module HTTPResponseCode
|
2
|
+
module Test
|
3
|
+
class PresenceTester
|
4
|
+
|
5
|
+
def initialize(params)
|
6
|
+
@site = params[:site]
|
7
|
+
@domain = params[:domain]
|
8
|
+
@sites = text_to_array(@site)
|
9
|
+
end
|
10
|
+
|
11
|
+
def run_test
|
12
|
+
error_count = 0
|
13
|
+
each_site do |site|
|
14
|
+
res = response(site)
|
15
|
+
puts "[#{res.code}] #{res.message.upcase}:
|
16
|
+
".colorize(response_color(res.code)) + "#{create_link(site)}"
|
17
|
+
end
|
18
|
+
finish_test error_count
|
19
|
+
end
|
20
|
+
|
21
|
+
def each_site(&block)
|
22
|
+
@sites.each do |site|
|
23
|
+
yield site
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def text_to_array(file)
|
30
|
+
File.read(file).split(/\n/).each do |site|
|
31
|
+
site[0] = ''
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def response_color(code)
|
36
|
+
case code.to_s[0]
|
37
|
+
when '1'
|
38
|
+
:yellow
|
39
|
+
when '2'
|
40
|
+
:green
|
41
|
+
when '3'
|
42
|
+
:blue
|
43
|
+
when '4'
|
44
|
+
:red
|
45
|
+
when '5'
|
46
|
+
:red
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_link(site)
|
51
|
+
URI.parse "#{@domain}#{site}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def response(site)
|
55
|
+
url = create_link(site)
|
56
|
+
req = Net::HTTP.new(url.host, url.port)
|
57
|
+
res = req.request_head(url.path)
|
58
|
+
end
|
59
|
+
|
60
|
+
def finish_test
|
61
|
+
puts "The test finished with #{error_count.colorize(:blue)} failures."
|
62
|
+
if error_count == 0
|
63
|
+
exit(0)
|
64
|
+
else
|
65
|
+
exit(1)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: http_response_code-test
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ian Ker-Seymer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- i.kerseymer@gmail.com
|
58
|
+
executables:
|
59
|
+
- http_response_code-test
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/http_response_code-test
|
69
|
+
- http_response_code-test.gemspec
|
70
|
+
- lib/http_response_code/test.rb
|
71
|
+
- lib/http_response_code/test/presence_tester.rb
|
72
|
+
- lib/http_response_code/test/version.rb
|
73
|
+
homepage: https://github.com/ianks/http_response_code-test
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.14
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Tests HTTP response codes of given .txt file
|
97
|
+
test_files: []
|