rack-action 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rack/action.rb CHANGED
@@ -109,6 +109,8 @@ module Rack
109
109
  # @private
110
110
  CONTENT_TYPE = 'Content-Type'.freeze
111
111
  # @private
112
+ HTTP_ACCEPT = 'HTTP_ACCEPT'.freeze
113
+ # @private
112
114
  TEXT_HTML = 'text/html'.freeze
113
115
  # @private
114
116
  APPLICATION_JSON = 'application/json'.freeze
@@ -146,6 +148,16 @@ module Rack
146
148
  end
147
149
  end
148
150
 
151
+ def format
152
+ if params[:format]
153
+ params[:format]
154
+ elsif env[HTTP_ACCEPT] == APPLICATION_JSON
155
+ "json"
156
+ else
157
+ "html"
158
+ end
159
+ end
160
+
149
161
  # This is the main method responsible for generating a Rack response.
150
162
  # You typically won't need to override this method or call it directly.
151
163
  # First this will run the before filters for this action.
@@ -247,7 +259,7 @@ module Rack
247
259
  def log_call
248
260
  if logger
249
261
  logger.debug do
250
- "#{self.class} #{request.env["REQUEST_METHOD"]} params: #{params.inspect}"
262
+ "#{self.class} #{request.env["REQUEST_METHOD"]} format: #{format.inspect}, params: #{params.inspect}"
251
263
  end
252
264
  end
253
265
  end
data/lib/rack/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Action
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/rack-action.gemspec CHANGED
@@ -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.1.0"
15
+ gem.version = "0.2.0"
16
16
 
17
17
  gem.add_runtime_dependency "rack"
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-action
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-21 00:00:00.000000000 Z
12
+ date: 2013-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -70,11 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 1.8.24
73
+ rubygems_version: 1.8.25
74
74
  signing_key:
75
75
  specification_version: 3
76
76
  summary: a small, simple framework for generating Rack responses
77
77
  test_files:
78
78
  - test/rack/action_test.rb
79
79
  - test/rack_test.rb
80
- has_rdoc: