google_ajax_crawler 0.1.0 → 0.1.1
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 +8 -8
- data/README.md +1 -1
- data/examples/config.ru +13 -0
- data/lib/google_ajax_crawler.rb +1 -1
- data/lib/google_ajax_crawler/crawler.rb +1 -1
- data/releases/google_ajax_crawler-0.1.0.gem +0 -0
- data/spec/integration/capybara_webkit_spec.rb +3 -3
- data/spec/support/rack_app.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzY2YzZkNTBjOWZmNWVhYzA0OTU5ZDgxNzA3M2IwMTEzOGRlOTQzYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDVhM2ZiNDIyMmY2MDYxZGI4Njk3YWVhM2I1ZjBjNmMwMzllYzEzMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTBhYzE0NmVlOTZhOWZiMjc2YzUxYWU0NzZmOGI0NmQ0NTRjN2NiOWRkOTAx
|
10
|
+
MGM4MmU0Y2U1ZTViNzc2Njg1MzI1MDA5YzU2ZmY3OTg1N2M1MWVmZDE5Yzdm
|
11
|
+
YjI2ZGNhNjViOTI5ZmI2M2E3YjRhZmZmYTM0OWU5MzIxMzgwNDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzU1ZTdiOTFlNTc2ODA2ZmQ3ZjgyOGUwYjMxZWU4ZWRlMTg1YzhlYTE4MTQx
|
14
|
+
NjhkZGU1YWI0NTBkOWUzNjM4NTExNTY3YzQ4Mjg2YzRlOWRlNjAzNDhlNjk2
|
15
|
+
M2IzNmFhNjExNDAzNjQ4ZjE3MDU2NTcwYzU2NGRkNDMyMzk4YjU=
|
data/README.md
CHANGED
data/examples/config.ru
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.require(:default)
|
3
|
+
require './lib/google_ajax_crawler'
|
4
|
+
require './spec/support/rack_app'
|
5
|
+
|
6
|
+
use GoogleAjaxCrawler::Crawler do |config|
|
7
|
+
config.driver = GoogleAjaxCrawler::Drivers::CapybaraWebkit
|
8
|
+
config.poll_interval = 0.25
|
9
|
+
config.page_loaded_test = lambda {|driver| driver.page.evaluate_script('document.getElementById("loading") == null') }
|
10
|
+
end
|
11
|
+
|
12
|
+
page_content = File.read('./spec/support/page.html')
|
13
|
+
run lambda {|env| [200, { 'Content-Type' => 'text/html' }, [page_content]] }
|
data/lib/google_ajax_crawler.rb
CHANGED
@@ -40,7 +40,7 @@ module GoogleAjaxCrawler
|
|
40
40
|
def as_uri_with_fragment(url)
|
41
41
|
uri = URI.parse(url)
|
42
42
|
params = Rack::Utils.parse_query(uri.query).merge(search_engine: true)
|
43
|
-
uri.fragment = params.delete options.requested_route_key
|
43
|
+
uri.fragment = "!#{params.delete options.requested_route_key}"
|
44
44
|
uri.query = Rack::Utils.build_query params
|
45
45
|
uri
|
46
46
|
end
|
Binary file
|
@@ -2,7 +2,7 @@ require './spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe 'CapybaraWebkit driver' do
|
4
4
|
let(:host) { "http://localhost:#{RackApp.port}/"}
|
5
|
-
let(:browser_route) { "#{host}
|
5
|
+
let(:browser_route) { "#{host}#!test" }
|
6
6
|
let(:snapshot_route) { "#{host}?_escaped_fragment_=test" }
|
7
7
|
|
8
8
|
before(:all) do
|
@@ -22,14 +22,14 @@ describe 'CapybaraWebkit driver' do
|
|
22
22
|
describe 'when a browser requests a client side route (i.e.: /#my_route)' do
|
23
23
|
it 'should not serve a snapshot of the dom' do
|
24
24
|
response = Faraday.get browser_route
|
25
|
-
response.body.should_not =~ /Javascript rendering complete for client-side route
|
25
|
+
response.body.should_not =~ /Javascript rendering complete for client-side route #!test/
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
29
|
describe 'when an ajax crawler requests a snapshot of a client side route' do
|
30
30
|
it 'should serve a snapshot of the dom that includes js rendered components' do
|
31
31
|
response = Faraday.get snapshot_route
|
32
|
-
response.body.should =~ /Javascript rendering complete for client-side route
|
32
|
+
response.body.should =~ /Javascript rendering complete for client-side route #!test/
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/spec/support/rack_app.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_ajax_crawler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Kitzelman
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- LICENSE.txt
|
56
56
|
- README.md
|
57
57
|
- Rakefile
|
58
|
+
- examples/config.ru
|
58
59
|
- google_ajax_crawler.gemspec
|
59
60
|
- lib/google_ajax_crawler.rb
|
60
61
|
- lib/google_ajax_crawler/crawler.rb
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- lib/google_ajax_crawler/drivers/driver.rb
|
63
64
|
- lib/google_ajax_crawler/options.rb
|
64
65
|
- lib/google_ajax_crawler/page.rb
|
66
|
+
- releases/google_ajax_crawler-0.1.0.gem
|
65
67
|
- spec/integration/capybara_webkit_spec.rb
|
66
68
|
- spec/spec_helper.rb
|
67
69
|
- spec/support/page.html
|