spob_browser_detector 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.1.0
@@ -1,17 +1,17 @@
1
- module SpobBrowserDetector
2
-
3
- # The Detector provides the ability to determine browser information from the user
1
+ module SpobBrowserDetector
2
+
3
+ # The Detector provides the ability to determine browser information from the user
4
4
  # agent string.
5
5
  #
6
6
  class Detector
7
-
7
+
8
8
  attr_reader :ua
9
-
9
+
10
10
  def initialize( user_agent )
11
11
  @ua = user_agent.downcase unless user_agent.nil?
12
12
  @version_regex = /(\d*)\.(\d*)\.*(\d*)\.*(\d*)/
13
13
  end
14
-
14
+
15
15
  # Returns true if the browser matches the options ent in, otherwise returns false.
16
16
  #
17
17
  # === Request
@@ -30,7 +30,7 @@ module SpobBrowserDetector
30
30
  minor_version = options[:minor_version]
31
31
  build_version = options[:build_version]
32
32
  revision_version = options[:revision_version]
33
-
33
+
34
34
  name ||= self.browser_name
35
35
  version ||= self.browser_version
36
36
  major_version ||= self.browser_version_major
@@ -44,9 +44,9 @@ module SpobBrowserDetector
44
44
  minor_version = minor_version.to_s.strip
45
45
  build_version = build_version.to_s.strip
46
46
  revision_version = revision_version.to_s.strip
47
-
47
+
48
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 &&
49
+ self.browser_version_minor == minor_version #&& self.browser_version_build == build_version &&
50
50
  #self.browser_version_revision == revision_version
51
51
  end
52
52
 
@@ -64,13 +64,13 @@ module SpobBrowserDetector
64
64
  else
65
65
  if ua.index( 'msie' ) && !ua.index( 'opera' ) && !ua.index( 'webtv' )
66
66
  if ua.index( 'windows ce' )
67
- 'ie' + '_ce' #+ ua[ua.index( 'msie' ) + 5].chr
67
+ 'ie' + '_ce' #+ ua[ua.index( 'msie' ) + 5].chr
68
68
  else
69
69
  'ie' # + ua[ua.index( 'msie' ) + 5].chr
70
70
  end
71
71
  elsif ua.include?( 'opera' )
72
72
  'opera'
73
- elsif ua.include?( 'konqueror' )
73
+ elsif ua.include?( 'konqueror' )
74
74
  'konqueror'
75
75
  elsif ua.include?( 'applewebkit/' )
76
76
  'safari'
@@ -112,19 +112,19 @@ module SpobBrowserDetector
112
112
  return match[2].to_i.to_s unless match.nil? || match.size < 3
113
113
  '0'
114
114
  end
115
-
115
+
116
116
  def browser_version_build
117
117
  match = @version_regex.match( browser_version )
118
118
  return match[3].to_i.to_s unless match.nil? || match.size < 4 || match[3].empty? || match[3].nil?
119
119
  '0'
120
120
  end
121
-
121
+
122
122
  def browser_version_revision
123
123
  match = @version_regex.match( browser_version )
124
124
  return match[4].to_i.to_s unless match.nil? || match.size < 5 || match[4].empty? || match[4].nil?
125
125
  '0'
126
126
  end
127
-
127
+
128
128
  # Returns the browser name concatenated with the browser version. for example, 'ie7'.
129
129
  #
130
130
  # === Request
@@ -133,7 +133,7 @@ module SpobBrowserDetector
133
133
  def browser_full_name
134
134
  self.send( "browser_full_name_for_#{self.browser_name}".to_sym )
135
135
  end
136
-
136
+
137
137
  # Returns the browser name concatenated with the browser version. for example, 'ie7'.
138
138
  #
139
139
  # === Request
@@ -142,7 +142,7 @@ module SpobBrowserDetector
142
142
  def browser_id
143
143
  browser_name + browser_version.gsub( /\./, '' )
144
144
  end
