hscode 0.1.1 → 0.1.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/.gitignore +1 -0
- data/lib/hscode.rb +2 -1
- data/lib/hscode/input_parser.rb +31 -2
- data/lib/hscode/status_code_types.rb +9 -0
- data/lib/hscode/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ba75b84c873bd24488f57b3ba9495adde410f6c
|
4
|
+
data.tar.gz: 44e49b551d43c3e925854c295441c5bf8704bbaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 288bbe23d7491261b40f1333da46adeed05b577d9753374e48edb389b919805e5be8ae8d3a912a4a53d5cee00ae77bb34cd58f2222f562b37b1b0db5c77ffd75
|
7
|
+
data.tar.gz: ac59a9eefb2f3104603f62c98f6ad336238e57582a4565a5d43c9875c7d83af73162d28c3c7e32c3ec0069e6b0083c7384d6c74a527967b5d1e22e01b59f6eb5
|
data/.gitignore
CHANGED
data/lib/hscode.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'hscode/version'
|
2
2
|
require 'hscode/input_parser'
|
3
3
|
require 'hscode/http_status_codes'
|
4
|
+
require 'hscode/status_code_types'
|
4
5
|
require 'optparse'
|
5
6
|
require 'ostruct'
|
6
7
|
|
@@ -18,7 +19,7 @@ module Hscode
|
|
18
19
|
|
19
20
|
unless status_code
|
20
21
|
puts "#{options.status_code} is not a valid code. See 'hscode --help'."
|
21
|
-
exit
|
22
|
+
exit 1
|
22
23
|
end
|
23
24
|
|
24
25
|
PrettyPrint.print(
|
data/lib/hscode/input_parser.rb
CHANGED
@@ -52,8 +52,11 @@ module Hscode
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def list_status_codes(opts)
|
55
|
-
opts.on('-l', '--list',
|
56
|
-
|
55
|
+
opts.on('-l', '--list [TYPE]',
|
56
|
+
'List all HTTP status codes of type') do |type|
|
57
|
+
print_all_codes unless type
|
58
|
+
options.status_type = type
|
59
|
+
print_all_codes_by_type(type)
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
@@ -63,6 +66,7 @@ module Hscode
|
|
63
66
|
hscode -c 200
|
64
67
|
hscode -c 200 -v
|
65
68
|
hscode -l
|
69
|
+
hscode -l 2xx
|
66
70
|
'
|
67
71
|
exit
|
68
72
|
end
|
@@ -75,6 +79,31 @@ module Hscode
|
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
82
|
+
def print_all_codes_by_type(type)
|
83
|
+
unless type =~ /\A[1-5]x{2}\z/
|
84
|
+
abort "#{type} is not a valid code type. See 'hscode --help'."
|
85
|
+
end
|
86
|
+
|
87
|
+
colour_code = type.to_s[0]
|
88
|
+
PrettyPrint.print("#{type} #{STATUS_CODE_TYPES[type]}\n", colour_code)
|
89
|
+
|
90
|
+
process_code_type(type, colour_code)
|
91
|
+
end
|
92
|
+
|
93
|
+
def process_code_type(type, colour)
|
94
|
+
code_type_group(type).map do |code, info_hash|
|
95
|
+
PrettyPrint.print("#{code} - #{info_hash[:title]}", colour)
|
96
|
+
end
|
97
|
+
|
98
|
+
exit
|
99
|
+
end
|
100
|
+
|
101
|
+
def code_type_group(type)
|
102
|
+
HTTP_STATUS_CODES.select do |code, _|
|
103
|
+
type.start_with? code.to_s[0]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
78
107
|
def print_all_codes
|
79
108
|
HTTP_STATUS_CODES.map do |code, info_hash|
|
80
109
|
colour_code = code.to_s[0]
|
data/lib/hscode/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hscode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Herbert Kagumba
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-03-
|
12
|
+
date: 2017-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- lib/hscode/http_status_codes.rb
|
207
207
|
- lib/hscode/input_parser.rb
|
208
208
|
- lib/hscode/pretty_print.rb
|
209
|
+
- lib/hscode/status_code_types.rb
|
209
210
|
- lib/hscode/version.rb
|
210
211
|
homepage: https://akabiru.github.io/hscode/
|
211
212
|
licenses:
|