rack-action 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 796671ba97fa3e73e6479c1d2a3d7f59414f9349
4
- data.tar.gz: 5c8327c910ea1697e279e22bb650001cf3b0339a
3
+ metadata.gz: 7d5631a05a4f3286db246abf47cb5edaa037820a
4
+ data.tar.gz: 4810c8e247f8c49ef4a452318b62acc1cb7c7dae
5
5
  SHA512:
6
- metadata.gz: 4362096b699d0fc25d1c9786c20cd3d009417df517862de21fea39497c7b5bf5e20d090244b7984e1b82ac916cd7930d9f6831552bb8aaffba21ee456c98be01
7
- data.tar.gz: ecb490f6b0733ed85e0941016c1cbf39b76bd7234ce7e82b6100887be0c99b4aed27388ac723c3cab04ac0e720aea4000c9d9c28a99be742c60a714fd39b88e9
6
+ metadata.gz: 26464e5ecfcdf5d7a2f800563faab7fc4e9def069f0c1946c6e2d3267715e35196c3750f58f961792162094fd5d9880efc48d99c7c07621f1460ea0d7aeababc
7
+ data.tar.gz: 480457ed2a7a088f8d1b012aa1ff9bbe8aeb1eb16ea925ddb48c6f58da8d532272556f3ab0c9cc3731a8bf95e17081f076f84e7981d6df0a48a4ff2ee9a471d6
@@ -5,7 +5,7 @@ require 'rack/filters'
5
5
 
6
6
  module Rack
7
7
  class Action
8
- VERSION = '0.4.1'
8
+ VERSION = '0.5.0'
9
9
 
10
10
  extend Filters
11
11
 
@@ -54,7 +54,7 @@ module Rack
54
54
  if request.content_type.to_s.include?(APPLICATION_JSON)
55
55
  body = env[RACK_INPUT].read
56
56
  env[RACK_INPUT].rewind
57
- p.merge!(JSON.parse(body))
57
+ p.merge!(self.class.json_serializer.load(body))
58
58
  end
59
59
  p.respond_to?(:with_indifferent_access) ? p.with_indifferent_access : p
60
60
  end
@@ -108,20 +108,7 @@ module Rack
108
108
  def json(data={}, options={})
109
109
  response[CONTENT_TYPE] = APPLICATION_JSON
110
110
  response.status = options[:status] if options.has_key?(:status)
111
- response.write JSON.generate(data)
112
- end
113
-
114
- # This is a convenience method that sets the Content-Type headers
115
- # and writes the pretty-formatted JSON String to the response.
116
- #
117
- # @param [Hash] data The data
118
- # @param [Hash] options The options
119
- # @option options [Fixnum] :status The response status code
120
- # @return [String] The JSON
121
- def pretty_json(data={}, options={})
122
- response[CONTENT_TYPE] = APPLICATION_JSON
123
- response.status = options[:status] if options.has_key?(:status)
124
- response.write JSON.pretty_generate(data)
111
+ response.write self.class.json_serializer.dump(data)
125
112
  end
126
113
 
127
114
  # This is a convenience method that forms an absolute URL based on the
@@ -234,6 +221,22 @@ module Rack
234
221
  @logger = logger
235
222
  end
236
223
 
224
+ def self.json_serializer
225
+ if defined? @json_serializer
226
+ @json_serializer
227
+ else
228
+ @json_serializer = if superclass.respond_to?(:json_serializer)
229
+ superclass.json_serializer
230
+ else
231
+ JSON
232
+ end
233
+ end
234
+ end
235
+
236
+ def self.json_serializer=(json_serializer)
237
+ @json_serializer = json_serializer
238
+ end
239
+
237
240
  # @private
238
241
  class URL
239
242
  HTTPS = 'https'.freeze
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "rack-action"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "0.4.1"
15
+ gem.version = "0.5.0"
16
16
 
17
17
  gem.add_runtime_dependency "rack"
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-action
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack