seojs 0.0.5 → 0.0.7

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: 1ff41c44815271af27f16d7419a59a8820f270f0
4
- data.tar.gz: edeb8d13e24cf062cd5faa3b0294668e103ef68a
3
+ metadata.gz: db1d2bc5a6f425688e975276a74290e9b7555532
4
+ data.tar.gz: e556f95c06025db18757aef6e912456b3180d65b
5
5
  SHA512:
6
- metadata.gz: 31b473f7b05c647e43102021e76fc1bebc8f699571c319c243af46838c677c49279609db7d8c6cd8e18e052801cea9ff5913cdd4d0c798e7172be15e10915ece
7
- data.tar.gz: 94290ae8623c1cf71847442f7964063ffc25014e1c0a0106dffb714087dbfd8f8db8fcf7e1672106c548f4a0477654770c6b83bac5dcc0b8baa137bf23e7e203
6
+ metadata.gz: 8a2c254ec97c5404b66657212a533809a766c3d0b51590becb2cc69b624f5157b2f2099b173371893606f4036ba165bb27be25413161e648efb167c4f8590c1e
7
+ data.tar.gz: b442cb4eef3ae8ed973b8292e75801a38a2f0a40b2a1569757bb20560a015ff6590160d21a284fd97483ba9a2c0a7a46bd8ea0daf19b543dd56a3a51c7e1e830
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx-19mode
data/Gemfile CHANGED
@@ -6,12 +6,12 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
 
9
- gem 'rack-proxy'
10
-
11
9
  group :development do
12
- gem "shoulda", ">= 0"
10
+ gem "sinatra"
11
+ gem "rack-test"
12
+ gem "mocha"
13
13
  gem "rdoc", "~> 3.12"
14
14
  gem "bundler", "~> 1.0"
15
15
  gem "jeweler", "~> 1.8.7"
16
- #gem "rcov", ">= 0"
16
+ gem "simplecov-console"
17
17
  end
data/Gemfile.lock CHANGED
@@ -1,15 +1,9 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (4.0.0)
5
- i18n (~> 0.6, >= 0.6.4)
6
- minitest (~> 4.2)
7
- multi_json (~> 1.3)
8
- thread_safe (~> 0.1)
9
- tzinfo (~> 0.3.37)
10
4
  addressable (2.3.5)
11
- atomic (1.1.14)
12
5
  builder (3.2.2)
6
+ colorize (0.6.0)
13
7
  faraday (0.8.8)
14
8
  multipart-post (~> 1.2.0)
15
9
  git (1.2.6)
@@ -22,8 +16,8 @@ GEM
22
16
  oauth2
23
17
  hashie (2.0.5)
24
18
  highline (1.6.19)
19
+ hirb (0.7.1)
25
20
  httpauth (0.2.0)
26
- i18n (0.6.5)
27
21
  jeweler (1.8.7)
28
22
  builder
29
23
  bundler (~> 1.0)
@@ -36,7 +30,9 @@ GEM
36
30
  json (1.8.0)
37
31
  jwt (0.1.8)
38
32
  multi_json (>= 1.5)
39
- minitest (4.7.5)
33
+ metaclass (0.0.1)
34
+ mocha (0.14.0)
35
+ metaclass (~> 0.0.1)
40
36
  multi_json (1.8.0)
41
37
  multi_xml (0.5.5)
42
38
  multipart-post (1.2.0)
@@ -49,20 +45,26 @@ GEM
49
45
  multi_xml (~> 0.5)
50
46
  rack (~> 1.2)
51
47
  rack (1.5.2)
52
- rack-proxy (0.5.1)
48
+ rack-protection (1.5.0)
53
49
  rack
50
+ rack-test (0.6.2)
51
+ rack (>= 1.0)
54
52
  rake (10.1.0)
55
53
  rdoc (3.12.2)
56
54
  json (~> 1.4)
