joshbuddy-esi-for-rack 0.0.1 → 0.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.
Files changed (5) hide show
  1. data/README.rdoc +34 -0
  2. data/Rakefile +2 -0
  3. data/VERSION +1 -1
  4. data/lib/esi_for_rack/lookup.rb +50 -0
  5. metadata +26 -4
data/README.rdoc ADDED
@@ -0,0 +1,34 @@
1
+ = EsiForRack
2
+
3
+ == What is ESI?
4
+
5
+ ESI is a standard way to assemble pages. This spec is supported by several reverse proxies.
6
+
7
+ http://slideshare.net/joshbuddy/to-the-edge-of-web-performance-and-beyond
8
+
9
+ == Usage
10
+
11
+ In your builder, just use it.
12
+
13
+ use EsiForRack
14
+
15
+ In your HTTP responses, just normal ESI tags. If you're working within Rails, give Spackle a try.
16
+
17
+ http://github.com/joshbuddy/spackle
18
+
19
+ Here is an example of a response that would be parsed by EsiForRack
20
+
21
+ <html>
22
+ <body>
23
+ <esi:include src="/helloworld"/>
24
+ </body>
25
+ </html>
26
+
27
+ In this case, a request to <tt>/helloworld</tt> would be made by EsiForRack to fill in the request. If your application sent: "Hey world" as a response to <tt>/helloworld</tt> the above example would be interpolated to:
28
+
29
+ <html>
30
+ <body>
31
+ Hey world
32
+ </body>
33
+ </html>
34
+
data/Rakefile CHANGED
@@ -10,6 +10,8 @@ begin
10
10
  s.authors = ["Joshua Hull"]
11
11
  s.files = FileList["[A-Z]*", "{lib,spec}/**/*"]
12
12
  s.add_dependency 'joshbuddy-esi_attribute_language'
13
+ s.add_dependency 'nokogiri'
14
+ s.add_dependency 'jaxn-parse_user_agent'
13
15
  end
14
16
  rescue LoadError
15
17
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,50 @@
1
+ class EsiForRack
2
+
3
+ class Lookup
4
+
5
+ class PassThrough < Lookup
6
+
7
+ def initialize(app, env)
8
+ @app = app
9
+ @env = env
10
+ end
11
+
12
+ def [](path)
13
+ uri = URI(path)
14
+
15
+ request = {
16
+ "REQUEST_METHOD" => "GET",
17
+ "SERVER_NAME" => @env['SERVER_NAME'],
18
+ "SERVER_PORT" => @env['SERVER_PORT'],
19
+ "QUERY_STRING" => uri.query.to_s,
20
+ "PATH_INFO" => (!uri.path || uri.path.empty?) ? "/" : uri.path,
21
+ "rack.url_scheme" => uri.scheme || @env['rack.url_scheme'] || 'http',
22
+ "SCRIPT_NAME" => ""
23
+ }
24
+
25
+ response = @app.call(request)
26
+ if response.first == 200
27
+ response_body = response.last
28
+ if response_body.respond_to? :to_str
29
+ response_body.to_str
30
+ elsif response_body.respond_to?(:each)
31
+ body = ''
32
+ response_body.each { |part|
33
+ body << part.to_s
34
+ }
35
+ body
36
+ else
37
+ raise TypeError, "stringable or iterable required"
38
+ end
39
+ else
40
+ nil
41
+ end
42
+
43
+ rescue URI::InvalidURIError
44
+ nil
45
+ end
46
+
47
+ end
48
+
49
+ end
50
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joshbuddy-esi-for-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Hull
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-18 00:00:00 -07:00
12
+ date: 2009-07-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,18 +22,40 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: jaxn-parse_user_agent
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
25
45
  description: ESI for Rack
26
46
  email: joshbuddy@gmail.com
27
47
  executables: []
28
48
 
29
49
  extensions: []
30
50
 
31
- extra_rdoc_files: []
32
-
51
+ extra_rdoc_files:
52
+ - README.rdoc
33
53
  files:
54
+ - README.rdoc
34
55
  - Rakefile
35
56
  - VERSION
36
57
  - lib/esi_for_rack.rb
58
+ - lib/esi_for_rack/lookup.rb
37
59
  - lib/esi_for_rack/node.rb
38
60
  - spec/http_integration/accept_language_spec.rb
39
61
  - spec/http_integration/cookie_spec.rb