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 +4 -4
- data/lib/rack/action.rb +19 -16
- data/rack-action.gemspec +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: 7d5631a05a4f3286db246abf47cb5edaa037820a
|
4
|
+
data.tar.gz: 4810c8e247f8c49ef4a452318b62acc1cb7c7dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26464e5ecfcdf5d7a2f800563faab7fc4e9def069f0c1946c6e2d3267715e35196c3750f58f961792162094fd5d9880efc48d99c7c07621f1460ea0d7aeababc
|
7
|
+
data.tar.gz: 480457ed2a7a088f8d1b012aa1ff9bbe8aeb1eb16ea925ddb48c6f58da8d532272556f3ab0c9cc3731a8bf95e17081f076f84e7981d6df0a48a4ff2ee9a471d6
|
data/lib/rack/action.rb
CHANGED
@@ -5,7 +5,7 @@ require 'rack/filters'
|
|
5
5
|
|
6
6
|
module Rack
|
7
7
|
class Action
|
8
|
-
VERSION = '0.
|
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!(
|
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
|
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
|
data/rack-action.gemspec
CHANGED
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
|
+
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-
|
11
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|