rack-varnish-esi 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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 868a50df8b570f5f12ffa4838f0af462f94f731f
4
- data.tar.gz: f68cb19e79f829083ec53c0ea0fba9ddd6e64b9c
3
+ metadata.gz: e82b47df9d83984078b8c319a2ff76ed8f13e29e
4
+ data.tar.gz: e3bc74e67a1b8d23b8b2bd42aba45dd7bb268ac8
5
5
  SHA512:
6
- metadata.gz: 8d0a0f6a039b10adcc3a8be8975fac56014526a95fcb67598acfae2c9a67fd3cbdea0925b66fafd134d8649e8ffd51a6e577ea81c5787191be4995be4aeaa310
7
- data.tar.gz: ad8020a28a4a067dbbe015fe86912450909a5ea26fe04087ede5f809fd07fae616d83f21e1e8a523b09602c8ac677cc4235aeb2632ddca81d084b59088a4d1ea
6
+ metadata.gz: 25f7a8579e5fea4679c99ac127b57ca109e71618d5789ea330e94e58d32996d6c87e5e5bd9c40ad77e3c081396c9a50079761b7fb2eaab13b34e65316acb5eaa
7
+ data.tar.gz: ac4bfac1131a090d98d163d1cbab01b7322267a67edf632fb3ac16901cccbddd7814950ca8be641a4379ab231cfefa4ef1b18e079427799afa852abbab6c4fa8
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -30,7 +30,7 @@ module Rack
30
30
 
31
31
  def process_include(part)
32
32
  part.gsub(/<esi:include src="([^"]+)"(?: +alt="([^"]+)")?\/?>/) do
33
- fetch($1)
33
+ fetch($1).force_encoding(part.encoding)
34
34
  end
35
35
  end
36
36
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class VarnishEsi
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -24,4 +24,5 @@ Note: This gem should only be used in development.}
24
24
  spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "minitest"
27
+ spec.add_development_dependency "webmock"
27
28
  end
@@ -2,3 +2,4 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'rack/varnish_esi'
3
3
 
4
4
  require 'minitest/autorun'
5
+ require 'webmock/minitest'
@@ -10,6 +10,8 @@ class TestRackVarnishEsi < Minitest::Test
10
10
  end
11
11
 
12
12
  def test_that_it_has_the_same_behavior_as_varnish
13
+ WebMock.allow_net_connect!
14
+
13
15
  http_server_thread = start_http_server_with_varnish_esi_middleware(
14
16
  :locations => {/.*/ => 'http://localhost:8080'},
15
17
  )
@@ -0,0 +1,32 @@
1
+ require 'minitest_helper'
2
+
3
+ class TestRackVarnishEsiProcessor < Minitest::Test
4
+ def test_that_it_forces_the_encoding_of_the_context
5
+ WebMock.disable_net_connect!
6
+
7
+ processor = Rack::VarnishEsiProcessor.new(
8
+ /.*/ => 'http://rack-varnish-esi.test'
9
+ )
10
+
11
+ body = <<-eos
12
+ <html>
13
+ <body>
14
+ <esi:include src="/some/location">
15
+ </body>
16
+ </html>
17
+ eos
18
+
19
+ expected = <<-eos
20
+ <html>
21
+ <body>
22
+ <p>€254</p>
23
+ </body>
24
+ </html>
25
+ eos
26
+
27
+ stub_request(:get, "http://rack-varnish-esi.test/some/location").to_return(:status => 200, :body => "<p>€254</p>".force_encoding("ASCII-8BIT"), :headers => {})
28
+
29
+ processed = processor.process(body.strip.split("\n"))
30
+ assert_equal expected.strip, processed.join("\n").strip
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-varnish-esi
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
  - Thomas Marek
@@ -66,12 +66,27 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: |-
70
84
  rack-varnish-esi is a Varnish ESI middleware implementation for Rack which is as close as possible to Varnish's own ESI implementation.
71
85
  Note: This gem should only be used in development.
72
86
  email:
73
87
  - thomas_marek@gmx.net
74
- executables: []
88
+ executables:
89
+ - rake
75
90
  extensions: []
76
91
  extra_rdoc_files: []
77
92
  files:
@@ -80,6 +95,7 @@ files:
80
95
  - LICENSE.txt
81
96
  - README.md
82
97
  - Rakefile
98
+ - bin/rake
83
99
  - lib/rack-varnish-esi.rb
84
100
  - lib/rack/varnish_esi.rb
85
101
  - lib/rack/varnish_esi_processor.rb
@@ -97,6 +113,7 @@ files:
97
113
  - test/static_server/public/subdir/full_name.html
98
114
  - test/static_server/public/unicode.txt
99
115
  - test/test_rack_varnish_esi.rb
116
+ - test/test_varnish_esi_processor.rb
100
117
  homepage: https://github.com/tmak/rack-varnish-esi
101
118
  licenses:
102
119
  - MIT
@@ -134,3 +151,4 @@ test_files:
134
151
  - test/static_server/public/subdir/full_name.html
135
152
  - test/static_server/public/unicode.txt
136
153
  - test/test_rack_varnish_esi.rb
154
+ - test/test_varnish_esi_processor.rb