browser_detector 1.0.0

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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ = 1.0.0 2009-10-19
2
+
3
+ * Initial release.
4
+ * Moved browser detector out of the Guilded framework to its own Gem.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 C. Jason Harrelson (midas)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,106 @@
1
+ = browser_detector
2
+
3
+ http://github.com/midas/browser_detector
4
+
5
+
6
+ == DESCRIPTION
7
+
8
+ Determines the name and version of the browser currently making a request.
9
+
10
+ The browser detector uses the HTTP user agent string to determine which browser is making the current request. The detector
11
+ can determine the name, version, major version, minor version, build version and revision version of the current browser.
12
+
13
+ If using Rails, there are several view helpers available that use the BrowserDetector: g_browser_name(), g_browser_version(),
14
+ g_browser_full_name() and g_browser_is?().
15
+
16
+
17
+ == FEATURES
18
+
19
+ * Detector class that can determine the browser name and version given a user agent string.
20
+ * List of known user agents.
21
+ * List of example user agent strings for each known user agent.
22
+
23
+
24
+ == INSTALL
25
+
26
+ gem sources -a http://gemcutter.org
27
+ sudo gem install
28
+
29
+
30
+ == INSTALL FOR RAILS
31
+
32
+ Add to environment file:
33
+
34
+ config.gem "browser_detector", :version => '1.0.0', :source => 'http://gemcutter.org'
35
+
36
+
37
+ == USAGE
38
+
39
+ The following examples will assume Firefox 3.5.3 on OS/X is being used. The user agent string for Firefox 3.5.3 on OS/X is:
40
+
41
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
42
+
43
+ === Detector Class
44
+
45
+ @detector = BrowserDetector::Detector.new( request.env['HTTP_USER_AGENT'] )
46
+ puts @detector.browser_name # firefox
47
+ puts @detector.browser_version # 3.5.3
48
+ puts @detector.full_name # Firefox 3.5.3
49
+ puts @detector.browser_is? :name => :firefox, :version => '3.5.3' # true
50
+ puts @detector.browser_is? :name => :firefox, :major_version => 3, :minor_version => '5', build_version => '3' # true
51
+
52
+ === Within Rails Views
53
+
54
+ g_browser_name
55
+
56
+ <% if g_browser_name == 'firefox' %>
57
+ ...
58
+
59
+ g_browser_version
60
+
61
+ <% if g_browser_version == '3.5.3' %>
62
+ ...
63
+
64
+ g_browser_full_name
65
+
66
+ <%= g_browser_full_name # Outputs: Firefox 3.5.3 %>
67
+
68
+ g_browser_is?
69
+
70
+ <% if g_browser_is?( :name => 'firefox', :version => '3.5.3' ) %>
71
+ ...
72
+
73
+ <% if g_browser_is?( :name => 'firefox', :major_version => '3' ) %>
74
+ ...
75
+
76
+ <% if g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3 ) %>
77
+ ...
78
+
79
+ <% if g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3, :revision_version => 0 ) %>
80
+ ...
81
+
82
+
83
+ == LICENSE
84
+
85
+ (The MIT License)
86
+
87
+ Copyright (c) 2009 C. Jason Harrelson (midas)
88
+
89
+ Permission is hereby granted, free of charge, to any person obtaining
90
+ a copy of this software and associated documentation files (the
91
+ 'Software'), to deal in the Software without restriction, including
92
+ without limitation the rights to use, copy, modify, merge, publish,
93
+ distribute, sublicense, and/or sell copies of the Software, and to
94
+ permit persons to whom the Software is furnished to do so, subject to
95
+ the following conditions:
96
+
97
+ The above copyright notice and this permission notice shall be
98
+ included in all copies or substantial portions of the Software.
99
+
100
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
101
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
102
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
103
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
104
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
105
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
106
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "browser_detector"
8
+ gem.summary = %Q{Determines the name and version of the browser currently making a request.}
9
+ gem.description = %Q{Determines the name and version of the browser currently making a request.}
10
+ gem.email = "jason@lookforwardenterprises.com"
11
+ gem.homepage = "http://github.com/midas/browser_detector"
12
+ gem.authors = ["C. Jason Harrelson (midas)"]
13
+ gem.add_development_dependency "shoulda", ">= 2.10.2"
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ if File.exist?('VERSION')
47
+ version = File.read('VERSION')
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "browser_detector #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,62 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{browser_detector}
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["C. Jason Harrelson (midas)"]
12
+ s.date = %q{2010-02-03}
13
+ s.description = %q{Determines the name and version of the browser currently making a request.}
14
+ s.email = %q{jason@lookforwardenterprises.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "History.txt",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "browser_detector.gemspec",
28
+ "lib/browser_detector.rb",
29
+ "lib/browser_detector/detector.rb",
30
+ "lib/browser_detector/rails.rb",
31
+ "lib/browser_detector/rails/view_helpers.rb",
32
+ "test/browser_detector/detector_test.rb",
33
+ "test/browser_detector/rails/view_helpers_test.rb",
34
+ "test/browser_detector_test.rb",
35
+ "test/test_helper.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/midas/browser_detector}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.5}
41
+ s.summary = %q{Determines the name and version of the browser currently making a request.}
42
+ s.test_files = [
43
+ "test/browser_detector/detector_test.rb",
44
+ "test/browser_detector/rails/view_helpers_test.rb",
45
+ "test/browser_detector_test.rb",
46
+ "test/test_helper.rb"
47
+ ]
48
+
49
+ if s.respond_to? :specification_version then
50
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
54
+ s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
55
+ else
56
+ s.add_dependency(%q<shoulda>, [">= 2.10.2"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<shoulda>, [">= 2.10.2"])
60
+ end
61
+ end
62
+
@@ -0,0 +1,233 @@
1
+ module BrowserDetector
2
+
3
+ # The Detector provides the ability to determine browser information from the user
4
+ # agent string.
5
+ #
6
+ class Detector
7
+
8
+ attr_reader :ua
9
+
10
+ def initialize( user_agent )
11
+ @ua = user_agent.downcase unless user_agent.nil?
12
+ @version_regex = /(\d*)\.(\d*)\.*(\d*)\.*(\d*)/
13
+ end
14
+
15
+ # Returns true if the browser matches the options ent in, otherwise returns false.
16
+ #
17
+ # === Request
18
+ # * +request+ - The request object.
19
+ #
20
+ # === Options
21
+ # * +:name+ - The name of the browser. For example 'ie' or :ie.
22
+ # * +:version+ - The version of the browser. For example '3.0.5'.
23
+ # * +:major_version+ - The major version of the browser. For example '3' or 3.
24
+ # * +:minor_version+ - The minor version of the browser. For example '0' or 0.
25
+ #
26
+ def browser_is?( options={} )
27
+ name = options[:name]
28
+ version = options[:version]
29
+ major_version = options[:major_version]
30
+ minor_version = options[:minor_version]
31
+ build_version = options[:build_version]
32
+ revision_version = options[:revision_version]
33
+
34
+ name ||= self.browser_name
35
+ version ||= self.browser_version
36
+ major_version ||= self.browser_version_major
37
+ minor_version ||= self.browser_version_minor
38
+ build_version ||= self.browser_version_build
39
+ revision_version ||= self.browser_version_revision
40
+
41
+ name = name.to_s.strip
42
+ version = version.to_s.strip
43
+ major_version = major_version.to_s.strip
44
+ minor_version = minor_version.to_s.strip
45
+ build_version = build_version.to_s.strip
46
+ revision_version = revision_version.to_s.strip
47
+
48
+ self.browser_name == name && self.browser_version == version && self.browser_version_major == major_version &&
49
+ self.browser_version_minor == minor_version #&& self.browser_version_build == build_version &&
50
+ #self.browser_version_revision == revision_version
51
+ end
52
+
53
+ # Returns the name of the browser that is making this request. For example 'ie'.
54
+ #
55
+ # === Request
56
+ # * +request+ - The request object.
57
+ #
58
+ def browser_name
59
+ begin
60
+ @browser_name ||= begin
61
+ ua = @ua
62
+ if ua.nil?
63
+ 'unknown'
64
+ else
65
+ if ua.index( 'msie' ) && !ua.index( 'opera' ) && !ua.index( 'webtv' )
66
+ if ua.index( 'windows ce' )
67
+ 'ie' + '_ce' #+ ua[ua.index( 'msie' ) + 5].chr
68
+ else
69
+ 'ie' # + ua[ua.index( 'msie' ) + 5].chr
70
+ end
71
+ elsif ua.include?( 'opera' )
72
+ 'opera'
73
+ elsif ua.include?( 'konqueror' )
74
+ 'konqueror'
75
+ elsif ua.include?( 'applewebkit/' )
76
+ 'safari'
77
+ elsif ua.include?( 'chrome' )
78
+ 'chrome'
79
+ elsif ua.include?( 'firefox' )
80
+ 'firefox'
81
+ elsif ua.include?( 'netscape' )
82
+ 'netscape'
83
+ else
84
+ 'unknown'
85
+ end
86
+ end
87
+ end
88
+ rescue
89
+ 'unknown'
90
+ end
91
+ end
92
+
93
+ # Returns the version of the browser that is making this request. For example '7'.
94
+ #
95
+ # === Request
96
+ # * +request+ - The request object.
97
+ #
98
+ def browser_version
99
+ @browser_version ||= begin
100
+ self.send( "resolve_version_for_#{self.browser_name}".to_sym )
101
+ end
102
+ end
103
+
104
+ def browser_version_major
105
+ match = @version_regex.match( browser_version )
106
+ return match[1].to_i.to_s unless match.nil? || match.size < 2
107
+ '0'
108
+ end
109
+
110
+ def browser_version_minor
111
+ match = @version_regex.match( browser_version )
112
+ return match[2].to_i.to_s unless match.nil? || match.size < 3
113
+ '0'
114
+ end
115
+
116
+ def browser_version_build
117
+ match = @version_regex.match( browser_version )
118
+ return match[3].to_i.to_s unless match.nil? || match.size < 4 || match[3].empty? || match[3].nil?
119
+ '0'
120
+ end
121
+
122
+ def browser_version_revision
123
+ match = @version_regex.match( browser_version )
124
+ return match[4].to_i.to_s unless match.nil? || match.size < 5 || match[4].empty? || match[4].nil?
125
+ '0'
126
+ end
127
+
128
+ # Returns the browser name concatenated with the browser version. for example, 'ie7'.
129
+ #
130
+ # === Request
131
+ # * +request+ - The request object.
132
+ #
133
+ def browser_full_name
134
+ self.send( "browser_full_name_for_#{self.browser_name}".to_sym )
135
+ end
136
+
137
+ # Returns the browser name concatenated with the browser version. for example, 'ie7'.
138
+ #
139
+ # === Request
140
+ # * +request+ - The request object.
141
+ #
142
+ def browser_id
143
+ browser_name + browser_version.gsub( /\./, '' )
144
+ end
145
+
146
+ # Returns true if the current browser type can handle PNGs.
147
+ #
148
+ def can_use_png?
149
+ return browser_version.to_i >= 7 if browser_name== 'ie'
150
+ true
151
+ end
152
+
153
+ # A list of all the browser types that Guilded recognizes.
154
+ #
155
+ def self.all_browsers
156
+ %w( chrome firefox ie55 ie60 ie70 ie80 konqueror netscape opera safari )
157
+ end
158
+
159
+ # A list of all the mobile browser types that Guilded recognizes.
160
+ #
161
+ def self.all_mobile_browsers
162
+ %w( ie_ce4 iphone )
163
+ end
164
+
165
+ def self.user_agents
166
+ {
167
+ :ie55 => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)',
168
+ :ie60 => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
169
+ :ie70 => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
170
+ :ie80 => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
171
+ :firefox2 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17',
172
+ :firefox3 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.11',
173
+ :firefox35 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3',
174
+ :firefox35win => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)',
175
+ :opera10 => 'Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00',
176
+ :safari403 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.8 Safari/532.2',
177
+ :iphone3 => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7C144 Safari/528.16',
178
+ :iphone2 => 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A535b Safari/419.3',
179
+ :chrome3 => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0',
180
+ :chrome4 => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.221.8 Safari/532.2'
181
+ }
182
+ end
183
+
184
+ protected
185
+
186
+ def resolve_version_for_ie
187
+ match = /.*msie (.*); windows nt 5.1/.match( @ua )
188
+ return match.nil? ? '0' : match[1]
189
+ end
190
+
191
+ def resolve_version_for_firefox
192
+ match = /.*\((.*); u;.*firefox\/(.*) \(.net.*/.match( @ua )
193
+ if match.nil?
194
+ match = /.*\((.*); u;.*firefox\/(.*)/.match( @ua )
195
+ return match.nil? ? '0' : match[2]
196
+ end
197
+ return match.nil? ? '0' : match[2]
198
+ end
199
+
200
+ def resolve_version_for_opera
201
+ match = /.*\((.*); intel.*version\/(.*)/.match( @ua )
202
+ return match.nil? ? '0' : match[2]
203
+ end
204
+
205
+ def resolve_version_for_safari
206
+ match = /.* safari\/(.*)/.match( @ua )
207
+ rev = match.nil? ? 0 : match[1]
208
+ return case rev
209
+ when '528.16' then '4.0.0'
210
+ when '530.18' then '4.0.1'
211
+ when '530.19' then '4.0.2'
212
+ when '531.9', '532.2' then '4.0.3'
213
+ else '0.0.0.0'
214
+ end
215
+ end
216
+
217
+ def browser_full_name_for_ie
218
+ "Internet Explorer #{browser_version}"
219
+ end
220
+
221
+ def browser_full_name_for_firefox
222
+ "Firefox #{browser_version}"
223
+ end
224
+
225
+ def browser_full_name_for_opera
226
+ "Opera #{browser_version}"
227
+ end
228
+
229
+ def browser_full_name_for_safari
230
+ "Safari #{browser_version}"
231
+ end
232
+ end
233
+ end
@@ -0,0 +1,61 @@
1
+ module BrowserDetector
2
+ module Rails
3
+ module ViewHelpers
4
+
5
+ # Returns the name of the browser that is making this request. For example 'ie'. When using
6
+ # the browser detector in the contoller you may put a :g_browser_detector variabe in the session if
7
+ # you wish to keep the BrowserDetector from being instantiated more than once per request.
8
+ #
9
+ def g_browser_name
10
+ setup_detector
11
+ @g_browser_detector.browser_name
12
+ end
13
+
14
+ # Returns the version of the browser that is making this request. For example '7'. When using
15
+ # the browser detector in the contoller you may put a :g_browser_detector variabe in the session if
16
+ # you wish to keep the BrowserDetector from being instantiated more than once per request.
17
+ #
18
+ def g_browser_version
19
+ setup_detector
20
+ @g_browser_detector.browser_version
21
+ end
22
+
23
+ # Returns the full browser name. For example, 'Internet Explorer 7.0'.
24
+ #
25
+ def g_browser_full_name
26
+ setup_detector
27
+ @g_browser_detector.browser_full_name
28
+ end
29
+
30
+ # Returns the browser name concatenated with the browser version. for example, 'ie7'. When using
31
+ # the browser detector in the contoller you may put a :g_browser_detector variabe in the session if
32
+ # you wish to keep the BrowserDetector from being instantiated more than once per request.
33
+ #
34
+ def g_browser_id
35
+ setup_detector
36
+ @g_browser_detector.browser_id
37
+ end
38
+
39
+ # Returns true if the browser matches the options ent in, otherwise returns false. When using
40
+ # the browser detector in the contoller you may put a :g_browser_detector variable in the session if
41
+ # you wish to keep the Detector from being instantiated more than once per request.
42
+ #
43
+ # === Options
44
+ # * +:name+ - The name of the browser. For example 'ie'.
45
+ # * +:version+ - The version of the browser. For example '7'.
46
+ #
47
+ def g_browser_is?( options={} )
48
+ setup_detector
49
+ @g_browser_detector.browser_is?( options )
50
+ end
51
+
52
+ protected
53
+
54
+ def setup_detector
55
+ @g_browser_detector = session[:g_browser_detector] if respond_to?( :session )
56
+ @g_browser_detector ||= BrowserDetector::Detector.new( request.env['HTTP_USER_AGENT'] )
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,4 @@
1
+ module BrowserDetector
2
+ module Rails
3
+ end
4
+ end
@@ -0,0 +1,11 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'browser_detector/detector'
5
+ require 'browser_detector/rails/view_helpers'
6
+
7
+ module BrowserDetector
8
+ VERSION = '1.0.0'
9
+ end
10
+
11
+ ActionView::Base.send( :include, BrowserDetector::Rails::ViewHelpers ) if defined?( ActionView )