faraday-cli 0.2.0 → 0.3.0
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/README.md +23 -12
- data/VERSION +1 -1
- data/bin/faraday-cli +10 -0
- data/lib/faraday/cli/middleware_fetcher.rb +14 -11
- data/lib/faraday/cli/middleware_fetcher/container.rb +1 -0
- metadata +2 -3
- data/.faraday.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5ef5d377a91ad8e8eabdda498fcad557a29db2e
|
4
|
+
data.tar.gz: 9c35a33ccb6620728fd954a277ec5ee5d7eb7ff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fa22cfa76b24c399d4d23a475c261645b561829e42425f42e86c32e915952be0e857dfaef085307789472e67fe46bec4457d284fbcbd6149d264807aa6f86f
|
7
|
+
data.tar.gz: c51b1ec867372bd33d75f993f6b00d18e4b1c13e13c99bc8aed6cf4f4563f88aa2467ec3a479d2995606a5ef380aab8b4aa2e9a48d132bdf4653ddad74ecb872
|
data/README.md
CHANGED
@@ -21,21 +21,32 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
|
24
|
+
### CLI options
|
25
|
+
|
26
|
+
```shell
|
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
|
+
-d, --data PAYLOAD_STRING HTTP POST data (H)
|
33
|
+
--upload_file KEY=FILE_PATH[:CONTENT_TYPE]
|
34
|
+
Pass File upload io in the request pointing to the given file
|
35
|
+
-A, --user-agent STRING Send User-Agent STRING to server (H)
|
36
|
+
-o, --output FILE_PATH Write to FILE instead of stdout
|
37
|
+
-s, --silent Silent mode (don't output anything)
|
38
|
+
-c, --config FILE_PATH File path to the .faraday.rb if you want use other than default
|
39
|
+
|
40
|
+
faraday-cli http://www.google.com -q "q=hello world"
|
41
|
+
```
|
25
42
|
|
26
|
-
|
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"
|
43
|
+
### Middleware use
|
34
44
|
|
35
|
-
|
45
|
+
You can use middlewares with ".faraday.rb" file.
|
46
|
+
Put any middleware related configuration into the file,
|
47
|
+
and use the 'use' method to include into the faraday connection.
|
36
48
|
|
37
|
-
|
38
|
-
just make a file with the following name: ".faraday.rb"
|
49
|
+
you can use any faraday middlewares as how you pleased.
|
39
50
|
|
40
51
|
```ruby
|
41
52
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/faraday-cli
CHANGED
@@ -71,6 +71,10 @@ OptionParser.new do |o|
|
|
71
71
|
CLI_OPTIONS[:config_file_paths] << File.realpath(file_path)
|
72
72
|
end
|
73
73
|
|
74
|
+
o.on('-M','--middlewares','Show current middleware stack') do
|
75
|
+
CLI_OPTIONS[:flags] << :show_middlewares
|
76
|
+
end
|
77
|
+
|
74
78
|
o.parse!
|
75
79
|
|
76
80
|
end
|
@@ -88,6 +92,12 @@ connection = Faraday.new do |builder|
|
|
88
92
|
|
89
93
|
end
|
90
94
|
|
95
|
+
if CLI_OPTIONS[:flags].include?(:show_middlewares)
|
96
|
+
$stdout.puts(connection.builder.handlers.map(&:inspect))
|
97
|
+
exit
|
98
|
+
end
|
99
|
+
|
100
|
+
|
91
101
|
response = connection.public_send(CLI_OPTIONS[:http_method].downcase) do |request|
|
92
102
|
|
93
103
|
request.url(ARGV[0])
|
@@ -5,29 +5,32 @@ module Faraday::CLI::MiddlewareFetcher
|
|
5
5
|
require 'faraday/cli/middleware_fetcher/container'
|
6
6
|
|
7
7
|
def extend!(faraday_connection_builder, *config_file_paths)
|
8
|
-
|
9
|
-
file_name = '.faraday.rb'
|
10
8
|
container = Faraday::CLI::MiddlewareFetcher::Container.new(faraday_connection_builder)
|
9
|
+
get_file_paths(config_file_paths).each { |file_path| container.merge!(file_path) }
|
10
|
+
end
|
11
11
|
|
12
|
+
protected
|
13
|
+
|
14
|
+
def get_file_paths(config_file_paths)
|
15
|
+
file_name = '{.faraday.rb,.faraday}'
|
12
16
|
case
|
13
17
|
|
14
18
|
when !config_file_paths.empty?
|
15
|
-
config_file_paths
|
19
|
+
config_file_paths
|
16
20
|
|
17
|
-
when
|
18
|
-
|
21
|
+
when !(file_paths = Dir.glob(File.join(Dir.pwd, file_name))).empty?
|
22
|
+
file_paths
|
19
23
|
|
20
|
-
when
|
21
|
-
|
24
|
+
when !(file_paths = Dir.glob(File.join(PWD.pwd, file_name))).empty?
|
25
|
+
file_paths
|
22
26
|
|
23
|
-
when
|
24
|
-
|
27
|
+
when !(file_paths = Dir.glob(File.join(ENV['HOME'], file_name))).empty?
|
28
|
+
file_paths
|
25
29
|
|
26
30
|
else
|
27
|
-
|
31
|
+
[]
|
28
32
|
|
29
33
|
end
|
30
|
-
|
31
34
|
end
|
32
35
|
|
33
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,7 +103,6 @@ executables:
|
|
103
103
|
extensions: []
|
104
104
|
extra_rdoc_files: []
|
105
105
|
files:
|
106
|
-
- ".faraday.rb"
|
107
106
|
- ".gitignore"
|
108
107
|
- ".rspec"
|
109
108
|
- ".travis.yml"
|