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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2QxYzU1Yjc3YmEzYzRmYjg5MTdlMWViN2JiYWUyNjdiYWRmZmQ4Yg==
4
+ NzY2YzZkNTBjOWZmNWVhYzA0OTU5ZDgxNzA3M2IwMTEzOGRlOTQzYw==
5
5
  data.tar.gz: !binary |-
6
- MDBmOTllZDkzYzg2NjE1ZmVjY2RiYzE4NzA1YjVhNzA4ZTNiMjE4ZA==
6
+ MDVhM2ZiNDIyMmY2MDYxZGI4Njk3YWVhM2I1ZjBjNmMwMzllYzEzMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTg5Y2E4MGZjZTRlOWU0ZmRkNDY3OGRmMTMwYzkzZTc3MzIyNDViMTdiMGQy
10
- ZmQ5Yjc1ZGM2ZDUwYTk4YjliYzYwYzg1MmY0MzY0ODliNGI5MWZlMTlhYjhm
11
- Njg1MTI2MzAzOTY1Mzg2MGYyMmExNDM5YmI4Y2ZkYzBkYmU5MjI=
9
+ MTBhYzE0NmVlOTZhOWZiMjc2YzUxYWU0NzZmOGI0NmQ0NTRjN2NiOWRkOTAx
10
+ MGM4MmU0Y2U1ZTViNzc2Njg1MzI1MDA5YzU2ZmY3OTg1N2M1MWVmZDE5Yzdm
11
+ YjI2ZGNhNjViOTI5ZmI2M2E3YjRhZmZmYTM0OWU5MzIxMzgwNDc=
12
12
  data.tar.gz: !binary |-
13
- ZGYzZDVlMmZkOTY2YTU5MWZhNDRlNWQ5MzllMmFmMjVlMjBhYjk2MjM0NDZi
14
- YmFkMzE4MDBlMTliYTUzOWE4MWZkNjRmNjA3NTZmOTg5NWE2M2RjNzRmMDA4
15
- ZGYyOTc5ZjI2N2NjMTFhZTA4NTdjMDVjZGU2MzIxNTRlNDlkM2M=
13
+ NzU1ZTdiOTFlNTc2ODA2ZmQ3ZjgyOGUwYjMxZWU4ZWRlMTg1YzhlYTE4MTQx
14
+ NjhkZGU1YWI0NTBkOWUzNjM4NTExNTY3YzQ4Mjg2YzRlOWRlNjAzNDhlNjk2
15
+ M2IzNmFhNjExNDAzNjQ4ZjE3MDU2NTcwYzU2NGRkNDMyMzk4YjU=
data/README.md CHANGED
@@ -9,7 +9,7 @@ Details of the scheme can be found at: https://developers.google.com/webmasters/
9
9
  install
10
10
 
11
11
  ``` ruby
12
- gem install google-ajax-crawler
12
+ gem install google_ajax_crawler
13
13
  ```
14
14
 
15
15
  In your config.ru
@@ -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]] }
@@ -10,6 +10,6 @@ end
10
10
 
11
11
  module GoogleAjaxCrawler
12
12
  def self.version
13
- "0.1.0"
13
+ "0.1.1"
14
14
  end
15
15
  end
@@ -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
@@ -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}#test" }
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 #test/
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 #test/
32
+ response.body.should =~ /Javascript rendering complete for client-side route #!test/
33
33
  end
34
34
  end
35
35
  end
@@ -36,11 +36,11 @@ class RackApp
36
36
  pid = Process.fork
37
37
  if pid.nil?
38
38
  Rack::Server.start(:app => app, :Port => port)
39
- sleep 1
40
39
  else
41
40
  File.open(pidfile, 'w') { |f| f.write pid }
42
41
  trap("SIGINT") { stop }
43
42
  Process.detach pid
43
+ sleep 1
44
44
  end
45
45
  end
46
46
 
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.0
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