rack-lacquer 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmIwZjQ3ZTZiM2RjZDIyNGU1ZjhhMDUzOTJmMGIwYjlmMmEyODE0Nw==
4
+ MmEzN2VhOThmMGQ0ZGQzNzY4ODE4ZTYwNmNhOWQ0NmZhMWM3OTQyNw==
5
5
  data.tar.gz: !binary |-
6
- NjA3YWFjZDZjZDQ2NjZkMDg0YWQxZmFhYzBhMjVhZmY1NWVkYzQwNA==
6
+ Mzc2ZjIzOTY4NjhkMDc1M2UxNTVmODJjOWYzZTM5NThkZjBlOTQ2ZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MWNmYzVkMzNiNmM1NDRiMzhkZTRiODdmMGY3NGI2NjYxNTUwYThiNGFhZGE4
10
- NTVkZWY4ZTdiYTdkY2IwY2Q3YWZjZGRjNGQ5MjY2YWJmZWQ2NjNmNWZiNzFj
11
- YTAxMjFmMWE2YTQ1NmU5OWNlMjMzNmU0MjEwMTM3Y2JkZmQ5MmQ=
9
+ ZWIwYzE0YTg3ZmFmNTQ2ODA2ZjhiNjg2MTQzZTVjMjMwMjRkNjNkM2FhYTA4
10
+ ODVkYjUwY2JiMTBjOTQyM2ZmODBiY2U1ZWExODJlN2ZlN2M4MDFiODJkNWUx
11
+ ZDU4YWM0OWIyMzJjMzQ0ZjAwMDE3NDQ2MmJmOTAyY2VhZGFmYjU=
12
12
  data.tar.gz: !binary |-
13
- YTQ3YWM3ZjA5NWE5Y2EwYmFkNzQ0NjAzOTI5ZTIwZTk2ZDRkMGVlNmRhNDFk
14
- YzczMTk2YmEzYzQ5YjRmZmNhODIzM2E1Mzk1MjhlNjE2ZmVjMjliZTI2MDUw
15
- ZGMyYzZhNDI1MmM1NzY5NGM0NTEwMGUyMDU3ZjhmYWRlOTA2ODM=
13
+ NTgzN2I0NzlhMDk2MzM0MDBkYjViOGEzYmE5NDhmMmIwYzhmYjU4NjEzOWY0
14
+ YTIzNTE5MWU1ZTEyNjUyYjg2ODZiYjAwNjYwNTVkMWJkMzFmMGY4MTBlMmRi
15
+ N2FjYTU0ZGFkMDM3YTlhYTA1NWYxYmE5YTQ3MDU1YjBkZmVhYWQ=
data/README.md CHANGED
@@ -18,11 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- In your rails environment file, add the following:
21
+ In your rails development environment file, add the following:
22
22
 
23
23
  ``` ruby
24
24
  config.middleware.insert_before ActionDispatch::Static, Rack::Lacquer
25
+ config.threadsafe!
25
26
  ```
27
+ This inserts Rack::Lacquer as the first middleware in the stack. We run in threadsafe mode to prevent recursive locking from Rack::Lock
26
28
 
27
29
  ## Contributing
28
30
 
@@ -1,3 +1,5 @@
1
+ require 'nokogiri'
2
+
1
3
  module Rack
2
4
  class Lacquer
3
5
 
@@ -6,20 +8,30 @@ module Rack
6
8
  end
7
9
 
8
10
  def call env
11
+ @env = env.deep_dup
9
12
  status, headers, response = @app.call env
10
- response.map! { |part| process_includes part, env } if headers['Content-Type'] =~ /text\/html/ && response.respond_to?( :map! )
13
+ response.map! { |part| process_includes part } if headers['Content-Type'] =~ /text\/html/ && response.respond_to?( :map! )
11
14
  [status, headers, response]
12
15
  end
13
16
 
14
- def process_includes part, env
17
+ def process_includes part
15
18
  document = Nokogiri::HTML part.to_s
16
19
  document.css('include').each do |esi|
17
- include_status, include_headers, include_response = @app.call env.merge 'PATH_INFO' => esi['src'], 'REQUEST_URI' => esi['src']
18
- esi.after include_response.join
20
+ status, headers, response = @app.call env_for(esi['src'])
21
+ esi.after response.join
19
22
  esi.remove
20
23
  end
21
24
  document.to_s
22
25
  end
23
26
 
27
+ def env_for path_with_query
28
+ path_info, query_string = path_with_query.split('?')
29
+ @env.deep_dup.merge({
30
+ 'PATH_INFO' => path_info,
31
+ 'REQUEST_URI' => path_with_query,
32
+ 'QUERY_STRING' => query_string.to_s
33
+ })
34
+ end
35
+
24
36
  end
25
37
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rack-lacquer"
7
- spec.version = '0.0.2'
7
+ spec.version = '0.0.3'
8
8
  spec.authors = ["Adam Ross Cohen"]
9
9
  spec.email = ["a.ross.cohen@gmail.com"]
10
10
  spec.description = %q{Ruby driven ESI for non-production environments}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-lacquer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Ross Cohen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-12 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri