rack_phantom 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 228af5ff03c29c2e333491e784ddbd0508ca3b6d
4
- data.tar.gz: 31238f79e1a1b2e61c38e6df1d34670ac45e660a
3
+ metadata.gz: ebb02e8354733ee6342887c0e9f145e22b2fd218
4
+ data.tar.gz: f05f9240c4f8ac532c89a69223b257b3391824d2
5
5
  SHA512:
6
- metadata.gz: ec40ae7c9940e0f2682193df063406e2f5688b60b59801f3f012d4166ffe8d60bdf77137ce4885bd98ab37081dbec4d4e375bdef57bd6e383917112488763cf8
7
- data.tar.gz: 770ed195fdaade233a87457fd6844f2d11fc63a23081f863417135bfca18a3419a009e3f2efd0d93650bb6e4696a9c8bc59bb77346f292954b26dcce996c9898
6
+ metadata.gz: ab119eb22401043356fbecd77b85657482ab961c2bf7851281f8b25de3ba7bd6d81ce44e49feefa842d93900472c75591b36e377df54f2812504845e605585be
7
+ data.tar.gz: f6510e5a33ec5a48a818cbbacfbe52916849be1245f923fd6581d02317c1eb577a860f54e7bc7718eeec09bc76d75008e8a49df3631cde4fa97a661f614e8d21
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'rack_phantom'
@@ -0,0 +1,15 @@
1
+ # RackPhantom Sinatra Example
2
+
3
+ ## Run
4
+
5
+ ```bash
6
+ bundle install
7
+ bundle exec ruby app.rb
8
+ ```
9
+
10
+ ## Demo
11
+
12
+ ```bash
13
+ curl http://localtest.me:4567/ # regular request
14
+ curl -A "Googlebot" http://localtest.me:4567/ # request as google bot
15
+ ```
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ use RackPhantom::Middleware
5
+
6
+ get '/' do
7
+ %q{<html><head><script>document.write("Hello World");</script></head><body></body></html>}
8
+ end
@@ -21,7 +21,8 @@ module RackPhantom
21
21
 
22
22
  return [status, headers, response] unless render?(headers, env)
23
23
 
24
- html = Phantomjs.run(render_js, %['#{response.join("\n")}']).strip
24
+ response = response.join("\n").gsub("\"", "\\\"")
25
+ html = Phantomjs.run(render_js, %["#{response}"]).strip
25
26
  headers['Content-Length'] = html.length.to_s
26
27
 
27
28
  [status, headers, [html]]
@@ -1,3 +1,3 @@
1
1
  module RackPhantom
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe RackPhantom do
4
4
 
5
- let(:html) { %q{<html><head><script>document.write("Hello World");</script></head><body></body></html>} }
5
+ let(:html) { %q{<html><head><script>document.write("Hello' World");</script></head><body></body></html>} }
6
6
  let(:real_app) { ->(env) { [200, {'Content-Type' => 'text/html'}, [html]] } }
7
7
  let(:app) { RackPhantom::Middleware.new(real_app) }
8
8
 
@@ -19,10 +19,8 @@ describe RackPhantom do
19
19
  last_response.headers['Content-Length'].should == evaluated_html.length.to_s
20
20
  end
21
21
 
22
- it 'escapes the single quotes'
23
-
24
22
  def evaluated_html
25
- %q{<html><head><script>document.write("Hello World");</script></head><body>Hello World</body></html>}
23
+ %q{<html><head><script>document.write("Hello' World");</script></head><body>Hello' World</body></html>}
26
24
  end
27
25
  end
28
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack_phantom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Selva
@@ -110,6 +110,9 @@ files:
110
110
  - LICENSE.txt
111
111
  - README.md
112
112
  - Rakefile
113
+ - examples/rack_app/Gemfile
114
+ - examples/rack_app/README.md
115
+ - examples/rack_app/app.rb
113
116
  - js/render.js
114
117
  - lib/rack_phantom.rb
115
118
  - lib/rack_phantom/railtie.rb