JamieFlournoy-UserAgent 1.0.1 → 1.0.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.
@@ -1,3 +1,7 @@
1
+ === 1.0.2 / 2009-07-28
2
+
3
+ * Added some sample user agent strings for test use.
4
+
1
5
  === 1.0.1 / 2009-07-28
2
6
 
3
7
  * Now detects Twiceler.
@@ -2,5 +2,7 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
+ UserAgent.gemspec
5
6
  lib/user_agent.rb
7
+ lib/user_agent/test.rb
6
8
  test/test_user_agent.rb
data/README.txt CHANGED
@@ -8,7 +8,9 @@ Determine whether the HTTP user agent talking to your code is a web spider.
8
8
 
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
- All you can do at this point is call UserAgent.is_spider? and pass it the user agent.
11
+ Call UserAgent.is_spider? and pass it the user agent.
12
+
13
+ UserAgent::Test::AGENT_STRINGS is a hash of sample user agent strings you can use in your tests.
12
14
 
13
15
  == SYNOPSIS:
14
16
 
@@ -21,7 +23,10 @@ And put this in your ApplicationController:
21
23
  session :off, :if => proc { |request| UserAgent.is_spider?(request.user_agent) }
22
24
 
23
25
 
24
- If you're not using Rails then just call UserAgent.is_spider? and pass it the user agent string.
26
+ If you're not using Rails then just require user_agent, then call UserAgent.is_spider? and pass it the user agent string.
27
+
28
+ If you want to use UserAgent::Test::AGENT_STRINGS, remember to require 'user_agent/test'.
29
+
25
30
 
26
31
  == REQUIREMENTS:
27
32
 
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{UserAgent}
5
+ s.version = "1.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Jamie Flournoy"]
9
+ s.date = %q{2009-07-28}
10
+ s.description = %q{Determine whether the HTTP user agent talking to your code is a web spider.}
11
+ s.email = ["jamie@pervasivecode.com"]
12
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
13
+ s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "UserAgent.gemspec", "lib/user_agent.rb", "lib/user_agent/test.rb", "test/test_user_agent.rb"]
14
+ s.homepage = %q{http://github.com/JamieFlournoy/UserAgent/}
15
+ s.rdoc_options = ["--main", "README.txt"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{useragent}
18
+ s.rubygems_version = %q{1.3.3}
19
+ s.summary = %q{Determine whether the HTTP user agent talking to your code is a web spider.}
20
+ s.test_files = ["test/test_user_agent.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
28
+ else
29
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
33
+ end
34
+ end
@@ -1,5 +1,5 @@
1
- class UserAgent
2
- VERSION = '1.0.1'
1
+ module UserAgent
2
+ VERSION = '1.0.2'
3
3
 
4
4
  def self.is_spider?(user_agent_string)
5
5
  user_agent_string =~ /(Baidu|bot|Google|SiteUptime|Slurp|Twiceler|WordPress|ZIBB|ZyBorg)/i
@@ -0,0 +1,11 @@
1
+ module UserAgent
2
+ class Test
3
+ # some sample user agent strings for use in tests.
4
+ AGENT_STRINGS = {
5
+ :googlebot => "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
6
+ :msnbot => "msnbot/1.1 (+http://search.msn.com/msnbot.htm)",
7
+ :firefox => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.12) Gecko/2009070609 Firefox/3.0.12",
8
+ :opera => "Opera/8.00 (Windows NT 5.1; U; en)"
9
+ }
10
+ end
11
+ end
@@ -1,14 +1,10 @@
1
1
  require "test/unit"
2
2
  require "user_agent"
3
+ require 'user_agent/test'
3
4
 
4
5
  class TestUserAgent < Test::Unit::TestCase
5
6
  def setup
6
- @agent_strings = {
7
- :googlebot => "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
8
- :msnbot => "msnbot/1.1 (+http://search.msn.com/msnbot.htm)",
9
- :firefox => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.12) Gecko/2009070609 Firefox/3.0.12",
10
- :opera => "Opera/8.00 (Windows NT 5.1; U; en)"
11
- }
7
+ @agent_strings = UserAgent::Test::AGENT_STRINGS
12
8
  end
13
9
 
14
10
  def test_is_spider_true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: JamieFlournoy-UserAgent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Flournoy
@@ -38,7 +38,9 @@ files:
38
38
  - Manifest.txt
39
39
  - README.txt
40
40
  - Rakefile
41
+ - UserAgent.gemspec
41
42
  - lib/user_agent.rb
43
+ - lib/user_agent/test.rb
42
44
  - test/test_user_agent.rb
43
45
  has_rdoc: false
44
46
  homepage: http://github.com/JamieFlournoy/UserAgent/