faraday-cli 0.0.1.pre → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.faraday.rb +14 -0
- data/.gitignore +1 -0
- data/README.md +41 -0
- data/TODO +2 -174
- data/VERSION +1 -1
- data/bin/faraday-cli +78 -0
- data/faraday-cli.gemspec +14 -19
- data/lib/faraday/cli.rb +8 -3
- data/lib/faraday/cli/client.rb +3 -0
- data/lib/faraday/cli/middleware_fetcher.rb +30 -0
- data/lib/faraday/cli/middleware_fetcher/container.rb +15 -0
- data/lib/faraday/cli/response_formatter.rb +24 -0
- data/lib/faraday/cli/version.rb +1 -0
- metadata +36 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f05a956dccfc757f41470e2d83a9073c992b1959
|
4
|
+
data.tar.gz: b9e8b968189f9034bf5ce6d3511c684f3c06a9b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3205560b172da216bc751eccd3e9c92416cedede685212d949357c2dc3d3482857bcf873aef60a196ded4e42b628ec857c381a7c193019ad2ea020ebf30b0490
|
7
|
+
data.tar.gz: f9b823c5abf8358688beeb0a41d58847055dd32047fee9b5c97c2b75a50d14841f655138da1984b594e5670d480f9a6d9edd13096ae194923a211b4f18f86f11
|
data/.faraday.rb
ADDED
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,47 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
+
#### Basic
|
25
|
+
|
26
|
+
$ faraday-cli --help
|
27
|
+
Usage: faraday-cli [options] <url>
|
28
|
+
-V, --version Show version number and quit
|
29
|
+
-X, --request COMMAND Specify http request command to use
|
30
|
+
-H, --header HEADER:VALUE Pass custom header LINE to server (H)
|
31
|
+
-q, --query key=value Pass Query key values to use in the request
|
32
|
+
|
33
|
+
$ faraday-cli http://www.google.com -q "q=hello world"
|
34
|
+
|
35
|
+
#### Advanced
|
36
|
+
|
37
|
+
because it's faraday, you can use faraday middlewares as how you pleased
|
38
|
+
just make a file with the following name: ".faraday.rb"
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
|
42
|
+
class MyAwesomeMiddleware
|
43
|
+
|
44
|
+
def initialize(app)
|
45
|
+
@app = app
|
46
|
+
end
|
47
|
+
|
48
|
+
def call(env)
|
49
|
+
puts env.object_id
|
50
|
+
@app.call(env)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
use MyAwesomeMiddleware
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
By default it will look for the current runtime directory for this file.
|
60
|
+
If you are in a project, than it will look for the project folder (Ruby project).
|
61
|
+
If still nothing than for the last place to look it will check for Home folder to find a default middleware file.
|
62
|
+
|
63
|
+
With that you can use all kind of stuff out of the box with your faraday-cli, such as Amazon v3 authentication, or
|
64
|
+
anything that is on the internet :D
|
24
65
|
|
25
66
|
## Development
|
26
67
|
|
data/TODO
CHANGED
@@ -1,178 +1,6 @@
|
|
1
|
-
|
2
|
-
Options: (H) means HTTP/HTTPS only, (F) means FTP only
|
3
|
-
--anyauth Pick "any" authentication method (H)
|
4
|
-
-a, --append Append to target file when uploading (F/SFTP)
|
1
|
+
|
5
2
|
--basic Use HTTP Basic Authentication (H)
|
6
|
-
--
|
7
|
-
--capath DIR CA directory to verify peer against (SSL)
|
8
|
-
-E, --cert CERT[:PASSWD] Client certificate file and password (SSL)
|
9
|
-
--cert-status Verify the status of the server certificate (SSL)
|
10
|
-
--cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)
|
11
|
-
--ciphers LIST SSL ciphers to use (SSL)
|
12
|
-
--compressed Request compressed response (using deflate or gzip)
|
13
|
-
-K, --config FILE Read config from FILE
|
14
|
-
--connect-timeout SECONDS Maximum time allowed for connection
|
15
|
-
-C, --continue-at OFFSET Resumed transfer OFFSET
|
16
|
-
-b, --cookie STRING/FILE Read cookies from STRING/FILE (H)
|
17
|
-
-c, --cookie-jar FILE Write cookies to FILE after operation (H)
|
18
|
-
--create-dirs Create necessary local directory hierarchy
|
19
|
-
--crlf Convert LF to CRLF in upload
|
20
|
-
--crlfile FILE Get a CRL list in PEM format from the given file
|
21
|
-
-d, --data DATA HTTP POST data (H)
|
22
|
-
--data-raw DATA HTTP POST data, '@' allowed (H)
|
23
|
-
--data-ascii DATA HTTP POST ASCII data (H)
|
24
|
-
--data-binary DATA HTTP POST binary data (H)
|
25
|
-
--data-urlencode DATA HTTP POST data url encoded (H)
|
26
|
-
--delegation STRING GSS-API delegation permission
|
27
|
-
--digest Use HTTP Digest Authentication (H)
|
28
|
-
--disable-eprt Inhibit using EPRT or LPRT (F)
|
29
|
-
--disable-epsv Inhibit using EPSV (F)
|
30
|
-
--dns-servers DNS server addrs to use: 1.1.1.1;2.2.2.2
|
31
|
-
--dns-interface Interface to use for DNS requests
|
32
|
-
--dns-ipv4-addr IPv4 address to use for DNS requests, dot notation
|
33
|
-
--dns-ipv6-addr IPv6 address to use for DNS requests, dot notation
|
3
|
+
--proxy-basic Use Basic authentication on the proxy (H)
|
34
4
|
-D, --dump-header FILE Write the headers to FILE
|
35
|
-
--egd-file FILE EGD socket path for random data (SSL)
|
36
|
-
--engine ENGINE Crypto engine (use "--engine list" for list) (SSL)
|
37
|
-
-f, --fail Fail silently (no output at all) on HTTP errors (H)
|
38
|
-
--false-start Enable TLS False Start.
|
39
|
-
-F, --form CONTENT Specify HTTP multipart POST data (H)
|
40
|
-
--form-string STRING Specify HTTP multipart POST data (H)
|
41
|
-
--ftp-account DATA Account data string (F)
|
42
|
-
--ftp-alternative-to-user COMMAND String to replace "USER [name]" (F)
|
43
|
-
--ftp-create-dirs Create the remote dirs if not present (F)
|
44
|
-
--ftp-method [MULTICWD/NOCWD/SINGLECWD] Control CWD usage (F)
|
45
|
-
--ftp-pasv Use PASV/EPSV instead of PORT (F)
|
46
|
-
-P, --ftp-port ADR Use PORT with given address instead of PASV (F)
|
47
|
-
--ftp-skip-pasv-ip Skip the IP address for PASV (F)
|
48
|
-
--ftp-pret Send PRET before PASV (for drftpd) (F)
|
49
|
-
--ftp-ssl-ccc Send CCC after authenticating (F)
|
50
|
-
--ftp-ssl-ccc-mode ACTIVE/PASSIVE Set CCC mode (F)
|
51
|
-
--ftp-ssl-control Require SSL/TLS for FTP login, clear for transfer (F)
|
52
|
-
-G, --get Send the -d data with a HTTP GET (H)
|
53
|
-
-g, --globoff Disable URL sequences and ranges using {} and []
|
54
5
|
-H, --header LINE Pass custom header LINE to server (H)
|
55
|
-
-I, --head Show document info only
|
56
|
-
-h, --help This help text
|
57
|
-
--hostpubmd5 MD5 Hex-encoded MD5 string of the host public key. (SSH)
|
58
|
-
-0, --http1.0 Use HTTP 1.0 (H)
|
59
|
-
--http1.1 Use HTTP 1.1 (H)
|
60
|
-
--http2 Use HTTP 2 (H)
|
61
|
-
--ignore-content-length Ignore the HTTP Content-Length header
|
62
|
-
-i, --include Include protocol headers in the output (H/F)
|
63
|
-
-k, --insecure Allow connections to SSL sites without certs (H)
|
64
|
-
--interface INTERFACE Use network INTERFACE (or address)
|
65
|
-
-4, --ipv4 Resolve name to IPv4 address
|
66
|
-
-6, --ipv6 Resolve name to IPv6 address
|
67
|
-
-j, --junk-session-cookies Ignore session cookies read from file (H)
|
68
|
-
--keepalive-time SECONDS Wait SECONDS between keepalive probes
|
69
|
-
--key KEY Private key file name (SSL/SSH)
|
70
|
-
--key-type TYPE Private key file type (DER/PEM/ENG) (SSL)
|
71
|
-
--krb LEVEL Enable Kerberos with security LEVEL (F)
|
72
|
-
--libcurl FILE Dump libcurl equivalent code of this command line
|
73
|
-
--limit-rate RATE Limit transfer speed to RATE
|
74
|
-
-l, --list-only List only mode (F/POP3)
|
75
|
-
--local-port RANGE Force use of RANGE for local port numbers
|
76
|
-
-L, --location Follow redirects (H)
|
77
|
-
--location-trusted Like '--location', and send auth to other hosts (H)
|
78
|
-
--login-options OPTIONS Server login options (IMAP, POP3, SMTP)
|
79
|
-
-M, --manual Display the full manual
|
80
|
-
--mail-from FROM Mail from this address (SMTP)
|
81
|
-
--mail-rcpt TO Mail to this/these addresses (SMTP)
|
82
|
-
--mail-auth AUTH Originator address of the original email (SMTP)
|
83
|
-
--max-filesize BYTES Maximum file size to download (H/F)
|
84
|
-
--max-redirs NUM Maximum number of redirects allowed (H)
|
85
|
-
-m, --max-time SECONDS Maximum time allowed for the transfer
|
86
|
-
--metalink Process given URLs as metalink XML file
|
87
|
-
--negotiate Use HTTP Negotiate (SPNEGO) authentication (H)
|
88
|
-
-n, --netrc Must read .netrc for user name and password
|
89
|
-
--netrc-optional Use either .netrc or URL; overrides -n
|
90
|
-
--netrc-file FILE Specify FILE for netrc
|
91
|
-
-:, --next Allows the following URL to use a separate set of options
|
92
|
-
--no-alpn Disable the ALPN TLS extension (H)
|
93
|
-
-N, --no-buffer Disable buffering of the output stream
|
94
|
-
--no-keepalive Disable keepalive use on the connection
|
95
|
-
--no-npn Disable the NPN TLS extension (H)
|
96
|
-
--no-sessionid Disable SSL session-ID reusing (SSL)
|
97
|
-
--noproxy List of hosts which do not use proxy
|
98
|
-
--ntlm Use HTTP NTLM authentication (H)
|
99
|
-
--oauth2-bearer TOKEN OAuth 2 Bearer Token (IMAP, POP3, SMTP)
|
100
|
-
-o, --output FILE Write to FILE instead of stdout
|
101
|
-
--pass PASS Pass phrase for the private key (SSL/SSH)
|
102
|
-
--path-as-is Do not squash .. sequences in URL path
|
103
|
-
--pinnedpubkey FILE Public key (PEM/DER) to verify peer against (OpenSSL/GnuTLS/NSS/wolfSSL/CyaSSL/GSKit only)
|
104
|
-
--post301 Do not switch to GET after following a 301 redirect (H)
|
105
|
-
--post302 Do not switch to GET after following a 302 redirect (H)
|
106
|
-
--post303 Do not switch to GET after following a 303 redirect (H)
|
107
|
-
-#, --progress-bar Display transfer progress as a progress bar
|
108
|
-
--proto PROTOCOLS Enable/disable PROTOCOLS
|
109
|
-
--proto-redir PROTOCOLS Enable/disable PROTOCOLS on redirect
|
110
6
|
-x, --proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port
|
111
|
-
--proxy-anyauth Pick "any" proxy authentication method (H)
|
112
|
-
--proxy-basic Use Basic authentication on the proxy (H)
|
113
|
-
--proxy-digest Use Digest authentication on the proxy (H)
|
114
|
-
--proxy-negotiate Use HTTP Negotiate (SPNEGO) authentication on the proxy (H)
|
115
|
-
--proxy-ntlm Use NTLM authentication on the proxy (H)
|
116
|
-
--proxy-service-name NAME SPNEGO proxy service name
|
117
|
-
--service-name NAME SPNEGO service name
|
118
|
-
-U, --proxy-user USER[:PASSWORD] Proxy user and password
|
119
|
-
--proxy1.0 HOST[:PORT] Use HTTP/1.0 proxy on given port
|
120
|
-
-p, --proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)
|
121
|
-
--pubkey KEY Public key file name (SSH)
|
122
|
-
-Q, --quote CMD Send command(s) to server before transfer (F/SFTP)
|
123
|
-
--random-file FILE File for reading random data from (SSL)
|
124
|
-
-r, --range RANGE Retrieve only the bytes within RANGE
|
125
|
-
--raw Do HTTP "raw"; no transfer decoding (H)
|
126
|
-
-e, --referer Referer URL (H)
|
127
|
-
-J, --remote-header-name Use the header-provided filename (H)
|
128
|
-
-O, --remote-name Write output to a file named as the remote file
|
129
|
-
--remote-name-all Use the remote file name for all URLs
|
130
|
-
-R, --remote-time Set the remote file's time on the local output
|
131
|
-
-X, --request COMMAND Specify request command to use
|
132
|
-
--resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS
|
133
|
-
--retry NUM Retry request NUM times if transient problems occur
|
134
|
-
--retry-delay SECONDS Wait SECONDS between retries
|
135
|
-
--retry-max-time SECONDS Retry only within this period
|
136
|
-
--sasl-ir Enable initial response in SASL authentication
|
137
|
-
-S, --show-error Show error. With -s, make curl show errors when they occur
|
138
|
-
-s, --silent Silent mode (don't output anything)
|
139
|
-
--socks4 HOST[:PORT] SOCKS4 proxy on given host + port
|
140
|
-
--socks4a HOST[:PORT] SOCKS4a proxy on given host + port
|
141
|
-
--socks5 HOST[:PORT] SOCKS5 proxy on given host + port
|
142
|
-
--socks5-hostname HOST[:PORT] SOCKS5 proxy, pass host name to proxy
|
143
|
-
--socks5-gssapi-service NAME SOCKS5 proxy service name for GSS-API
|
144
|
-
--socks5-gssapi-nec Compatibility with NEC SOCKS5 server
|
145
|
-
-Y, --speed-limit RATE Stop transfers below RATE for 'speed-time' secs
|
146
|
-
-y, --speed-time SECONDS Trigger 'speed-limit' abort after SECONDS (default: 30)
|
147
|
-
--ssl Try SSL/TLS (FTP, IMAP, POP3, SMTP)
|
148
|
-
--ssl-reqd Require SSL/TLS (FTP, IMAP, POP3, SMTP)
|
149
|
-
-2, --sslv2 Use SSLv2 (SSL)
|
150
|
-
-3, --sslv3 Use SSLv3 (SSL)
|
151
|
-
--ssl-allow-beast Allow security flaw to improve interop (SSL)
|
152
|
-
--stderr FILE Where to redirect stderr (use "-" for stdout)
|
153
|
-
--tcp-nodelay Use the TCP_NODELAY option
|
154
|
-
-t, --telnet-option OPT=VAL Set telnet option
|
155
|
-
--tftp-blksize VALUE Set TFTP BLKSIZE option (must be >512)
|
156
|
-
-z, --time-cond TIME Transfer based on a time condition
|
157
|
-
-1, --tlsv1 Use => TLSv1 (SSL)
|
158
|
-
--tlsv1.0 Use TLSv1.0 (SSL)
|
159
|
-
--tlsv1.1 Use TLSv1.1 (SSL)
|
160
|
-
--tlsv1.2 Use TLSv1.2 (SSL)
|
161
|
-
--trace FILE Write a debug trace to FILE
|
162
|
-
--trace-ascii FILE Like --trace, but without hex output
|
163
|
-
--trace-time Add time stamps to trace/verbose output
|
164
|
-
--tr-encoding Request compressed transfer encoding (H)
|
165
|
-
-T, --upload-file FILE Transfer FILE to destination
|
166
|
-
--url URL URL to work with
|
167
|
-
-B, --use-ascii Use ASCII/text transfer
|
168
|
-
-u, --user USER[:PASSWORD] Server user and password
|
169
|
-
--tlsuser USER TLS username
|
170
|
-
--tlspassword STRING TLS password
|
171
|
-
--tlsauthtype STRING TLS authentication type (default: SRP)
|
172
|
-
--unix-socket FILE Connect through this Unix domain socket
|
173
|
-
-A, --user-agent STRING Send User-Agent STRING to server (H)
|
174
|
-
-v, --verbose Make the operation more talkative
|
175
|
-
-V, --version Show version number and quit
|
176
|
-
-w, --write-out FORMAT Use output FORMAT after completion
|
177
|
-
--xattr Store metadata in extended file attributes
|
178
|
-
-q Disable .curlrc (must be first parameter)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/bin/faraday-cli
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ENV['DEVELOPER_ENV'] == 'true'
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'optparse'
|
8
|
+
require 'faraday/cli'
|
9
|
+
|
10
|
+
|
11
|
+
CLI_OPTIONS = {}
|
12
|
+
OptionParser.new do |o|
|
13
|
+
|
14
|
+
o.banner.concat(' <url>')
|
15
|
+
|
16
|
+
o.on('-V', '--version', 'Show version number and quit') { $stdout.puts(Faraday::CLI::VERSION); exit }
|
17
|
+
|
18
|
+
CLI_OPTIONS[:http_method]= 'get'
|
19
|
+
o.on('-X', '--request COMMAND', 'Specify http request command to use') do |http_method|
|
20
|
+
CLI_OPTIONS[:http_method]= http_method.to_s.strip.downcase
|
21
|
+
end
|
22
|
+
|
23
|
+
CLI_OPTIONS[:http_headers]= []
|
24
|
+
o.on('-H', '--header HEADER:VALUE', 'Pass custom header LINE to server (H)') do |header|
|
25
|
+
CLI_OPTIONS[:http_headers].push(header.split(':'))
|
26
|
+
end
|
27
|
+
|
28
|
+
CLI_OPTIONS[:params]= []
|
29
|
+
o.on('-q','--query key=value','Pass Query key values to use in the request') do |raw_query_pair|
|
30
|
+
CLI_OPTIONS[:params].push(raw_query_pair.split('='))
|
31
|
+
end
|
32
|
+
|
33
|
+
# o.on('-d', '--data PAYLOAD_STRING', 'HTTP POST data (H)') { |payload| CLI_OPTIONS[:payload]= payload }
|
34
|
+
# o.on('--data_file FILE_PATH', 'Read file content for use as payload') do |payload_file|
|
35
|
+
# CLI_OPTIONS[:payload]= File.read(payload_file)
|
36
|
+
# end
|
37
|
+
#
|
38
|
+
# o.on('-A', '--user-agent STRING', 'Send User-Agent STRING to server (H)') do |user_agent|
|
39
|
+
# CLI_OPTIONS[:user_agent]= user_agent
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# o.on('-o', '--output FILE_PATH', 'Write to FILE instead of stdout') { |out_file_path| CLI_OPTIONS[:out_file]= out_file_path }
|
43
|
+
#
|
44
|
+
# o.on('-x', '--proxy HOST:PORT', 'HOST[:PORT] Use proxy on given port') do |host_port_str|
|
45
|
+
# host, port = host_port_str.split(':')
|
46
|
+
# port = '80' if port.nil?
|
47
|
+
#
|
48
|
+
# CLI_OPTIONS[:proxy]= {host: host, port: port}
|
49
|
+
# end
|
50
|
+
|
51
|
+
o.parse!
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# p CLI_OPTIONS
|
56
|
+
# p ARGV
|
57
|
+
|
58
|
+
ALLOWED_HTTP_METHODS = %w(get head post put patch delete options)
|
59
|
+
raise('invalid http method given') unless ALLOWED_HTTP_METHODS.include?(CLI_OPTIONS[:http_method])
|
60
|
+
conn = Faraday.new
|
61
|
+
|
62
|
+
Faraday::CLI::MiddlewareFetcher.extend!(conn)
|
63
|
+
|
64
|
+
response = conn.public_send(CLI_OPTIONS[:http_method]) do |request|
|
65
|
+
request.url(ARGV[0])
|
66
|
+
|
67
|
+
CLI_OPTIONS[:http_headers].each do |key, value|
|
68
|
+
request.headers[key]=value
|
69
|
+
end
|
70
|
+
|
71
|
+
CLI_OPTIONS[:params].each do |key,value|
|
72
|
+
request.params[key]=value
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
$stdout.puts Faraday::CLI::ResponseFormatter.format(response)
|
data/faraday-cli.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'faraday/cli'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "faraday-cli"
|
8
|
-
spec.version =
|
8
|
+
spec.version = Faraday::CLI::VERSION
|
9
9
|
spec.authors = ["Adam Luzsi"]
|
10
10
|
spec.email = ["adamluzsi@gmail.com"]
|
11
11
|
|
@@ -13,24 +13,19 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.description = %q{Console line interface for faraday gem client so you can use your favorite middleware based ruby http client on the terminal!}
|
14
14
|
spec.homepage = "https://github.com/adamluzsi/faraday-cli.rb"
|
15
15
|
|
16
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
-
# delete this section to allow pushing this gem to any host.
|
18
|
-
#if spec.respond_to?(:metadata)
|
19
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
-
#else
|
21
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
-
#end
|
23
|
-
|
24
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
spec.bindir =
|
26
|
-
spec.executables = spec.files.grep(%r{^
|
27
|
-
|
17
|
+
spec.bindir = 'bin'
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
.select{|cli_command| cli_command =~ /^faraday\-cli/ }
|
20
|
+
|
21
|
+
spec.require_paths = ['lib']
|
28
22
|
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency 'bundler', '>= 1.10'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'cucumber'
|
32
27
|
|
33
|
-
spec.add_dependency 'commander'
|
34
28
|
spec.add_dependency 'faraday'
|
29
|
+
spec.add_dependency 'pwd'
|
35
30
|
|
36
31
|
end
|
data/lib/faraday/cli.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'pwd'
|
2
|
+
module Faraday::CLI::MiddlewareFetcher
|
3
|
+
extend self
|
4
|
+
|
5
|
+
require 'faraday/cli/middleware_fetcher/container'
|
6
|
+
|
7
|
+
def extend!(faraday_connection)
|
8
|
+
|
9
|
+
file_name = '.faraday.rb'
|
10
|
+
container = Faraday::CLI::MiddlewareFetcher::Container.new(faraday_connection)
|
11
|
+
|
12
|
+
case true
|
13
|
+
|
14
|
+
when File.exist?(File.join(Dir.pwd, file_name))
|
15
|
+
container.merge!(File.join(Dir.pwd, file_name))
|
16
|
+
|
17
|
+
when File.exist?(File.join(PWD.pwd, file_name))
|
18
|
+
container.merge!(File.join(PWD.pwd, file_name))
|
19
|
+
|
20
|
+
when File.exist?(File.join(ENV['HOME'], file_name))
|
21
|
+
container.merge!(File.join(ENV['HOME'], file_name))
|
22
|
+
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
class Faraday::CLI::MiddlewareFetcher::Container
|
3
|
+
|
4
|
+
extend Forwardable
|
5
|
+
def_delegator :@builder, :use
|
6
|
+
|
7
|
+
def initialize(conn)
|
8
|
+
@builder = conn.builder
|
9
|
+
end
|
10
|
+
|
11
|
+
def merge!(file_path)
|
12
|
+
instance_eval(File.read(file_path))
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
module Faraday::CLI::ResponseFormatter
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def format(faraday_response)
|
6
|
+
formatted_message_parts = []
|
7
|
+
formatted_message_parts << YAML.dump(response_hash_by(faraday_response))
|
8
|
+
formatted_message_parts << faraday_response.body
|
9
|
+
|
10
|
+
formatted_message_parts.join("\n")
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def response_hash_by(faraday_response)
|
16
|
+
{
|
17
|
+
'response' => {
|
18
|
+
'status' => faraday_response.status,
|
19
|
+
'headers' => Hash[faraday_response.headers]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Faraday::CLI::VERSION ||= File.read(File.join(File.dirname(__FILE__),'..','..','..','VERSION')).strip
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,13 +53,13 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: cucumber
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
type: :
|
62
|
+
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
@@ -80,14 +80,30 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pwd
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: Console line interface for faraday gem client so you can use your favorite
|
84
98
|
middleware based ruby http client on the terminal!
|
85
99
|
email:
|
86
100
|
- adamluzsi@gmail.com
|
87
|
-
executables:
|
101
|
+
executables:
|
102
|
+
- faraday-cli
|
88
103
|
extensions: []
|
89
104
|
extra_rdoc_files: []
|
90
105
|
files:
|
106
|
+
- ".faraday.rb"
|
91
107
|
- ".gitignore"
|
92
108
|
- ".rspec"
|
93
109
|
- ".travis.yml"
|
@@ -98,9 +114,15 @@ files:
|
|
98
114
|
- TODO
|
99
115
|
- VERSION
|
100
116
|
- bin/console
|
117
|
+
- bin/faraday-cli
|
101
118
|
- bin/setup
|
102
119
|
- faraday-cli.gemspec
|
103
120
|
- lib/faraday/cli.rb
|
121
|
+
- lib/faraday/cli/client.rb
|
122
|
+
- lib/faraday/cli/middleware_fetcher.rb
|
123
|
+
- lib/faraday/cli/middleware_fetcher/container.rb
|
124
|
+
- lib/faraday/cli/response_formatter.rb
|
125
|
+
- lib/faraday/cli/version.rb
|
104
126
|
homepage: https://github.com/adamluzsi/faraday-cli.rb
|
105
127
|
licenses: []
|
106
128
|
metadata: {}
|
@@ -115,9 +137,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
137
|
version: '0'
|
116
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
139
|
requirements:
|
118
|
-
- - "
|
140
|
+
- - ">="
|
119
141
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
142
|
+
version: '0'
|
121
143
|
requirements: []
|
122
144
|
rubyforge_project:
|
123
145
|
rubygems_version: 2.2.2
|