rocket_pants 1.7.0 → 1.8.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/lib/rocket_pants/base.rb +13 -3
- data/lib/rocket_pants/controller/instrumentation.rb +7 -0
- data/lib/rocket_pants/controller/rescuable.rb +6 -1
- data/lib/rocket_pants/controller/strong_parameters.rb +13 -0
- data/lib/rocket_pants/test_helper.rb +13 -3
- data/lib/rocket_pants.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faa4d8c1b00d94400456cf629e82be17e220d9b0
|
4
|
+
data.tar.gz: 1483ff1f8246de1ff36d5eb9166e0bf7f9e3829f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e13d4dc41f47653b6fe95b5f6d79d194ea89c11776752e52ac70062f27cba8ad792576347361abdfb62b672f9740dcd46ac293ee7d7bface7c4b6ed65e3ff79d
|
7
|
+
data.tar.gz: bb9dd86ae4a6dae9baad05fcfa195a851832197f5628c34260e4c23ef48d3115146ec38cad233682a7ea475cd0091a4856281b7ff5527d0b73fe22f85d32a9a1
|
data/lib/rocket_pants/base.rb
CHANGED
@@ -21,14 +21,15 @@ module RocketPants
|
|
21
21
|
HeaderMetadata,
|
22
22
|
Linking,
|
23
23
|
Versioning,
|
24
|
-
Instrumentation,
|
25
24
|
Caching,
|
26
25
|
# Include earliest as possible in the request.
|
27
26
|
AbstractController::Callbacks,
|
28
27
|
ActionController::Rescue,
|
29
28
|
ErrorHandling,
|
30
29
|
Rescuable,
|
31
|
-
JSONP
|
30
|
+
JSONP,
|
31
|
+
StrongParameters,
|
32
|
+
Instrumentation
|
32
33
|
# FormatVerification # TODO: Implement Format Verification
|
33
34
|
].compact
|
34
35
|
|
@@ -40,6 +41,15 @@ module RocketPants
|
|
40
41
|
rescue LoadError => e
|
41
42
|
end
|
42
43
|
|
44
|
+
# If possible, include Honeybadger methods in the Rails controller
|
45
|
+
begin
|
46
|
+
require 'honeybadger'
|
47
|
+
require 'honeybadger/rails/controller_methods'
|
48
|
+
MODULES << Honeybadger::Rails::ControllerMethods
|
49
|
+
rescue LoadError => e
|
50
|
+
end
|
51
|
+
|
52
|
+
|
43
53
|
MODULES.each do |mixin|
|
44
54
|
include mixin
|
45
55
|
end
|
@@ -56,4 +66,4 @@ module RocketPants
|
|
56
66
|
def self.helper_method(*); end
|
57
67
|
|
58
68
|
end
|
59
|
-
end
|
69
|
+
end
|
@@ -21,10 +21,17 @@ module RocketPants
|
|
21
21
|
ActiveSupport::Notifications.instrument("process_action.rocket_pants", raw_payload) do |payload|
|
22
22
|
result = super
|
23
23
|
payload[:status] = response.status
|
24
|
+
append_info_to_payload payload
|
24
25
|
result
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
29
|
+
private
|
30
|
+
|
31
|
+
def append_info_to_payload(payload) #:nodoc:
|
32
|
+
# Append any custom information here.
|
33
|
+
end
|
34
|
+
|
28
35
|
end
|
29
36
|
ActionController::LogSubscriber.attach_to :rocket_pants
|
30
37
|
end
|
@@ -16,6 +16,11 @@ module RocketPants
|
|
16
16
|
unless c.send(:airbrake_local_request?)
|
17
17
|
c.error_identifier = Airbrake.notify(e, c.send(:airbrake_request_data))
|
18
18
|
end
|
19
|
+
},
|
20
|
+
:honeybadger => lambda { |controller, exception, request|
|
21
|
+
if controller.respond_to?(:notify_honeybadger, true)
|
22
|
+
controller.send(:notify_honeybadger, exception)
|
23
|
+
end
|
19
24
|
}
|
20
25
|
}
|
21
26
|
|
@@ -64,4 +69,4 @@ module RocketPants
|
|
64
69
|
end
|
65
70
|
|
66
71
|
end
|
67
|
-
end
|
72
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RocketPants
|
2
|
+
module StrongParameters
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
if defined? ActionController::StrongParameters
|
7
|
+
include ActionController::StrongParameters
|
8
|
+
map_error! ActionController::ParameterMissing, RocketPants::BadRequest
|
9
|
+
map_error! ActionController::UnpermittedParameters, RocketPants::BadRequest
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -5,6 +5,8 @@ module RocketPants
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
+
require 'action_controller/test_case'
|
9
|
+
|
8
10
|
# Extend the response on first include.
|
9
11
|
class_attribute :_default_version
|
10
12
|
unless ActionController::TestResponse < ResponseHelper
|
@@ -13,7 +15,7 @@ module RocketPants
|
|
13
15
|
end
|
14
16
|
|
15
17
|
module ResponseHelper
|
16
|
-
|
18
|
+
|
17
19
|
def recycle_cached_body!
|
18
20
|
@_parsed_body = @_decoded_body = nil
|
19
21
|
end
|
@@ -73,13 +75,21 @@ module RocketPants
|
|
73
75
|
protected
|
74
76
|
|
75
77
|
# Like process, but automatically adds the api version.
|
76
|
-
def process(action,
|
78
|
+
def process(action, http_method = 'GET', *args)
|
79
|
+
# Rails 4 changes the method signature. In rails 3, http_method is actually
|
80
|
+
# the parameters.
|
81
|
+
if http_method.kind_of?(String)
|
82
|
+
parameters = args.shift
|
83
|
+
else
|
84
|
+
parameters = http_method
|
85
|
+
end
|
86
|
+
|
77
87
|
response.recycle_cached_body!
|
78
88
|
parameters ||= {}
|
79
89
|
if _default_version.present? && parameters[:version].blank? && parameters['version'].blank?
|
80
90
|
parameters[:version] = _default_version
|
81
91
|
end
|
82
|
-
super
|
92
|
+
super action, parameters, *args
|
83
93
|
end
|
84
94
|
|
85
95
|
def normalise_value(value)
|
data/lib/rocket_pants.rb
CHANGED
@@ -37,6 +37,7 @@ module RocketPants
|
|
37
37
|
autoload :Versioning, 'rocket_pants/controller/versioning'
|
38
38
|
autoload :FormatVerification, 'rocket_pants/controller/format_verification'
|
39
39
|
autoload :UrlFor, 'rocket_pants/controller/url_for'
|
40
|
+
autoload :StrongParameters, 'rocket_pants/controller/strong_parameters'
|
40
41
|
|
41
42
|
mattr_accessor :caching_enabled, :header_metadata, :serializers_enabled
|
42
43
|
|
@@ -111,4 +112,4 @@ module RocketPants
|
|
111
112
|
|
112
113
|
end
|
113
114
|
|
114
|
-
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rocket_pants
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darcy Laycock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- lib/rocket_pants/controller/linking.rb
|
247
247
|
- lib/rocket_pants/controller/rescuable.rb
|
248
248
|
- lib/rocket_pants/controller/respondable.rb
|
249
|
+
- lib/rocket_pants/controller/strong_parameters.rb
|
249
250
|
- lib/rocket_pants/controller/url_for.rb
|
250
251
|
- lib/rocket_pants/controller/versioning.rb
|
251
252
|
- lib/rocket_pants/error.rb
|
@@ -276,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
276
277
|
version: 1.3.6
|
277
278
|
requirements: []
|
278
279
|
rubyforge_project:
|
279
|
-
rubygems_version: 2.0.
|
280
|
+
rubygems_version: 2.0.2
|
280
281
|
signing_key:
|
281
282
|
specification_version: 4
|
282
283
|
summary: JSON API love for Rails and ActionController
|