rack-bouncer 1.4.1 → 1.4.2

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/Rakefile CHANGED
@@ -40,10 +40,18 @@ namespace :gem do
40
40
  jeweler { |gem_file| system "gem push #{gem_file}"}
41
41
  end
42
42
 
43
+ desc "Tags and pushes the current version to GitHub"
44
+ task :tag do
45
+ puts "==> Tagging and pushing to GitHub"
46
+ system "git tag -a v#{Rack::Bouncer::VERSION} -m 'Tag v#{Rack::Bouncer::VERSION}'"
47
+ system "git push --tags"
48
+ end
49
+
43
50
  desc "Builds, pushes, and cleans a gem for the current project"
44
51
  task :release do
45
52
  Rake::Task["gem:build"].invoke
46
53
  Rake::Task["gem:push"].invoke
54
+ Rake::Task["gem:tag"].invoke
47
55
  Rake::Task["gem:clean"].invoke
48
56
  end
49
57
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Rack
4
4
  class Bouncer
5
- VERSION = "1.4.1"
5
+ VERSION = "1.4.2"
6
6
 
7
7
  DEFAULT_OPTIONS = {
8
8
  :safe_paths => [],
@@ -0,0 +1,59 @@
1
+ require "test_helper"
2
+
3
+ class Rack::Bouncer::GoogleCrawlersTest < MiniTest::Unit::TestCase
4
+ def test_allows_googlebot
5
+ request = create_request
6
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:googlebot])
7
+ assert_equal 200, response.status
8
+ assert_equal "Hi Internets!", response.body
9
+ end
10
+
11
+ def test_allows_googlebot_news
12
+ request = create_request
13
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:googlebot_news])
14
+ assert_equal 200, response.status
15
+ assert_equal "Hi Internets!", response.body
16
+ end
17
+
18
+ def test_allows_googlebot_images
19
+ request = create_request
20
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:googlebot_images])
21
+ assert_equal 200, response.status
22
+ assert_equal "Hi Internets!", response.body
23
+ end
24
+
25
+ def test_allows_googlebot_video
26
+ request = create_request
27
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:googlebot_video])
28
+ assert_equal 200, response.status
29
+ assert_equal "Hi Internets!", response.body
30
+ end
31
+
32
+ def test_allows_googlebot_mobile
33
+ request = create_request
34
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:googlebot_mobile])
35
+ assert_equal 200, response.status
36
+ assert_equal "Hi Internets!", response.body
37
+ end
38
+
39
+ def test_allows_google_mobile_adsense
40
+ request = create_request
41
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:google_mobile_adsense])
42
+ assert_equal 200, response.status
43
+ assert_equal "Hi Internets!", response.body
44
+ end
45
+
46
+ def test_allows_google_adsense
47
+ request = create_request
48
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:google_adsense])
49
+ assert_equal 200, response.status
50
+ assert_equal "Hi Internets!", response.body
51
+ end
52
+
53
+ def test_allows_google_adsbot
54
+ request = create_request
55
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:google_adsbot])
56
+ assert_equal 200, response.status
57
+ assert_equal "Hi Internets!", response.body
58
+ end
59
+ end
@@ -0,0 +1,10 @@
1
+ require "test_helper"
2
+
3
+ class Rack::Bouncer::MicrosoftCrawlersTest < MiniTest::Unit::TestCase
4
+ def test_allows_bingbot
5
+ request = create_request
6
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:bingbot])
7
+ assert_equal 200, response.status
8
+ assert_equal "Hi Internets!", response.body
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ require "test_helper"
2
+
3
+ class Rack::Bouncer::YahooCrawlersTest < MiniTest::Unit::TestCase
4
+ def test_allows_yahoo_slurp
5
+ request = create_request
6
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:yahoo_slurp])
7
+ assert_equal 200, response.status
8
+ assert_equal "Hi Internets!", response.body
9
+ end
10
+
11
+ def test_allows_yahoo_slurp_china
12
+ request = create_request
13
+ response = request.get("/", "HTTP_USER_AGENT" => USER_AGENTS[:yahoo_slurp_china])
14
+ assert_equal 200, response.status
15
+ assert_equal "Hi Internets!", response.body
16
+ end
17
+ end
@@ -3,7 +3,7 @@ require "test_helper"
3
3
 
