api_hammer 0.11.1 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdd05fc523d6412474d2f8e7e9391ae957eeb322
4
- data.tar.gz: 5cd309f7d6e4b0df81dfb601bcec2ff6e228afe9
3
+ metadata.gz: 32321326726e5c0d8d195dfb62c59fbaeb6837ec
4
+ data.tar.gz: f770e32fc9bd8ee16d1f17d6c30b4dceeca03131
5
5
  SHA512:
6
- metadata.gz: 3c0a8f2cb93d538ae70d6061abd1021d8c0b3b95c6f1e340e2e28e7f321e28d91f1affee9ef990c6eae2923402cb30cb8c66883707cfdfce8ce2edc08e1b12db
7
- data.tar.gz: 7011a6bc4b70966eeddad76af884e2c821e1b77be9aeacaee76222fed61818aaa545f3e5e43382173576f5a6851b904af45c5ae18f076ae15417db23e6cf6dcb
6
+ metadata.gz: 843b147c0c7d60776834ffe0ea3d2c9e8c25e42558ea398df825478217969309af8700a2cbafe3ffc1f885a61adcbb183d80a495881a664b508850aa94a00cc5
7
+ data.tar.gz: 2202a0ebb1fbf519a37ecd5ab223418a3e38254616c7367d1dbb0da8b1c72fd1d860db831fa5031012949bc49a81284b224dfb22500f98d93bece4c010c84216
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.12.0
2
+ - hc --input option
3
+ - rails 4 support for unmunged_request_params
4
+
1
5
  # v0.11.1
2
6
  - bugfix trailingnewline
3
7
 
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
- unless ActionDispatch::Request.method_defined?(:real_deep_munge)
11
- ActionDispatch::Request.send(:alias_method, :real_deep_munge, :deep_munge)
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
- ActionDispatch::Request.send(:define_method, :deep_munge) { |hash| hash }
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
- ActionDispatch::Request.send(:alias_method, :deep_munge, :real_deep_munge)
31
+ deep_munge_owner.send(:alias_method, :deep_munge, :real_deep_munge)
23
32
  end
24
33
  end
25
34
  end
@@ -1,3 +1,3 @@
1
1
  module ApiHammer
2
- VERSION = "0.11.1"
2
+ VERSION = "0.12.0"
3
3
  end
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.11.1
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: 2015-09-27 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack