rack_ssi 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.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ .rbenv-version
1
2
  *.gem
2
3
  *.rbc
3
4
  .bundle
data/README.md CHANGED
@@ -7,7 +7,7 @@ Directives currently supported: `block` and `include`
7
7
 
8
8
  Add this line to your application's Gemfile:
9
9
 
10
- gem 'rack_ssi', :git => "git@github.com:forward/rack-ssi.git"
10
+ gem 'rack_ssi'
11
11
 
12
12
  And then execute:
13
13
 
@@ -22,18 +22,18 @@ Or install it yourself as:
22
22
  require 'rack_ssi'
23
23
 
24
24
  ### Sinatra
25
-
26
- configure do
27
- use Rack::SSI, {
28
- :logging => :on,
29
- :when => lambda {|env| not env['SOME_CUSTOM_HEADER'] == 'ON'},
30
- :locations => {
31
- %r{^/includes} => "http://includes.mydomain.com"
32
- }
33
- }
34
- end
35
-
25
+ ```ruby
26
+ configure do
27
+ use Rack::SSI, {
28
+ :logging => :on,
29
+ :when => lambda {|env| not env['SOME_CUSTOM_HEADER'] == 'ON'},
30
+ :locations => {
31
+ %r{^/includes} => "http://includes.mydomain.com"
32
+ }
33
+ }
34
+ end
35
+ ```
36
36
  ### Rails
37
-
38
- config.middleware.use Rack::SSI, { ... }
39
-
37
+ ```ruby
38
+ config.middleware.use Rack::SSI, { ... }
39
+ ```
@@ -0,0 +1,12 @@
1
+ class String
2
+ unless "".respond_to?(:encoding)
3
+ def encoding
4
+ nil
5
+ end
6
+ end
7
+ unless "".respond_to?(:force_encoding)
8
+ def force_encoding(encoding)
9
+ self
10
+ end
11
+ end
12
+ end
data/lib/rack_ssi.rb CHANGED
@@ -1,4 +1,5 @@
1
- require File.expand_path('../ssi_processor', __FILE__)
1
+ require 'compatibility'
2
+ require 'ssi_processor'
2
3
  require 'rest_client'
3
4
  require 'logger'
4
5
 
data/lib/ssi_processor.rb CHANGED
@@ -32,7 +32,7 @@ module Rack
32
32
  if stub && (status != 200 || body.nil? || body == "")
33
33
  blocks[stub]
34
34
  else
35
- body
35
+ body.force_encoding(part.encoding)
36
36
  end
37
37
  end
38
38
  end
data/rack-ssi.gemspec CHANGED
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
  gem.name = "rack_ssi"
17
17
  gem.require_paths = ["lib"]
18
- gem.version = "0.0.2"
18
+ gem.version = "0.0.3"
19
19
  gem.add_dependency "rest-client"
20
20
  end
@@ -1,3 +1,5 @@
1
+ # encoding: UTF-8
2
+
1
3
  require File.expand_path('../spec_helper', __FILE__)
2
4
 
3
5
  describe Rack::SSIProcessor do
@@ -150,7 +152,32 @@ describe Rack::SSIProcessor do
150
152
  processed.gsub(/\s+/, "").should == "<html><body><bang></body></html>"
151
153
  end
152
154
  end
153
-
155
+
156
+ context "the SSI include request returns a response with a different encoding than the context" do
157
+ it "should force the encoding of the context" do
158
+ html = <<-eos
159
+ <html>
160
+ <body>
161
+ <!--# include virtual="/some/location" -->
162
+ </body>
163
+ </html>
164
+ eos
165
+
166
+ expected = <<-eos.gsub /\s+/, ""
167
+ <html>
168
+ <body>
169
+ <p>€254</p>
170
+ </body>
171
+ </html>
172
+ eos
173
+
174
+ ssi = Rack::SSIProcessor.new
175
+ ssi.stub(:fetch).with("/some/location").and_return([200, {}, "<p>€254</p>".force_encoding("ASCII-8BIT")])
176
+
177
+ processed = ssi.process_include(html, {})
178
+ processed.gsub(/\s+/, "").should == expected
179
+ end
180
+ end
154
181
  end
155
182
 
156
183
  describe "#fetch" do
metadata CHANGED
@@ -1,51 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack_ssi
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Thibaut Sacreste
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-08-20 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rest-client
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :runtime
33
- version_requirements: *id001
34
- description: " Rack middleware for processing SSI based on the nginx HttpSsiModule.\n Directives currently supported: 'block' and 'include'\n"
35
- email:
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: ! " Rack middleware for processing SSI based on the nginx HttpSsiModule.\n
31
+ \ Directives currently supported: 'block' and 'include'\n"
32
+ email:
36
33
  - thibaut.sacreste@gmail.com
37
34
  executables: []
38
-
39
35
  extensions: []
40
-
41
36
  extra_rdoc_files: []
42
-
43
- files:
37
+ files:
44
38
  - .gitignore
45
39
  - Gemfile
46
40
  - LICENSE
47
41
  - README.md
48
42
  - Rakefile
43
+ - lib/compatibility.rb
49
44
  - lib/rack_ssi.rb
50
45
  - lib/ssi_processor.rb
51
46
  - rack-ssi.gemspec
@@ -54,38 +49,29 @@ files:
54
49
  - spec/ssi_processor_spec.rb
55
50
  homepage: https://github.com/forward/rack-ssi
56
51
  licenses: []
57
-
58
52
  post_install_message:
59
53
  rdoc_options: []
60
-
61
- require_paths:
54
+ require_paths:
62
55
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
56
+ required_ruby_version: !ruby/object:Gem::Requirement
64
57
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
63
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
81
68
  requirements: []
82
-
83
69
  rubyforge_project:
84
- rubygems_version: 1.8.24
70
+ rubygems_version: 1.8.23
85
71
  signing_key:
86
72
  specification_version: 3
87
73
  summary: Rack middleware for processing SSI based on the nginx HttpSsiModule.
88
- test_files:
74
+ test_files:
89
75
  - spec/rack_ssi_spec.rb
90
76
  - spec/spec_helper.rb
91
77
  - spec/ssi_processor_spec.rb