httpdisk 0.2.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/Gemfile.lock +16 -4
- data/README.md +32 -6
- data/Rakefile +14 -11
- data/bin/httpdisk +9 -7
- data/bin/httpdisk-grep +46 -0
- data/httpdisk.gemspec +1 -0
- data/lib/httpdisk.rb +10 -5
- data/lib/httpdisk/cache.rb +31 -21
- data/lib/httpdisk/cache_key.rb +15 -6
- data/lib/httpdisk/cli/args.rb +57 -0
- data/lib/httpdisk/cli/main.rb +169 -0
- data/lib/httpdisk/client.rb +82 -19
- data/lib/httpdisk/error.rb +4 -0
- data/lib/httpdisk/grep/args.rb +35 -0
- data/lib/httpdisk/grep/main.rb +112 -0
- data/lib/httpdisk/grep/printer.rb +99 -0
- data/lib/httpdisk/payload.rb +7 -5
- data/lib/httpdisk/slop_duration.rb +24 -0
- data/lib/httpdisk/sloptions.rb +105 -0
- data/lib/httpdisk/version.rb +1 -1
- metadata +25 -4
- data/lib/httpdisk/cli.rb +0 -223
- data/lib/httpdisk/cli_slop.rb +0 -54
data/lib/httpdisk/cli_slop.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# manually load dependencies here since this is loaded standalone by bin
|
2
|
-
require 'httpdisk/error'
|
3
|
-
require 'httpdisk/version'
|
4
|
-
require 'slop'
|
5
|
-
|
6
|
-
module HTTPDisk
|
7
|
-
# Slop parsing. This is broken out so we can run without require 'httpdisk'.
|
8
|
-
module CliSlop
|
9
|
-
def self.slop(args)
|
10
|
-
slop = Slop.parse(args) do |o|
|
11
|
-
o.banner = 'httpdisk [options] [url]'
|
12
|
-
|
13
|
-
# similar to curl
|
14
|
-
o.separator 'Similar to curl:'
|
15
|
-
o.string '-d', '--data', 'HTTP POST data'
|
16
|
-
o.array '-H', '--header', 'pass custom header(s) to server', delimiter: nil
|
17
|
-
o.boolean '-i', '--include', 'include response headers in the output'
|
18
|
-
o.integer '-m', '--max-time', 'maximum time allowed for the transfer'
|
19
|
-
o.string '-o', '--output', 'write to file instead of stdout'
|
20
|
-
o.string '-x', '--proxy', 'use host[:port] as proxy'
|
21
|
-
o.string '-X', '--request', 'HTTP method to use'
|
22
|
-
o.integer '--retry', 'retry request if problems occur'
|
23
|
-
o.boolean '-s', '--silent', "silent mode (don't print errors)"
|
24
|
-
o.string '-A', '--user-agent', 'send User-Agent to server'
|
25
|
-
|
26
|
-
# from httpdisk
|
27
|
-
o.separator 'Specific to httpdisk:'
|
28
|
-
o.string '--dir', 'httpdisk cache directory (defaults to ~/httpdisk)'
|
29
|
-
o.string '--expires', 'when to expire cached requests (ex: 1h, 2d, 3w)'
|
30
|
-
o.boolean '--force', "don't read anything from cache (but still write)"
|
31
|
-
o.boolean '--force-errors', "don't read errors from cache (but still write)"
|
32
|
-
o.boolean '--status', 'show status for a url in the cache'
|
33
|
-
|
34
|
-
# generic
|
35
|
-
o.boolean '--version', 'show version' do
|
36
|
-
puts "httpdisk #{HTTPDisk::VERSION}"
|
37
|
-
exit
|
38
|
-
end
|
39
|
-
o.on '--help', 'show this help' do
|
40
|
-
puts o
|
41
|
-
exit
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
raise Slop::Error, '' if args.empty?
|
46
|
-
raise Slop::Error, 'no URL specified' if slop.args.empty?
|
47
|
-
raise Slop::Error, 'more than one URL specified' if slop.args.length > 1
|
48
|
-
|
49
|
-
slop.to_h.tap do
|
50
|
-
_1[:url] = slop.args.first
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|