browser_detect 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/README +0 -0
- data/Rakefile +2 -0
- data/browser_detect.gemspec +22 -0
- data/lib/browser_detect/browser_detect_helper.rb +43 -0
- data/lib/browser_detect/version.rb +3 -0
- data/lib/browser_detect.rb +2 -0
- metadata +90 -0
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/browser_detect/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "browser_detect"
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["faunzy"]
|
9
|
+
s.email = []
|
10
|
+
s.homepage = "http://rubygems.org/gems/browser_detect"
|
11
|
+
s.summary = "Detects the client's browser"
|
12
|
+
s.description = "Client browser detector"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "browser_detect"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
21
|
+
s.require_path = 'lib'
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module BrowserDetect
|
2
|
+
module BrowserDetectHelper
|
3
|
+
|
4
|
+
def browser_is? name
|
5
|
+
|
6
|
+
name = name.to_s.strip
|
7
|
+
|
8
|
+
return true if browser_name == name
|
9
|
+
return true if name == 'mozilla' && browser_name == 'gecko'
|
10
|
+
return true if name == 'ie' && browser_name.index('ie')
|
11
|
+
return true if name == 'webkit' && browser_name == ('safari' or 'chrome' or 'iphone' or 'ipad')
|
12
|
+
end
|
13
|
+
|
14
|
+
def browser_name
|
15
|
+
@browser_name ||= begin
|
16
|
+
|
17
|
+
ua = request.env['HTTP_USER_AGENT'].downcase
|
18
|
+
|
19
|
+
if ua.index('msie') && !ua.index('opera') && !ua.index('webtv')
|
20
|
+
'ie'+ua[ua.index('msie')+5].chr
|
21
|
+
elsif ua.index('gecko/')
|
22
|
+
'gecko'
|
23
|
+
elsif ua.index('opera')
|
24
|
+
'opera'
|
25
|
+
elsif ua.index('konqueror')
|
26
|
+
'konqueror'
|
27
|
+
elsif ua.index('ipad')
|
28
|
+
'ipad'
|
29
|
+
elsif ua.index('iphone')
|
30
|
+
'iphone'
|
31
|
+
elsif ua.index('chrome/')
|
32
|
+
'chrome'
|
33
|
+
elsif ua.index('applewebkit/')
|
34
|
+
'safari'
|
35
|
+
elsif ua.index('mozilla/')
|
36
|
+
'gecko'
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: browser_detect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- faunzy
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-21 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
- rc
|
33
|
+
- 6
|
34
|
+
version: 1.0.0.rc.6
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: Client browser detector
|
38
|
+
email: []
|
39
|
+
|
40
|
+
executables: []
|
41
|
+
|
42
|
+
extensions: []
|
43
|
+
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
46
|
+
files:
|
47
|
+
- Gemfile
|
48
|
+
- README
|
49
|
+
- Rakefile
|
50
|
+
- browser_detect-0.0.1.gem
|
51
|
+
- browser_detect.gemspec
|
52
|
+
- lib/browser_detect.rb
|
53
|
+
- lib/browser_detect/browser_detect_helper.rb
|
54
|
+
- lib/browser_detect/version.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://rubygems.org/gems/browser_detect
|
57
|
+
licenses: []
|
58
|
+
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 3
|
80
|
+
- 6
|
81
|
+
version: 1.3.6
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: browser_detect
|
85
|
+
rubygems_version: 1.3.7
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Detects the client's browser
|
89
|
+
test_files: []
|
90
|
+
|