after_response 0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
File without changes
data/README ADDED
@@ -0,0 +1,6 @@
1
+ AfterResponse
2
+ =============
3
+
4
+ Adds an after_response callback method to perform actions after the HTTP response has been sent to
5
+ the client.
6
+
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "after_response"
3
+ s.version = "0.8"
4
+ s.platform = Gem::Platform::RUBY
5
+ s.summary = "Provides hooks to execute callbacks after the response has been delivered to the client."
6
+
7
+ s.description = <<-EOF
8
+ AfterResponse provides callbacks into the Passenger2 and Passenger3 (and soon, Unicorn)
9
+ request cycle. The main goal is to delay as much non-critical processing until later, delivering
10
+ the response to the client application sooner. This would mainly include logging data into a Mixpanel-like
11
+ service, sending email and other tasks that do not affect the response body in any way.
12
+ EOF
13
+
14
+ s.files = Dir['{lib/*,rails/*}'] +
15
+ %w(after_response.gemspec CHANGELOG README)
16
+ s.require_path = 'lib'
17
+ s.extra_rdoc_files = ['README', 'CHANGELOG']
18
+
19
+ s.author = 'Kevin E. Hunt'
20
+ s.email = 'kevin@kev.in'
21
+ s.homepage = 'https://github.com/kevn/after_response'
22
+
23
+ end
@@ -0,0 +1,36 @@
1
+
2
+ module AfterResponse
3
+
4
+ CONTAINER_ADAPTERS = [
5
+ OpenStruct.new(
6
+ :name => :passenger3,
7
+ :test => lambda{ defined?(PhusionPassenger) && PhusionPassenger::AbstractRequestHandler.private_instance_methods.include?("accept_and_process_next_request") },
8
+ :lib => 'after_response/adapters/passenger3'
9
+ ),
10
+ OpenStruct.new(
11
+ :name => :passenger2,
12
+ :test => lambda{ defined?(PhusionPassenger) && PhusionPassenger::VERSION_STRING == '2.2.14' },
13
+ :lib => 'after_response/adapters/passenger2'
14
+ )
15
+ ]
16
+
17
+ def self.attach_to_current_container!
18
+ return if @after_response_attached
19
+ if current_container
20
+ require(current_container.lib)
21
+ @after_response_attached = true
22
+ Rails.logger.info{ "[AfterResponse] => Callback hook installed for #{current_container.name}" }
23
+ else
24
+ Rails.logger.info{ "[AfterResponse] => No supported container found. AfterResponse will not buffer." }
25
+ end
26
+ end
27
+
28
+ def self.current_container
29
+ @current_container ||= CONTAINER_ADAPTERS.detect{|c| c.test.call }
30
+ end
31
+
32
+ def self.bufferable?
33
+ @current_container
34
+ end
35
+
36
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'after_response'
2
+
3
+ AfterResponse.attach_to_current_container!
4
+
5
+ ActionController::Base.send(:include, AfterResponse::Callbacks::Helpers)
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: after_response
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 8
9
+ version: "0.8"
10
+ platform: ruby
11
+ authors:
12
+ - Kevin E. Hunt
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-13 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: |
22
+ AfterResponse provides callbacks into the Passenger2 and Passenger3 (and soon, Unicorn)
23
+ request cycle. The main goal is to delay as much non-critical processing until later, delivering
24
+ the response to the client application sooner. This would mainly include logging data into a Mixpanel-like
25
+ service, sending email and other tasks that do not affect the response body in any way.
26
+
27
+ email: kevin@kev.in
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README
34
+ - CHANGELOG
35
+ files:
36
+ - lib/after_response.rb
37
+ - rails/init.rb
38
+ - after_response.gemspec
39
+ - CHANGELOG
40
+ - README
41
+ has_rdoc: true
42
+ homepage: https://github.com/kevn/after_response
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Provides hooks to execute callbacks after the response has been delivered to the client.
75
+ test_files: []
76
+