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.
@@ -1,4 +1,10 @@
1
- == 1.0.1 released 2009-01-07
1
+ == 1.0.2 released 2009-01-11
2
+
3
+ * Respond to ALL BREW and HTCPCP requests irrespective of routing.
4
+
5
+ * Ensure old-style plugin works.
6
+
7
+ == 1.0.1 released 2009-01-10
2
8
 
3
9
  * Changed copyright and fixed documentation.
4
10
 
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Acts As Teapot
1
+ Copyright (c) 2009 Simon Harris
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -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 RFC2324. Our assumption
4
- here is that your application is not a coffee pot and does not understand the Hyper Text Coffee Pot Control Protocol
5
- (HTCPCP/1.0). Thus, if ever a BREW request or any other request with the Content-Type set to
6
- "application/coffee-pot-command" is received, the server will respond with 418 I’m a teapot.
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
 
@@ -1,9 +1,9 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "acts_as_teapot"
3
- s.version = "1.0.1"
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 = "simon.harris@cogentconsulting.com.au"
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/application_controller.rb",
17
- "lib/acts_as_teapot/action_controller/abstract_request.rb",
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
@@ -1,5 +1,6 @@
1
- ApplicationController.send(:include, ApplicationController::Base)
2
- ActionController::AbstractRequest.send(:include, ActsAsTeapot::ActionController::AbstractRequest)
3
- ActionController::Routing.send(:include, ActsAsTeapot::ActionController::Routing)
4
- ActionController::StatusCodes.send(:include, ActsAsTeapot::ActionController::StatusCodes)
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,12 @@
1
+ module HarukiZaemon
2
+ module ActsAsTeapot
3
+ module ActionController
4
+ module AbstractRequest
5
+ def self.included(base)
6
+ base::HTTP_METHODS << "brew"
7
+ base::HTTP_METHOD_LOOKUP["BREW"] = :brew
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -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
@@ -0,0 +1,11 @@
1
+ module HarukiZaemon
2
+ module ActsAsTeapot
3
+ module ActionController
4
+ module Routing
5
+ def self.included(base)
6
+ base::HTTP_METHODS << :brew
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ module HarukiZaemon
2
+ module ActsAsTeapot
3
+ module ActionController
4
+ module StatusCodes
5
+ def self.included(base)
6
+ base::STATUS_CODES[418] = "I'm a teapot"
7
+ base::SYMBOL_TO_STATUS_CODE[:im_a_teapot] = 418
8
+ end
9
+ end
10
+ end
11
+ end
12
+ 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.1
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: simon.harris@cogentconsulting.com.au
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/application_controller.rb
32
- - lib/acts_as_teapot/action_controller/abstract_request.rb
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,10 +0,0 @@
1
- module ActsAsTeapot
2
- module ActionController
3
- module AbstractRequest
4
- def self.included(base)
5
- base::HTTP_METHODS << "brew"
6
- base::HTTP_METHOD_LOOKUP["BREW"] = :brew
7
- end
8
- end
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- module ActsAsTeapot
2
- module ActionController
3
- module Routing
4
- def self.included(base)
5
- base::HTTP_METHODS << :brew
6
- end
7
- end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- module ActsAsTeapot
2
- module ActionController
3
- module StatusCodes
4
- def self.included(base)
5
- base.STATUS_CODES[418] = "I'm a teapot"
6
- base.SYMBOL_TO_STATUS_CODE[:im_a_teapot] = 418
7
- end
8
- end
9
- end
10
- end
@@ -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