rocket_pants 1.6.0.rc1 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,10 +38,11 @@ module RocketPants
38
38
  autoload :FormatVerification, 'rocket_pants/controller/format_verification'
39
39
  autoload :UrlFor, 'rocket_pants/controller/url_for'
40
40
 
41
- mattr_accessor :caching_enabled, :header_metadata
41
+ mattr_accessor :caching_enabled, :header_metadata, :serializers_enabled
42
42
 
43
- self.caching_enabled = false
44
- self.header_metadata = false
43
+ self.caching_enabled = false
44
+ self.header_metadata = false
45
+ self.serializers_enabled = true
45
46
 
46
47
  mattr_writer :cache
47
48
 
@@ -54,8 +55,9 @@ module RocketPants
54
55
  end
55
56
 
56
57
  class << self
57
- alias caching_enabled? caching_enabled
58
- alias header_metadata? header_metadata
58
+ alias caching_enabled? caching_enabled
59
+ alias header_metadata? header_metadata
60
+ alias serializers_enabled? serializers_enabled
59
61
 
60
62
  def cache
61
63
  @@cache ||= (MONETA_LEGACY ? Moneta::Memory : Moneta::Adapters::Memory).new
@@ -70,6 +72,16 @@ module RocketPants
70
72
  @@env = value
71
73
  end
72
74
 
75
+ def show_exception_message?
76
+ @@show_exception_message = default_show_exception_message if !defined?(@@show_exception_message) || @@show_exception_message.nil?
77
+ @@show_exception_message
78
+ end
79
+ alias show_exception_message show_exception_message?
80
+
81
+ def show_exception_message=(value)
82
+ @@show_exception_message = value
83
+ end
84
+
73
85
  def default_env
74
86
  env = Rails.env.to_s if defined?(Rails.env)
75
87
  env ||= ENV['RAILS_ENV'].presence || ENV['RACK_ENV'].presence || "development"
@@ -80,6 +92,10 @@ module RocketPants
80
92
  env.development? || env.test?
81
93
  end
82
94
 
95
+ def default_show_exception_message
96
+ env.development? || env.test?
97
+ end
98
+
83
99
  def pass_through_errors
84
100
  if defined?(@@pass_through_errors) && [true, false].include?(@@pass_through_errors)
85
101
  @@pass_through_errors
@@ -53,11 +53,19 @@ module RocketPants
53
53
  def lookup_error_message(exception)
54
54
  # TODO: Add in notification hooks for non-standard exceptions.
55
55
  name = lookup_error_name(exception)
56
- message = (exception.message == exception.class.name) ? 'An unknown error has occurred.' : exception.message
56
+ message = default_message_for_exception exception
57
57
  context = lookup_error_context(exception).reverse_merge(:scope => :"rocket_pants.errors", :default => message)
58
58
  I18n.t name, context.except(:metadata)
59
59
  end
60
60
 
61
+ def default_message_for_exception(exception)
62
+ if !RocketPants.show_exception_message? || exception.message == exception.class.name
63
+ 'An unknown error has occurred.'
64
+ else
65
+ exception.message
66
+ end
67
+ end
68
+
61
69
  # Lookup error name will automatically handle translating errors to a
62
70
  # simpler, symbol representation. It's implemented like this to make it
63
71
  # possible to override to a simple format.
@@ -5,7 +5,7 @@ module RocketPants
5
5
  module Instrumentation
6
6
  extend ActiveSupport::Concern
7
7
  include AbstractController::Logger
8
-
8
+
9
9
  def process_action(action, *args)
