ruboty-http_status 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/README.md +26 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/ruboty/handlers/http_status.rb +16 -0
- data/lib/ruboty/http_status.rb +3 -0
- data/lib/ruboty/http_status/actions/http-status-codes.csv +82 -0
- data/lib/ruboty/http_status/actions/http_status.rb +48 -0
- data/lib/ruboty/http_status/version.rb +5 -0
- data/ruboty-http_status.gemspec +29 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68ccda02f963a8915df14fd5450c0b4e6e6e6797
|
4
|
+
data.tar.gz: 1825ca7dd1e1df18b009df6f81f8cdb3d9b130bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 213c444847d9f2c98ffefb3b027249b46cb4a3987c21585e4a55c6cf059f5bd11e0edf62f0b0ec1e53a4e0ad45b92201ca11cfb51ca618b6997e4ff174a60c7a
|
7
|
+
data.tar.gz: 7b73458a1d1442d27f091a6208b638743d3937153d55c6b561a8c463a2871431c5e973948d8383394ff3678a00c41bd3a5fa30ef754c49b94c3925c79a2ae945
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Ruboty::HttpStatus
|
2
|
+
|
3
|
+
Display HTTP Status Code via [Ruboty](https://github.com/r7kamura/ruboty).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruboty'
|
11
|
+
gem 'ruboty-http_status'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```
|
17
|
+
http <code>
|
18
|
+
```
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
1. Fork it ( https://github.com/[my-github-username]/ruboty-http_status/fork )
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
26
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruboty/http_status"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Handlers
|
3
|
+
class HttpStatus < Base
|
4
|
+
on(
|
5
|
+
/^http (?<code>\d{3})$/,
|
6
|
+
name: 'code',
|
7
|
+
all: true,
|
8
|
+
description: 'Display HTTP Status Codes'
|
9
|
+
)
|
10
|
+
|
11
|
+
def code(message)
|
12
|
+
Ruboty::HttpStatus::Actions::HttpStatus.new(message).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
value,description
|
2
|
+
100,Continue
|
3
|
+
101,Switching Protocols
|
4
|
+
102,Processing
|
5
|
+
200,OK
|
6
|
+
201,Created
|
7
|
+
202,Accepted
|
8
|
+
203,Non-Authoritative Information
|
9
|
+
204,No Content
|
10
|
+
205,Reset Content
|
11
|
+
206,Partial Content
|
12
|
+
207,Multi-Status
|
13
|
+
208,Already Reported
|
14
|
+
226,IM Used
|
15
|
+
300,Multiple Choices
|
16
|
+
301,Moved Permanently
|
17
|
+
302,Found
|
18
|
+
303,See Other
|
19
|
+
304,Not Modified
|
20
|
+
305,Use Proxy
|
21
|
+
306,Switch Proxy (Unused)
|
22
|
+
307,Temporary Redirect
|
23
|
+
308,Permanent Redirect
|
24
|
+
400,Bad Request
|
25
|
+
401,Unauthorized
|
26
|
+
402,Payment Required
|
27
|
+
403,Forbidden
|
28
|
+
404,Not Found
|
29
|
+
405,Method Not Allowed
|
30
|
+
406,Not Acceptable
|
31
|
+
407,Proxy Authentication Required
|
32
|
+
408,Request Timeout
|
33
|
+
409,Conflict
|
34
|
+
410,Gone
|
35
|
+
411,Length Required
|
36
|
+
412,Precondition Failed
|
37
|
+
413,Payload Too Large
|
38
|
+
414,URI Too Long
|
39
|
+
415,Unsupported Media Type
|
40
|
+
416,Range Not Satisfiable
|
41
|
+
417,Expectation Failed
|
42
|
+
418,I'm a teapot
|
43
|
+
419,Authentication Timeout
|
44
|
+
420,Method Failure or Enhance Your Calm
|
45
|
+
421,Misdirected Request
|
46
|
+
422,Unprocessable Entity
|
47
|
+
423,Locked
|
48
|
+
424,Failed Dependency
|
49
|
+
425,Unassigned
|
50
|
+
426,Upgrade Required
|
51
|
+
427,Unassigned
|
52
|
+
428,Precondition Required
|
53
|
+
429,Too Many Requests
|
54
|
+
430,Unassigned
|
55
|
+
431,Request Header Fields Too Large
|
56
|
+
440,Login Timeout
|
57
|
+
444,No Response
|
58
|
+
449,Retry With
|
59
|
+
450,Blocked by Windows Parental Controls
|
60
|
+
451,Unavailable For Legal Reasons
|
61
|
+
451,Redirect
|
62
|
+
494,Request Header Too Large
|
63
|
+
495,Cert Error
|
64
|
+
496,No Cert
|
65
|
+
497,HTTP to HTTPS
|
66
|
+
498,Token expired/invalid
|
67
|
+
499,Client Closed Request
|
68
|
+
499,Token required
|
69
|
+
500,Internal Server Error
|
70
|
+
501,Not Implemented
|
71
|
+
502,Bad Gateway
|
72
|
+
503,Service Unavailable
|
73
|
+
504,Gateway Timeout
|
74
|
+
505,HTTP Version Not Supported
|
75
|
+
506,Variant Also Negotiates
|
76
|
+
507,Insufficient Storage
|
77
|
+
508,Loop Detected
|
78
|
+
509,Unassigned
|
79
|
+
510,Not Extended
|
80
|
+
511,Network Authentication Required
|
81
|
+
598,Network read timeout error
|
82
|
+
599,Network connect timeout error
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module HttpStatus
|
6
|
+
module Actions
|
7
|
+
class HttpStatus < Ruboty::Actions::Base
|
8
|
+
attr_reader :message, :code
|
9
|
+
|
10
|
+
def initialize(message)
|
11
|
+
@message = message
|
12
|
+
@code = message[:code]
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
message.reply(reason_phrase)
|
17
|
+
end
|
18
|
+
|
19
|
+
def reason_phrase
|
20
|
+
doc = parse
|
21
|
+
|
22
|
+
# If url doesn't exist,
|
23
|
+
# httpstatus.es returns 500 Internal Server Error
|
24
|
+
if doc == '500'
|
25
|
+
"HTTP Status Code #{code} doesn't exist."
|
26
|
+
else
|
27
|
+
doc.at_xpath(xpath).text
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def xpath
|
32
|
+
'//div[@id="wrapper"]/div[@class="header"]/span[@class="status_title"]'
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse
|
36
|
+
html = open(url) { |f| f.read }
|
37
|
+
Nokogiri::HTML.parse(html, nil, nil)
|
38
|
+
rescue OpenURI::HTTPError => error
|
39
|
+
error.io.status.first
|
40
|
+
end
|
41
|
+
|
42
|
+
def url
|
43
|
+
"http://httpstatus.es/#{code}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/http_status/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ruboty-http_status'
|
8
|
+
spec.version = Ruboty::HttpStatus::VERSION
|
9
|
+
spec.authors = ['Takahiro OKUMURA']
|
10
|
+
spec.email = ['hfm.garden@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Ruboty plugin: Display HTTP Status Codes'
|
13
|
+
spec.description = 'Ruboty plugin: Display HTTP Status Codes'
|
14
|
+
spec.homepage = ''
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'ruboty'
|
23
|
+
spec.add_runtime_dependency 'nokogiri'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'test-unit'
|
27
|
+
spec.add_development_dependency 'mocha'
|
28
|
+
spec.add_development_dependency 'simplecov'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-http_status
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takahiro OKUMURA
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: 'Ruboty plugin: Display HTTP Status Codes'
|
112
|
+
email:
|
113
|
+
- hfm.garden@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
|
+
- Gemfile
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bin/console
|
124
|
+
- bin/setup
|
125
|
+
- lib/ruboty/handlers/http_status.rb
|
126
|
+
- lib/ruboty/http_status.rb
|
127
|
+
- lib/ruboty/http_status/actions/http-status-codes.csv
|
128
|
+
- lib/ruboty/http_status/actions/http_status.rb
|
129
|
+
- lib/ruboty/http_status/version.rb
|
130
|
+
- ruboty-http_status.gemspec
|
131
|
+
homepage: ''
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.4.5
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: 'Ruboty plugin: Display HTTP Status Codes'
|
155
|
+
test_files: []
|