harukizaemon-acts_as_teapot 1.0.1 → 1.0.2
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.
- data/CHANGELOG.rdoc +7 -1
- data/MIT-LICENSE +1 -1
- data/README.rdoc +5 -4
- data/acts_as_teapot.gemspec +6 -6
- data/lib/acts_as_teapot.rb +5 -4
- data/lib/haruki_zaemon/acts_as_teapot/action_controller/abstract_request.rb +12 -0
- data/lib/haruki_zaemon/acts_as_teapot/action_controller/dispatcher.rb +40 -0
- data/lib/haruki_zaemon/acts_as_teapot/action_controller/routing.rb +11 -0
- data/lib/haruki_zaemon/acts_as_teapot/action_controller/status_codes.rb +12 -0
- metadata +6 -6
- data/lib/acts_as_teapot/action_controller/abstract_request.rb +0 -10
- data/lib/acts_as_teapot/action_controller/routing.rb +0 -9
- data/lib/acts_as_teapot/action_controller/status_codes.rb +0 -10
- data/lib/acts_as_teapot/application_controller.rb +0 -12
data/CHANGELOG.rdoc
CHANGED
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
= Acts As Teapot
|
2
2
|
|
3
|
-
Acts As Teapot is a Ruby on Rails plugin that ensures your Ruby on Rails applications conform to
|
4
|
-
here is that your application is not a coffee
|
5
|
-
(HTCPCP/1.0). Thus, if ever a BREW request or any
|
6
|
-
"application/coffee-pot-command" is received, the server will respond with
|
3
|
+
Acts As Teapot is a Ruby on Rails plugin that ensures your Ruby on Rails applications conform to
|
4
|
+
http://www.ietf.org/rfc/rfc2324.txt. Our assumption here is that your application is not a coffee
|
5
|
+
pot and does not understand the Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0). Thus, if ever a BREW request or any
|
6
|
+
other request with the Content-Type set to "application/coffee-pot-command" is received, the server will respond with
|
7
|
+
418 I’m a teapot.
|
7
8
|
|
8
9
|
== Installation
|
9
10
|
|
data/acts_as_teapot.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "acts_as_teapot"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.2"
|
4
4
|
s.date = "2009-01-11"
|
5
5
|
s.summary = "Ensure your Ruby on Rails applications conform to RFC2324."
|
6
|
-
s.email = "
|
6
|
+
s.email = "haruki.zaemon@gmail.com"
|
7
7
|
s.homepage = "http://github.com/harukizaemon/acts_as_teapot"
|
8
8
|
s.description = "Ensure your Ruby on Rails applications conform to RFC2324."
|
9
9
|
s.has_rdoc = true
|
@@ -13,10 +13,10 @@ Gem::Specification.new do |s|
|
|
13
13
|
"README.rdoc",
|
14
14
|
"acts_as_teapot.gemspec",
|
15
15
|
"lib/acts_as_teapot.rb",
|
16
|
-
"lib/acts_as_teapot/
|
17
|
-
"lib/acts_as_teapot/action_controller/
|
18
|
-
"lib/acts_as_teapot/action_controller/routing.rb",
|
19
|
-
"lib/acts_as_teapot/action_controller/status_codes.rb"]
|
16
|
+
"lib/haruki_zaemon/acts_as_teapot/action_controller/abstract_request.rb",
|
17
|
+
"lib/haruki_zaemon/acts_as_teapot/action_controller/dispatcher.rb",
|
18
|
+
"lib/haruki_zaemon/acts_as_teapot/action_controller/routing.rb",
|
19
|
+
"lib/haruki_zaemon/acts_as_teapot/action_controller/status_codes.rb"]
|
20
20
|
s.rdoc_options = ["--main", "README.rdoc"]
|
21
21
|
s.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
|
22
22
|
end
|
data/lib/acts_as_teapot.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
ActionController::
|
3
|
-
ActionController::
|
4
|
-
ActionController::
|
1
|
+
require 'action_controller/dispatcher' unless defined?(ActionController::Dispatcher)
|
2
|
+
ActionController::Dispatcher.send(:include, HarukiZaemon::ActsAsTeapot::ActionController::Dispatcher)
|
3
|
+
ActionController::AbstractRequest.send(:include, HarukiZaemon::ActsAsTeapot::ActionController::AbstractRequest)
|
4
|
+
ActionController::Routing.send(:include, HarukiZaemon::ActsAsTeapot::ActionController::Routing)
|
5
|
+
ActionController::StatusCodes.send(:include, HarukiZaemon::ActsAsTeapot::ActionController::StatusCodes)
|
5
6
|
Mime::Type.register("application/coffee-pot-command", :htcpcp)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module HarukiZaemon
|
2
|
+
module ActsAsTeapot
|
3
|
+
module ActionController
|
4
|
+
module Dispatcher
|
5
|
+
include ::ActionController::StatusCodes
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.alias_method_chain :handle_request, :acts_as_teapot
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def handle_request_with_acts_as_teapot
|
14
|
+
if brew_request? || htcpcp_request?
|
15
|
+
process
|
16
|
+
else
|
17
|
+
handle_request_without_acts_as_teapot
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def process
|
24
|
+
@response.headers['Status'] = interpret_status(:im_a_teapot)
|
25
|
+
@response.body = "Short and Stout"
|
26
|
+
@response.prepare!
|
27
|
+
@response.out(@output)
|
28
|
+
end
|
29
|
+
|
30
|
+
def brew_request?
|
31
|
+
@request.method == :brew
|
32
|
+
end
|
33
|
+
|
34
|
+
def htcpcp_request?
|
35
|
+
@request.content_type && @request.content_type == Mime::HTCPCP
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: harukizaemon-acts_as_teapot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Harris
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Ensure your Ruby on Rails applications conform to RFC2324.
|
17
|
-
email:
|
17
|
+
email: haruki.zaemon@gmail.com
|
18
18
|
executables: []
|
19
19
|
|
20
20
|
extensions: []
|
@@ -28,10 +28,10 @@ files:
|
|
28
28
|
- README.rdoc
|
29
29
|
- acts_as_teapot.gemspec
|
30
30
|
- lib/acts_as_teapot.rb
|
31
|
-
- lib/acts_as_teapot/
|
32
|
-
- lib/acts_as_teapot/action_controller/
|
33
|
-
- lib/acts_as_teapot/action_controller/routing.rb
|
34
|
-
- lib/acts_as_teapot/action_controller/status_codes.rb
|
31
|
+
- lib/haruki_zaemon/acts_as_teapot/action_controller/abstract_request.rb
|
32
|
+
- lib/haruki_zaemon/acts_as_teapot/action_controller/dispatcher.rb
|
33
|
+
- lib/haruki_zaemon/acts_as_teapot/action_controller/routing.rb
|
34
|
+
- lib/haruki_zaemon/acts_as_teapot/action_controller/status_codes.rb
|
35
35
|
has_rdoc: true
|
36
36
|
homepage: http://github.com/harukizaemon/acts_as_teapot
|
37
37
|
post_install_message:
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module ActsAsTeapot
|
2
|
-
module ApplicationController
|
3
|
-
def self.included(base)
|
4
|
-
base.prepend_before_filter :rfc2324_check
|
5
|
-
end
|
6
|
-
|
7
|
-
private
|
8
|
-
def rfc2324_check
|
9
|
-
head(:im_a_teapot) if request.method == :brew || (request.content_type && request.content_type == Mime::HTCPCP)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|