10
10
  raw_payload = {
11
11
  :controller => self.class.name,
@@ -24,7 +24,7 @@ module RocketPants
24
24
  result
25
25
  end
26
26
  end
27
-
27
+
28
28
  end
29
29
  ActionController::LogSubscriber.attach_to :rocket_pants
30
30
  end
@@ -69,6 +69,7 @@ module RocketPants
69
69
  end
70
70
 
71
71
  def self.normalise_to_serializer(object, options)
72
+ return object unless RocketPants.serializers_enabled?
72
73
  serializer = options.delete(:serializer)
73
74
  serializer = object.active_model_serializer if object.respond_to?(:active_model_serializer) && serializer.nil?
74
75
  return object unless serializer
@@ -5,6 +5,7 @@ module RocketPants
5
5
  config.rocket_pants.use_caching = nil
6
6
  config.rocket_pants.header_metadata = nil
7
7
  config.rocket_pants.pass_through_errors = nil
8
+ config.rocket_pants.pass_through_errors = nil
8
9
 
9
10
  config.i18n.railties_load_path << File.expand_path('../locale/en.yml', __FILE__)
10
11
 
@@ -13,11 +14,13 @@ module RocketPants
13
14
  end
14
15
 
15
16
  initializer "rocket_pants.configuration" do |app|
16
- rp_config = app.config.rocket_pants
17
- rp_config.use_caching = Rails.env.production? if rp_config.use_caching.nil?
18
- RocketPants.caching_enabled = rp_config.use_caching
19
- RocketPants.header_metadata = rp_config.header_metadata unless rp_config.header_metadata.nil?
20
- RocketPants.pass_through_errors = rp_config.pass_through_errors unless rp_config.pass_through_errors.nil?
17
+ rp_config = app.config.rocket_pants
18
+ rp_config.use_caching = Rails.env.production? if rp_config.use_caching.nil?
19
+ RocketPants.caching_enabled = rp_config.use_caching
20
+ RocketPants.header_metadata = rp_config.header_metadata unless rp_config.header_metadata.nil?
21
+ RocketPants.serializers_enabled = rp_config.serializers_enabled unless rp_config.serializers_enabled.nil?
22
+ RocketPants.show_exception_message = rp_config.show_exception_message unless rp_config.show_exception_message.nil?
23
+ RocketPants.pass_through_errors = rp_config.pass_through_errors unless rp_config.pass_through_errors.nil?
21
24
  # Set the rocket pants cache if present.
22
25
  RocketPants.cache = rp_config.cache if rp_config.cache
23
26
  end
metadata CHANGED
@@ -1,248 +1,209 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rocket_pants
3
- version: !ruby/object:Gem::Version
4
- version: 1.6.0.rc1
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 6
8
+ - 1
9
+ version: 1.6.1
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Darcy Laycock
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2013-01-24 00:00:00 +08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: actionpack
16
22
  prerelease: false
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
19
25
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '3.0'
22
- none: false
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 3
29
+ - 0
30
+ version: "3.0"
23
31
  type: :runtime
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- version: '3.0'
29
- none: false
30
- - !ruby/object:Gem::Dependency
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
31
34
  name: railties
32
35
  prerelease: false
33
- requirement: !ruby/object:Gem::Requirement
34
- requirements:
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
35
38
  - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '3.0'
38
- none: false
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 3
42
+ - 0
43
+ version: "3.0"
39
44
  type: :runtime
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- version: '3.0'
45
- none: false
46
- - !ruby/object:Gem::Dependency
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
47
  name: will_paginate
48
48
  prerelease: false
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
51
  - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '3.0'
54
- none: false
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 3
55
+ - 0
56
+ version: "3.0"
55
57
  type: :runtime
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- version: '3.0'
61
- none: false
62
- - !ruby/object:Gem::Dependency
58
+ version_requirements: *id003
59
+ - !ruby/object:Gem::Dependency
63
60
  name: hashie
64
61
  prerelease: false
65
- requirement: !ruby/object:Gem::Requirement
66
- requirements:
62
+ requirement: &id004 !ruby/object:Gem::Requirement
63
+ requirements:
67
64
  - - ~>
68
- - !ruby/object:Gem::Version
69
- version: '1.0'
70
- none: false
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 1
68
+ - 0
69
+ version: "1.0"
71
70
  type: :runtime
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- version: '1.0'
77
- none: false
78
- - !ruby/object:Gem::Dependency
71
+ version_requirements: *id004
72
+ - !ruby/object:Gem::Dependency
79
73
  name: api_smith
80
74
  prerelease: false
81
- requirement: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- none: false
75
+ requirement: &id005 !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ segments:
80
+ - 0
81
+ version: "0"
87
82
  type: :runtime
88
- version_requirements: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ! '>='
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- none: false
94
- - !ruby/object:Gem::Dependency
83
+ version_requirements: *id005
84
+ - !ruby/object:Gem::Dependency
95
85
  name: moneta
96
86
  prerelease: false
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- none: false
87
+ requirement: &id006 !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ segments:
92
+ - 0
93
+ version: "0"
103
94
  type: :runtime
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - ! '>='
107
- - !ruby/object:Gem::Version
108
- version: '0'
109
- none: false
110
- - !ruby/object:Gem::Dependency
95
+ version_requirements: *id006
96
+ - !ruby/object:Gem::Dependency
111
97
  name: rspec
112
98
  prerelease: false
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
99
+ requirement: &id007 !ruby/object:Gem::Requirement
100
+ requirements:
115
101
  - - ~>
116
- - !ruby/object:Gem::Version
117
- version: '2.4'
118
- none: false
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 2
105
+ - 4
106
+ version: "2.4"
119
107
  type: :development
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ~>
123
- - !ruby/object:Gem::Version
124
- version: '2.4'
125
- none: false
126
- - !ruby/object:Gem::Dependency
108
+ version_requirements: *id007
109
+ - !ruby/object:Gem::Dependency
127
110
  name: rspec-rails
128
111
  prerelease: false
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
112
+ requirement: &id008 !ruby/object:Gem::Requirement
113
+ requirements:
131
114
  - - ~>
132
- - !ruby/object:Gem::Version
133
- version: '2.4'
134
- none: false
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 2
118
+ - 4
119
+ version: "2.4"
135
120
  type: :development
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - ~>
139
- - !ruby/object:Gem::Version
140
- version: '2.4'
141
- none: false
142
- - !ruby/object:Gem::Dependency
121
+ version_requirements: *id008
122
+ - !ruby/object:Gem::Dependency
143
123
  name: rr
144
124
  prerelease: false
145
- requirement: !ruby/object:Gem::Requirement
146
- requirements:
125
+ requirement: &id009 !ruby/object:Gem::Requirement
126
+ requirements:
147
127
  - - ~>
148
- - !ruby/object:Gem::Version
149
- version: '1.0'
150
- none: false
128
+ - !ruby/object:Gem::Version
129
+ segments:
130
+ - 1
131
+ - 0
132
+ version: "1.0"
151
133
  type: :development
152
- version_requirements: !ruby/object:Gem::Requirement
153
- requirements:
154
- - - ~>
155
- - !ruby/object:Gem::Version
156
- version: '1.0'
157
- none: false
158
- - !ruby/object:Gem::Dependency
134
+ version_requirements: *id009
135
+ - !ruby/object:Gem::Dependency
159
136
  name: webmock
160
137
  prerelease: false
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- none: false
138
+ requirement: &id010 !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ segments:
143
+ - 0
144
+ version: "0"
167
145
  type: :development
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - ! '>='
171
- - !ruby/object:Gem::Version
172
- version: '0'
173
- none: false
174
- - !ruby/object:Gem::Dependency
146
+ version_requirements: *id010
147
+ - !ruby/object:Gem::Dependency
175
148
  name: activerecord
176
149
  prerelease: false
177
- requirement: !ruby/object:Gem::Requirement
178
- requirements:
150
+ requirement: &id011 !ruby/object:Gem::Requirement
151
+ requirements:
179
152
  - - ~>
180
- - !ruby/object:Gem::Version
181
- version: '3.0'
182
- none: false
153
+ - !ruby/object:Gem::Version
154
+ segments:
155
+ - 3
156
+ - 0
157
+ version: "3.0"
183
158
  type: :development
184
- version_requirements: !ruby/object:Gem::Requirement
185
- requirements:
186
- - - ~>
187
- - !ruby/object:Gem::Version
188
- version: '3.0'
189
- none: false
190
- - !ruby/object:Gem::Dependency
159
+ version_requirements: *id011
160
+ - !ruby/object:Gem::Dependency
191
161
  name: sqlite3
192
162
  prerelease: false
193
- requirement: !ruby/object:Gem::Requirement
194
- requirements:
195
- - - ! '>='
196
- - !ruby/object:Gem::Version
197
- version: '0'
198
- none: false
163
+ requirement: &id012 !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ segments:
168
+ - 0
169
+ version: "0"
199
170
  type: :development
200
- version_requirements: !ruby/object:Gem::Requirement
201
- requirements:
202
- - - ! '>='
203
- - !ruby/object:Gem::Version
204
- version: '0'
205
- none: false
206
- - !ruby/object:Gem::Dependency
171
+ version_requirements: *id012
172
+ - !ruby/object:Gem::Dependency
207
173
  name: reversible_data
208
174
  prerelease: false
209
- requirement: !ruby/object:Gem::Requirement
210
- requirements:
175
+ requirement: &id013 !ruby/object:Gem::Requirement
176
+ requirements:
211
177
  - - ~>
212
- - !ruby/object:Gem::Version
213
- version: '1.0'
214
- none: false
178
+ - !ruby/object:Gem::Version
179
+ segments:
180
+ - 1
181
+ - 0
182
+ version: "1.0"
215
183
  type: :development
216
- version_requirements: !ruby/object:Gem::Requirement
217
- requirements:
218
- - - ~>
219
- - !ruby/object:Gem::Version
220
- version: '1.0'
221
- none: false
222
- - !ruby/object:Gem::Dependency
184
+ version_requirements: *id013
185
+ - !ruby/object:Gem::Dependency
223
186
  name: kaminari
224
187
  prerelease: false
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ! '>='
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- none: false
188
+ requirement: &id014 !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ segments:
193
+ - 0
194
+ version: "0"
231
195
  type: :development
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ! '>='
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
- none: false
238
- description: Rocket Pants adds JSON API love to Rails and ActionController, making
239
- it simpler to build API-oriented controllers.
240
- email:
196
+ version_requirements: *id014
197
+ description: Rocket Pants adds JSON API love to Rails and ActionController, making it simpler to build API-oriented controllers.
198
+ email:
241
199
  - sutto@sutto.net
242
200
  executables: []
201
+
243
202
  extensions: []
203
+
244
204
  extra_rdoc_files: []
245
- files:
205
+
206
+ files:
246
207
  - lib/rocket_pants/active_record.rb
247
208
  - lib/rocket_pants/base.rb
248
209
  - lib/rocket_pants/cache_middleware.rb
@@ -268,28 +229,37 @@ files:
268
229
  - lib/rocket_pants/tasks/rocket_pants.rake
269
230
  - lib/rocket_pants/test_helper.rb
270
231
  - lib/rocket_pants.rb
232
+ has_rdoc: true
271
233
  homepage: http://github.com/filtersquad
272
234
  licenses: []
235
+
273
236
  post_install_message:
274
237
  rdoc_options: []
275
- require_paths:
238
+
239
+ require_paths:
276
240
  - lib
277
- required_ruby_version: !ruby/object:Gem::Requirement
278
- requirements:
279
- - - ! '>='
280
- - !ruby/object:Gem::Version
281
- version: '0'
282
- none: false
283
- required_rubygems_version: !ruby/object:Gem::Requirement
284
- requirements:
285
- - - ! '>='
286
- - !ruby/object:Gem::Version
241
+ required_ruby_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - ">="
244
+ - !ruby/object:Gem::Version
245
+ segments:
246
+ - 0
247
+ version: "0"
248
+ required_rubygems_version: !ruby/object:Gem::Requirement
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ segments:
253
+ - 1
254
+ - 3
255
+ - 6
287
256
  version: 1.3.6
288
- none: false
289
257
  requirements: []
258
+
290
259
  rubyforge_project:
291
- rubygems_version: 1.8.24
260
+ rubygems_version: 1.3.6
292
261
  signing_key:
293
262
  specification_version: 3
294
263
  summary: JSON API love for Rails and ActionController
295
264
  test_files: []
265
+