57
- shoulda (3.5.0)
58
- shoulda-context (~> 1.0, >= 1.0.1)
59
- shoulda-matchers (>= 1.4.1, < 3.0)
60
- shoulda-context (1.1.5)
61
- shoulda-matchers (2.3.0)
62
- activesupport (>= 3.0.0)
63
- thread_safe (0.1.3)
64
- atomic
65
- tzinfo (0.3.37)
55
+ simplecov (0.7.1)
56
+ multi_json (~> 1.0)
57
+ simplecov-html (~> 0.7.1)
58
+ simplecov-console (0.1.3)
59
+ colorize
60
+ hirb
61
+ simplecov
62
+ simplecov-html (0.7.1)
63
+ sinatra (1.4.3)
64
+ rack (~> 1.4)
65
+ rack-protection (~> 1.4)
66
+ tilt (~> 1.3, >= 1.3.4)
67
+ tilt (1.4.1)
66
68
 
67
69
  PLATFORMS
68
70
  ruby
@@ -70,6 +72,8 @@ PLATFORMS
70
72
  DEPENDENCIES
71
73
  bundler (~> 1.0)
72
74
  jeweler (~> 1.8.7)
73
- rack-proxy
75
+ mocha
76
+ rack-test
74
77
  rdoc (~> 3.12)
75
- shoulda
78
+ simplecov-console
79
+ sinatra
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # SEO.js for Rails
1
+ # SEO.js for Rails [![Build Status](https://travis-ci.org/seojs/seojs-ruby.png)](https://travis-ci.org/seojs/seojs-ruby)
2
+
2
3
 
3
4
  Welcome to [SEO.js](http://getseojs.com/) for Rails! SEO.js makes your BackboneJS, AngularJS or EmberJS apps crawlable by Google to make them appear in search results. Integrating it to your Rails or Sinatra app is easy.
4
5
 
@@ -56,7 +57,26 @@ This method works both with **HTML5 pushState URLs** as well as **Hashbang URLs*
56
57
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
57
58
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
58
59
 
59
- ## Copyright
60
+ ## License
61
+
62
+ The MIT License (MIT)
63
+
64
+ Copyright (c) 2013 SEO.js. http://getseojs.com/
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining a copy
67
+ of this software and associated documentation files (the "Software"), to deal
68
+ in the Software without restriction, including without limitation the rights
69
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
70
+ copies of the Software, and to permit persons to whom the Software is
71
+ furnished to do so, subject to the following conditions:
72
+
73
+ The above copyright notice and this permission notice shall be included in
74
+ all copies or substantial portions of the Software.
60
75
 
61
- Copyright (c) 2013 SEO.js. See LICENSE.txt for
62
- further details.
76
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
82
+ THE SOFTWARE.
data/Rakefile CHANGED
@@ -32,16 +32,6 @@ Rake::TestTask.new(:test) do |test|
32
32
  test.verbose = true
33
33
  end
34
34
 
35
- #require 'rcov/rcovtask'
36
- #Rcov::RcovTask.new do |test|
37
- # test.libs << 'test'
38
- # test.pattern = 'test/**/test_*.rb'
39
- # test.verbose = true
40
- # test.rcov_opts << '--exclude "gems/*"'
41
- #end
42
-
43
- task :default => :test
44
-
45
35
  require 'rdoc/task'
46
36
  Rake::RDocTask.new do |rdoc|
47
37
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
@@ -51,3 +41,5 @@ Rake::RDocTask.new do |rdoc|
51
41
  rdoc.rdoc_files.include('README*')
52
42
  rdoc.rdoc_files.include('lib/**/*.rb')
53
43
  end
44
+
45
+ task :default => [:test]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.7
@@ -1,38 +1,84 @@
1
- require 'seojs/rack/proxy'
2
- require 'seojs/rack/cascade'
1
+ require 'net/http'
2
+ require 'uri'
3
3
 
4
4
  module Seojs
5
5
  class Middleware
6
6
 
7
7
  def initialize(app)
8
- @app = app
9
- proxy_app = Rack::Proxy.new(backend: "#{Seojs.url}/v3", streaming: false)
10
- @rack_proxy = Rack::Cascade.new([proxy_app, app], [200, 301, 302, 304])
11
- puts "init"
8
+ @app = app
12
9
  end
13
10
 
14
11
  def call(env)
15
12
  @env = env
16
13
 
17
14
  if test?
18
- [ 200, {"Content-Type" => "text/html"}, self ]
15
+ return [ 200, {"Content-Type" => "text/html"}, 'SEO.js Middleware Found!' ]
19
16
  elsif Seojs.url && escaped_fragment_query?
20
- @rack_proxy.call(env)
21
- else
22
- @app.call(env)
23
- end
24
- end
25
-
26
- def each(&block)
27
- if test?
28
- block.call "SEO.js Middleware Found!"
17
+ triplet = get_snapshot
18
+ return triplet if triplet
29
19
  end
20
+ @app.call(env)
30
21
  end
31
22
 
32
23
  private
24
+
25
+ def get_snapshot
26
+ url, headers = snapshot_request
27
+ Timeout.timeout(10) do
28
+ req = Net::HTTP::Get.new(url.to_s)
29
+ headers.each_pair do |key, value|
30
+ req[key] = value
31
+ end
32
+
33
+ snapshot_response = Net::HTTP.start(url.hostname, url.port, :use_ssl => url.scheme == 'https') {|http|
34
+ http.request(req)
35
+ }
36
+
37
+ if [200, 301, 302, 304].include? snapshot_response.code.to_i
38
+ body = snapshot_response.body || ""
39
+ body = [body] unless body.respond_to?(:each)
40
+ [snapshot_response.code, snapshot_response.to_hash, body]
41
+ else
42
+ nil
43
+ end
44
+ end
45
+ rescue Exception => e
46
+ nil
47
+ end
48
+
49
+ def snapshot_request
50
+ source_request = Rack::Request.new(@env)
51
+
52
+ if source_request.fullpath == ""
53
+ full_path = URI.parse(@env['REQUEST_URI']).request_uri
54
+ else
55
+ full_path = source_request.fullpath
56
+ end
57
+
58
+ scheme, host, port = source_request.scheme, source_request.host, source_request.port
59
+
60
+ url = URI.parse("#{Seojs.url}/v3/#{scheme}://#{host}:#{port}#{full_path}")
61
+ headers = extract_http_request_headers(@env)
62
+ [url, headers]
63
+ end
64
+
65
+ def extract_http_request_headers(env)
66
+ headers = env.reject do |k, v|
67
+ !(/^HTTP_[A-Z_]+$/ === k) || v.nil?
68
+ end.map do |k, v|
69
+ [reconstruct_header_name(k), v]
70
+ end.select do |k,v|
71
+ ["IF-NONE-MATCH", "IF-MODIFIED-SINCE", "CACHE-CONTROL"].include? k
72
+ end
73
+ Hash[headers]
74
+ end
75
+
76
+ def reconstruct_header_name(name)
77
+ name.sub(/^HTTP_/, "").gsub("_", "-")
78
+ end
33
79
 
34
80
  def escaped_fragment_query?
35
- @env['ORIGINAL_FULLPATH'].match(/_escaped_fragment_/)
81
+ @env['QUERY_STRING'].match(/_escaped_fragment_/)
36
82
  end
37
83
 
38
84
  def test?
data/lib/seojs.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  module Seojs
2
2
 
3
3
  def self.token=(value)
4
- @url = "http://cdn.getseojs.com/snapshots/#{value}"
4
+ if value
5
+ @url = "http://cdn.getseojs.com/snapshots/#{value}"
6
+ else
7
+ @url = nil
8
+ end
5
9
  end
6
10
 
7
11
  def self.url=(value)
data/seojs.gemspec CHANGED
@@ -5,33 +5,30 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "seojs"
8
- s.version = "0.0.5"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["getseojs.com"]
12
- s.date = "2013-10-01"
12
+ s.date = "2013-10-11"
13
13
  s.description = "SEO.js makes your BackboneJS, AngularJS or EmberJS apps crawlable by Google to make them appear in search results."
14
14
  s.email = "hello@getseojs.com"
15
15
  s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
16
  "README.md"
18
17
  ]
19
18
  s.files = [
20
19
  ".document",
20
+ ".travis.yml",
21
21
  "Gemfile",
22
22
  "Gemfile.lock",
23
- "LICENSE.txt",
24
23
  "README.md",
25
24
  "Rakefile",
26
25
  "VERSION",
27
26
  "lib/seojs.rb",
28
27
  "lib/seojs/middleware.rb",
29
- "lib/seojs/rack/cascade.rb",
30
- "lib/seojs/rack/proxy.rb",
31
28
  "lib/seojs/railtie.rb",
32
29
  "seojs.gemspec",
33
30
  "test/helper.rb",
34
- "test/test_seojs.rb"
31
+ "test/test_middleware.rb"
35
32
  ]
36
33
  s.homepage = "http://github.com/seojs/seojs-ruby"
37
34
  s.licenses = ["MIT"]
@@ -43,24 +40,30 @@ Gem::Specification.new do |s|
43
40
  s.specification_version = 4
44
41
 
45
42
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
- s.add_runtime_dependency(%q<rack-proxy>, [">= 0"])
47
- s.add_development_dependency(%q<shoulda>, [">= 0"])
43
+ s.add_development_dependency(%q<sinatra>, [">= 0"])
44
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
45
+ s.add_development_dependency(%q<mocha>, [">= 0"])
48
46
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49
47
  s.add_development_dependency(%q<bundler>, ["~> 1.0"])
50
48
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
49
+ s.add_development_dependency(%q<simplecov-console>, [">= 0"])
51
50
  else
52
- s.add_dependency(%q<rack-proxy>, [">= 0"])
53
- s.add_dependency(%q<shoulda>, [">= 0"])
51
+ s.add_dependency(%q<sinatra>, [">= 0"])
52
+ s.add_dependency(%q<rack-test>, [">= 0"])
53
+ s.add_dependency(%q<mocha>, [">= 0"])
54
54
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
55
55
  s.add_dependency(%q<bundler>, ["~> 1.0"])
56
56
  s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
57
+ s.add_dependency(%q<simplecov-console>, [">= 0"])
57
58
  end
58
59
  else
59
- s.add_dependency(%q<rack-proxy>, [">= 0"])
60
- s.add_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_dependency(%q<sinatra>, [">= 0"])
61
+ s.add_dependency(%q<rack-test>, [">= 0"])
62
+ s.add_dependency(%q<mocha>, [">= 0"])
61
63
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
62
64
  s.add_dependency(%q<bundler>, ["~> 1.0"])
63
65
  s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
66
+ s.add_dependency(%q<simplecov-console>, [">= 0"])
64
67
  end
65
68
  end
66
69
 
data/test/helper.rb CHANGED
@@ -7,12 +7,23 @@ rescue Bundler::BundlerError => e
7
7
  $stderr.puts "Run `bundle install` to install missing gems"
8
8
  exit e.status_code
9
9
  end
10
+
11
+ require 'simplecov'
12
+ require 'simplecov-console'
13
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ SimpleCov::Formatter::Console,
16
+ ]
17
+ SimpleCov.start do
18
+ add_filter 'vendor' # Don't include vendored stuff
19
+ end
20
+
10
21
  require 'test/unit'
11
- require 'shoulda'
22
+ require 'mocha/setup'
12
23
 
13
24
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
25
  $LOAD_PATH.unshift(File.dirname(__FILE__))
15
26
  require 'seojs'
16
27
 
17
28
  class Test::Unit::TestCase
