api_hammer 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/hc +10 -0
- data/lib/api_hammer/unmunged_request_params.rb +13 -4
- data/lib/api_hammer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32321326726e5c0d8d195dfb62c59fbaeb6837ec
|
4
|
+
data.tar.gz: f770e32fc9bd8ee16d1f17d6c30b4dceeca03131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 843b147c0c7d60776834ffe0ea3d2c9e8c25e42558ea398df825478217969309af8700a2cbafe3ffc1f885a61adcbb183d80a495881a664b508850aa94a00cc5
|
7
|
+
data.tar.gz: 2202a0ebb1fbf519a37ecd5ab223418a3e38254616c7367d1dbb0da8b1c72fd1d860db831fa5031012949bc49a81284b224dfb22500f98d93bece4c010c84216
|
data/CHANGELOG.md
CHANGED
data/bin/hc
CHANGED
@@ -7,6 +7,7 @@ require 'rubygems'
|
|
7
7
|
require 'faraday'
|
8
8
|
require 'logger'
|
9
9
|
require 'yaml'
|
10
|
+
require 'pathname'
|
10
11
|
|
11
12
|
require 'api_hammer/faraday/outputter'
|
12
13
|
require 'api_hammer/version'
|
@@ -47,6 +48,9 @@ opt_parser = OptionParser.new do |opts|
|
|
47
48
|
opts.on("-o", "--output OUTPUT", "write response to file") do |v|
|
48
49
|
$options[:output] = v
|
49
50
|
end
|
51
|
+
opts.on("--input INPUT", "read request body from file") do |v|
|
52
|
+
$options[:input] = v
|
53
|
+
end
|
50
54
|
opts.on("--oauth-token TOKEN", "OAuth 1.0 token") do |token|
|
51
55
|
$oauth[:token] = token
|
52
56
|
end
|
@@ -97,6 +101,12 @@ end
|
|
97
101
|
|
98
102
|
httpmethod, url, body = *ARGV
|
99
103
|
|
104
|
+
if $options[:input] == '-'
|
105
|
+
body = STDIN.read
|
106
|
+
elsif $options[:input]
|
107
|
+
body = Pathname.new($options[:input]).read
|
108
|
+
end
|
109
|
+
|
100
110
|
unless url['://']
|
101
111
|
url = 'http://' + url
|
102
112
|
end
|
@@ -7,10 +7,19 @@ module ApiHammer::Rails
|
|
7
7
|
# TODO when we are on a rails which has ActionDispatch::Request::Utils.perform_deep_munge, use that instead
|
8
8
|
# of clobbering methods
|
9
9
|
@unmunged_params ||= Thread.exclusive do
|
10
|
-
|
11
|
-
|
10
|
+
if ActionDispatch::Request.const_defined?(:Utils) && ActionDispatch::Request::Utils.respond_to?(:deep_munge)
|
11
|
+
# rails 4
|
12
|
+
deep_munge_owner = (class << ActionDispatch::Request::Utils; self; end)
|
13
|
+
else
|
14
|
+
# rails 3
|
15
|
+
deep_munge_owner = ActionDispatch::Request
|
12
16
|
end
|
13
|
-
|
17
|
+
|
18
|
+
unless deep_munge_owner.method_defined?(:real_deep_munge)
|
19
|
+
deep_munge_owner.send(:alias_method, :real_deep_munge, :deep_munge)
|
20
|
+
end
|
21
|
+
deep_munge_owner.send(:define_method, :deep_munge) { |hash| hash }
|
22
|
+
|
14
23
|
begin
|
15
24
|
unmunged_params = nil
|
16
25
|
newenv = request.env.merge('action_dispatch.request.request_parameters' => nil)
|
@@ -19,7 +28,7 @@ module ApiHammer::Rails
|
|
19
28
|
end).call(newenv)
|
20
29
|
unmunged_params || ActionDispatch::Request.new(newenv).request_parameters
|
21
30
|
ensure
|
22
|
-
|
31
|
+
deep_munge_owner.send(:alias_method, :deep_munge, :real_deep_munge)
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
data/lib/api_hammer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_hammer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|