145
-
145
+
146
146
  # Returns true if the current browser type can handle PNGs.
147
147
  #
148
148
  def can_use_png?
@@ -159,12 +159,12 @@ module SpobBrowserDetector
159
159
  # A list of all the mobile browser types that Guilded recognizes.
160
160
  #
161
161
  def self.all_mobile_browsers
162
- %w( ie_ce4 iphone )
162
+ %w( ie_ce4 ie_ce iphone )
163
163
  end
164
-
164
+
165
165
  def self.user_agents
166
- {
167
- :ie55 => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)',
166
+ {
167
+ :ie55 => 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.1)',
168
168
  :ie60 => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)',
169
169
  :ie70 => 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
170
170
  :ie80 => 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
@@ -180,18 +180,18 @@ module SpobBrowserDetector
180
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
181
  }
182
182
  end
183
-
183
+
184
184
  protected
185
185
 
186
186
  def resolve_version_for_unknown
187
187
  '0'
188
188
  end
189
-
189
+
190
190
  def resolve_version_for_ie
191
191
  match = /.*msie (.*); windows nt 5.1/.match( @ua )
192
192
  return match.nil? ? '0' : match[1]
193
193
  end
194
-
194
+
195
195
  def resolve_version_for_firefox
196
196
  match = /.*\((.*); u;.*firefox\/(.*) \(.net.*/.match( @ua )
197
197
  if match.nil?
@@ -204,12 +204,12 @@ module SpobBrowserDetector
204
204
  def resolve_version_for_konqueror
205
205
  return '0'
206
206
  end
207
-
207
+
208
208
  def resolve_version_for_opera
209
209
  match = /.*\((.*); intel.*version\/(.*)/.match( @ua )
210
210
  return match.nil? ? '0' : match[2]
211
211
  end
212
-
212
+
213
213
  def resolve_version_for_safari
214
214
  match = /.* safari\/(.*)/.match( @ua )
215
215
  rev = match.nil? ? 0 : match[1]
@@ -221,19 +221,19 @@ module SpobBrowserDetector
221
221
  else '0.0.0.0'
222
222
  end
223
223
  end
224
-
224
+
225
225
  def browser_full_name_for_ie
226
226
  "Internet Explorer #{browser_version}"
227
227
  end
228
-
228
+
229
229
  def browser_full_name_for_firefox
230
230
  "Firefox #{browser_version}"
231
231
  end
232
-
232
+
233
233
  def browser_full_name_for_opera
234
234
  "Opera #{browser_version}"
235
235
  end
236
-
236
+
237
237
  def browser_full_name_for_safari
238
238
  "Safari #{browser_version}"
239
239
  end
@@ -242,4 +242,4 @@ module SpobBrowserDetector
242
242
  "Netscape #{browser_version}"
243
243
  end
244
244
  end
245
- end
245
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spob_browser_detector
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 31
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 3
9
- version: 1.0.3
9
+ - 4
10
+ version: 1.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - C. Jason Harrelson (midas)
@@ -21,9 +22,11 @@ dependencies:
21
22
  name: shoulda
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 35
27
30
  segments:
28
31
  - 2
29
32
  - 10
@@ -66,23 +69,27 @@ rdoc_options:
66
69
  require_paths:
67
70
  - lib
68
71
  required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
69
73
  requirements:
70
74
  - - ">="
71
75
  - !ruby/object:Gem::Version
76
+ hash: 3
72
77
  segments:
73
78
  - 0
74
79
  version: "0"
75
80
  required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
76
82
  requirements:
77
83
  - - ">="
78
84
  - !ruby/object:Gem::Version
85
+ hash: 3
79
86
  segments:
80
87
  - 0
81
88
  version: "0"
82
89
  requirements: []
83
90
 
84
91
  rubyforge_project:
85
- rubygems_version: 1.3.6
92
+ rubygems_version: 1.3.7
86
93
  signing_key:
87
94
  specification_version: 3
88
95
  summary: Determines the name and version of the browser currently making a request.