18
- end
29
+ end
@@ -0,0 +1,109 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+ require 'helper'
3
+ require 'rack/test'
4
+ require 'sinatra/base'
5
+
6
+ class TestApp < Sinatra::Base
7
+ use Seojs::Middleware
8
+
9
+ get '/hi' do
10
+ "Hello!"
11
+ end
12
+ end
13
+
14
+ class TestMiddleware < Test::Unit::TestCase
15
+ include Rack::Test::Methods
16
+
17
+ def app
18
+ TestApp.new
19
+ end
20
+
21
+ def setup
22
+ Seojs.token = nil
23
+ end
24
+
25
+ def test_hi
26
+ get '/hi'
27
+ assert last_response.ok?
28
+ assert_equal "Hello!", last_response.body
29
+ end
30
+
31
+ def test_its_a_trap
32
+ get '/trap'
33
+ assert !last_response.ok?
34
+ end
35
+
36
+ def test_forward_without_token
37
+ Seojs.token = nil
38
+ Net::HTTP::Get.expects(:new).never
39
+ get '/hi', :_escaped_fragment_ => ''
40
+ assert last_response.ok?
41
+ end
42
+
43
+ def test_forward_with_token
44
+ Seojs.token = 'token'
45
+ Net::HTTP::Get.expects(:new)
46
+ .with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
47
+ Net::HTTP.expects(:start)
48
+ .returns(stub(:body => 'Snapshot!', :code => 200, :to_hash => {}))
49
+ get '/hi', :_escaped_fragment_ => ''
50
+ assert last_response.ok?
51
+ assert_equal 'Snapshot!', last_response.body
52
+ end
53
+
54
+ def test_forward_with_token_timed_out
55
+ Seojs.token = 'token'
56
+ Timeout.expects(:timeout).raises(Timeout::Error)
57
+ get '/hi', :_escaped_fragment_ => ''
58
+ assert last_response.ok?
59
+ assert_equal 'Hello!', last_response.body
60
+ end
61
+
62
+ def test_forward_headers_with_token
63
+ Seojs.token = 'token'
64
+ Net::HTTP::Get.expects(:new)
65
+ .with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
66
+ .returns({})
67
+ Net::HTTP.expects(:start)
68
+ .returns(stub(:body => 'Snapshot!', :code => 200, :to_hash => {'ETAG'=>'abc'}))
69
+ get '/hi', {:_escaped_fragment_ => ''}, {'HTTP_IF_NONE_MATCH' => '123'}
70
+ assert_include last_response.headers, 'ETAG'
71
+ assert last_response.ok?
72
+ assert_equal 'Snapshot!', last_response.body
73
+ end
74
+
75
+ def test_fallback_if_not_found
76
+ Seojs.token = 'token'
77
+ Net::HTTP::Get.expects(:new)
78
+ .with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
79
+ Net::HTTP.expects(:start)
80
+ .returns(stub(:body => 'not found...', :code => 404, :to_hash => {}))
81
+ get '/hi', :_escaped_fragment_ => ''
82
+ assert last_response.ok?
83
+ assert_equal 'Hello!', last_response.body
84
+ end
85
+
86
+ def test_forward_redirect
87
+ Seojs.token = 'token'
88
+ Net::HTTP::Get.expects(:new)
89
+ .with(equals("http://cdn.getseojs.com/snapshots/token/v3/http://example.org:80/hi?_escaped_fragment_="))
90
+ Net::HTTP.expects(:start)
91
+ .returns(stub(:body => 'somewhere else', :code => 302, :to_hash => {'Location' => 'http://google.com/'}))
92
+ get '/hi', :_escaped_fragment_ => ''
93
+ assert last_response.redirect?
94
+ follow_redirect!
95
+ assert_equal last_request.url, 'http://google.com/'
96
+ end
97
+
98
+ def test_test_url
99
+ get '/seojs/test'
100
+ assert last_response.ok?
101
+ assert_equal 'SEO.js Middleware Found!', last_response.body
102
+ end
103
+
104
+ def test_set_url
105
+ Seojs.url = "abc"
106
+ assert_equal "abc", Seojs.url
107
+ end
108
+
109
+ end
metadata CHANGED
@@ -1,23 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seojs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - getseojs.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rack-proxy
14
+ name: sinatra
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :runtime
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
@@ -25,7 +39,7 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
- name: shoulda
42
+ name: mocha
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - '>='
@@ -80,30 +94,41 @@ dependencies:
80
94
  - - ~>
81
95
  - !ruby/object:Gem::Version
82
96
  version: 1.8.7
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-console
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description: SEO.js makes your BackboneJS, AngularJS or EmberJS apps crawlable by
84
112
  Google to make them appear in search results.
85
113
  email: hello@getseojs.com
86
114
  executables: []
87
115
  extensions: []
88
116
  extra_rdoc_files:
89
- - LICENSE.txt
90
117
  - README.md
91
118
  files:
92
119
  - .document
120
+ - .travis.yml
93
121
  - Gemfile
94
122
  - Gemfile.lock
95
- - LICENSE.txt
96
123
  - README.md