4
4
  class Rack::BouncerTest < MiniTest::Unit::TestCase
5
5
  def test_version
6
- assert_equal "1.4.1", Rack::Bouncer::VERSION
6
+ assert_equal "1.4.2", Rack::Bouncer::VERSION
7
7
  end
8
8
 
9
9
  # Default Options
@@ -50,7 +50,7 @@ class Rack::BouncerTest < MiniTest::Unit::TestCase
50
50
  assert_equal "Hi Internets!", response.body
51
51
  end
52
52
 
53
- # Redirects
53
+ # :redirect
54
54
  #################################################################################################
55
55
 
56
56
  def test_redirects_to_default
@@ -74,8 +74,7 @@ class Rack::BouncerTest < MiniTest::Unit::TestCase
74
74
  assert_equal response.location, "https://www.google.com/chrome"
75
75
  end
76
76
 
77
-
78
- # Safe Paths
77
+ # :safe_paths
79
78
  #################################################################################################
80
79
 
81
80
  def test_allows_redirect_path
@@ -80,6 +80,26 @@
80
80
  :firefox_10_0_a4:
81
81
  Mozilla/6.0 (Macintosh; I; Intel Mac OS X 11_7_9; rv:1.9b4) Gecko/2012010317 Firefox/10.0a4
82
82
 
83
+ # Google Crawlers
84
+ ###################################################################################################
85
+
86
+ :googlebot:
87
+ Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
88
+ :googlebot_news:
89
+ Googlebot-News
90
+ :googlebot_images:
91
+ Googlebot-Image/1.0
92
+ :googlebot_video:
93
+ Googlebot-Video/1.0
94
+ :googlebot_mobile:
95
+ (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)
96
+ :google_mobile_adsense:
97
+ (compatible; Mediapartners-Google/2.1; +http://www.google.com/bot.html)
98
+ :google_adsense:
99
+ Mediapartners-Google
100
+ :google_adsbot:
101
+ AdsBot-Google (+http://www.google.com/adsbot.html)
102
+
83
103
  # Internet Explorer
84
104
  ###################################################################################################
85
105
 
@@ -96,6 +116,12 @@
96
116
  :ie_9_0:
97
117
  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
98
118
 
119
+ # Microsoft Crawlers
120
+ ###################################################################################################
121
+
122
+ :bingbot:
123
+ Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
124
+
99
125
  # Mozilla
100
126
  ###################################################################################################
101
127
 
@@ -131,3 +157,11 @@
131
157
  Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1 Safari/534.52.7
132
158
  :safari_5_1_2:
133
159
  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7
160
+
161
+ # Yahoo! Crawlers
162
+ ###################################################################################################
163
+
164
+ :yahoo_slurp:
165
+ Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
166
+ :yahoo_slurp_china:
167
+ Mozilla/5.0 (compatible; Yahoo! Slurp China; http://misc.yahoo.com.cn/help.html)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-bouncer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 1
10
- version: 1.4.1
9
+ - 2
10
+ version: 1.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Julio Cesar Ody
@@ -74,8 +74,11 @@ files:
74
74
  - test/lib/rack/bouncer/aol_test.rb
75
75
  - test/lib/rack/bouncer/chrome_test.rb
76
76
  - test/lib/rack/bouncer/firefox_test.rb
77
+ - test/lib/rack/bouncer/google_crawlers_test.rb
77
78
  - test/lib/rack/bouncer/ie_test.rb
79
+ - test/lib/rack/bouncer/microsoft_crawlers_test.rb
78
80
  - test/lib/rack/bouncer/safari_test.rb
81
+ - test/lib/rack/bouncer/yahoo_crawlers_test.rb
79
82
  - test/lib/rack/bouncer_test.rb
80
83
  - test/test_helper.rb
81
84
  - test/user_agents.yml