97
124
  - Rakefile
98
125
  - VERSION
99
126
  - lib/seojs.rb
100
127
  - lib/seojs/middleware.rb
101
- - lib/seojs/rack/cascade.rb
102
- - lib/seojs/rack/proxy.rb
103
128
  - lib/seojs/railtie.rb
104
129
  - seojs.gemspec
105
130
  - test/helper.rb
106
- - test/test_seojs.rb
131
+ - test/test_middleware.rb
107
132
  homepage: http://github.com/seojs/seojs-ruby
108
133
  licenses:
109
134
  - MIT
data/LICENSE.txt DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2013 SEO.js
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,18 +0,0 @@
1
- require 'rack/cascade'
2
-
3
- module Seojs
4
- module Rack
5
- class Cascade < ::Rack::Cascade
6
- def call(env)
7
- result = NotFound
8
-
9
- @apps.each do |app|
10
- result = app.call(env)
11
- break if @catch.include?(result[0].to_i)
12
- end
13
-
14
- result
15
- end
16
- end
17
- end
18
- end
@@ -1,88 +0,0 @@
1
- require 'rack/proxy'
2
-
3
- module Seojs
4
- module Rack
5
- class Proxy < ::Rack::Proxy
6
-
7
- def rewrite_env(rack_env)
8
- rack_env.dup.tap do |env|
9
- env['PATH_INFO'] = "#{@backend.request_uri}/#{env['rack.url_scheme']}://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{env['PATH_INFO']}"
10
- env['SERVER_NAME'] = @backend.host
11
- env['SERVER_PORT'] = @backend.port
12
- env['HTTP_HOST'] = "#{@backend.host}:#{@backend.port}"
13
- end
14
- end
15
-
16
- # TODO: Submit PR to rack-proxy for target_response.to_hash
17
- def perform_request(env)
18
- source_request = ::Rack::Request.new(env)
19
-
20
- # Initialize request
21
- if source_request.fullpath == ""
22
- full_path = URI.parse(env['REQUEST_URI']).request_uri
23
- else
24
- full_path = source_request.fullpath
25
- end
26
-
27
- target_request = Net::HTTP.const_get(source_request.request_method.capitalize).new(full_path)
28
-
29
- # Setup headers
30
- target_request.initialize_http_header(extract_http_request_headers(source_request.env))
31
-
32
- # Setup body
33
- if target_request.request_body_permitted? && source_request.body
34
- target_request.body_stream = source_request.body
35
- target_request.content_length = source_request.content_length.to_i
36
- target_request.content_type = source_request.content_type if source_request.content_type
37
- end
38
-
39
-
40
- # Create a streaming response (the actual network communication is deferred, a.k.a. streamed)
41
- if @streaming
42
- if @backend
43
- target_response = HttpStreamingResponse.new(target_request, @backend.host, @backend.port)
44
-
45
- target_response.use_ssl = "https" == @backend.scheme
46
- else
47
- target_response = HttpStreamingResponse.new(target_request, source_request.host, source_request.port)
48
-
49
- target_response.use_ssl = "https" == source_request.scheme
50
- end
51
-
52
- triplet = [target_response.status, target_response.headers, target_response.body]
53
- else
54
- host = (@backend && @backend.host) || source_request.host
55
- port = (@backend && @backend.port) || source_request.port
56
- target_response = Net::HTTP.start(host, port) do |http|
57
- http.request(target_request)
58
- end
59
-
60
- if target_response.respond_to?(:headers)
61
- headers = target_response.headers
62
- elsif target_response.respond_to?(:to_hash)
63
- headers = target_response.to_hash
64
- else
65
- headers = {}
66
- end
67
-
68
- body = target_response.body
69
- body = [body] unless body.respond_to?(:each)
70
-
71
- triplet = [target_response.code, headers, body]
72
- end
73
-
74
- triplet
75
- end
76
-
77
-
78
- def call(env)
79
- Timeout.timeout(10) do
80
- return super(env)
81
- end
82
- rescue Exception => e
83
- [500, {}, [e.to_s]]
84
- end
85
-
86
- end
87
- end
88
- end
data/test/test_seojs.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestSeojs < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end