browser_sniffer 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.description = readme.description
10
10
  spec.summary = readme.summary
11
11
  spec.homepage = "https://github.com/Shopify/browser_sniffer"
12
- spec.license = "GPLv2 & MIT"
12
+ spec.licenses = %W[GPLv2 MIT]
13
13
 
14
14
  spec.files = files
15
15
  spec.executables = files.executables
@@ -20,4 +20,4 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
- end
23
+ end
@@ -96,7 +96,7 @@ class BrowserSniffer
96
96
  /(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, # Mozilla
97
97
  ], [:name, :version, :major, [:type, :firefox]], [
98
98
  # Other
99
- /(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf)[\/\s]?((\d+)?[\w\.]+)/i, # UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf
99
+ /(uc\s?browser|polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|word|excel)[\/\s]?((\d+)?[\w\.]+)/i, # UCBrowser/Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Word/Excel
100
100
  /(links)\s\(((\d+)?[\w\.]+)/i, # Links
101
101
  /(gobrowser)\/?((\d+)?[\w\.]+)*/i, # GoBrowser
102
102
  /(ice\s?browser)\/v?((\d+)?[\w\._]+)/i, # ICE Browser
@@ -136,7 +136,7 @@ class BrowserSniffer
136
136
  /(htc)[;_\s-]+([\w\s_]+(?=\))|\w+)*/i, # HTC
137
137
  /(zte)-(\w+)*/i, # ZTE
138
138
  /(alcatel|geeksphone|huawei|lenovo|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]+)*/i # Alcatel/GeeksPhone/Huawei/Lenovo/Nexian/Panasonic/Sony
139
- ], [:vendor, [:model, lambda {|str| str.gsub(/_/, ' ') }], [:type, :handheld]], [
139
+ ], [:vendor, [:model, lambda {|str| str && str.gsub(/_/, ' ') }], [:type, :handheld]], [
140
140
  /\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i, # Motorola
141
141
  /(mot)[\s-]?(\w+)*/i
142
142
  ], [[:vendor, 'Motorola'], :model, [:type, :handheld]], [
@@ -226,9 +226,9 @@ class BrowserSniffer
226
226
  /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]+)*/i # FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
227
227
  ], [:name, :version],[
228
228
  /(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i # iOS
229
- ], [[:name, 'iOS'], [:version, lambda {|str| str.gsub(/_/, '.') }], [:type, :ios]], [
229
+ ], [[:name, 'iOS'], [:version, lambda {|str| str && str.gsub(/_/, '.') }], [:type, :ios]], [
230
230
  /(mac\sos\sx)\s?([\w\s\.]+\w)*/i # Mac OS
231
- ], [:name, [:version, lambda {|str| str.gsub(/_/, '.') }], [:type, :mac]], [
231
+ ], [:name, [:version, lambda {|str| str && str.gsub(/_/, '.') }], [:type, :mac]], [
232
232
  # Other
233
233
  /(haiku)\s(\w+)/i, # Haiku
234
234
  /(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, # AIX
@@ -1,3 +1,3 @@
1
1
  class BrowserSniffer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class BrowserSnifferTest < ActiveSupport::TestCase
3
+ class BrowserSnifferTest < MiniTest::Unit::TestCase
4
4
  AGENTS = {
5
5
  :ipad_old => {
6
6
  :user_agent => "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10",
@@ -130,6 +130,7 @@ class BrowserSnifferTest < ActiveSupport::TestCase
130
130
  :os => :linux,
131
131
  :os_version => '2.6.22',
132
132
  :browser => nil,
133
+ :browser_name => 'Kindle',
133
134
  :major_browser_version => 2
134
135
  },
135
136
  :nokia_classic => {
@@ -351,6 +352,7 @@ class BrowserSnifferTest < ActiveSupport::TestCase
351
352
  :os => :ios,
352
353
  :os_version => '4.3.3',
353
354
  :browser => nil,
355
+ :browser_name => 'WebKit',
354
356
  :major_browser_version => 533
355
357
  },
356
358
  :ipod_os_4_3_3 => {
@@ -391,13 +393,27 @@ class BrowserSnifferTest < ActiveSupport::TestCase
391
393
  :os_version => '5.0',
392
394
  :browser => :safari,
393
395
  :major_browser_version => 5
396
+ },
397
+ :excel_mac => {
398
+ :user_agent => "Mozilla/5.0 (Macintosh; Intel Mac OS X) Excel/14.34.0",
399
+ :form_factor => :desktop,
400
+ :ios? => false,
401
+ :android? => false,
402
+ :desktop? => true,
403
+ :engine => nil,
404
+ :major_engine_version => nil,
405
+ :os => :mac,
406
+ :os_version => nil,
407
+ :browser => nil,
408
+ :browser_name => 'Excel',
409
+ :major_browser_version => 14
394
410
  }
395
411
  }
396
412
 
397
413
  AGENTS.each do |agent, attributes|
398
- test "sniff #{agent} correctly" do
414
+ define_method "test_sniff_#{agent}_corrently" do
399
415
  sniffer = BrowserSniffer.new(attributes[:user_agent])
400
- attributes.except(:user_agent).each do |attribute, value|
416
+ attributes.reject{|attr| attr == :user_agent}.each do |attribute, value|
401
417
  assert_equal value, sniffer.send(attribute), "#{attribute.to_s} did not match"
402
418
  end
403
419
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
- require 'active_support/all'
4
3
 
5
4
  require "#{File.dirname(__FILE__)}/../init"
6
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-19 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -66,7 +66,8 @@ files:
66
66
  - test/test_helper.rb
67
67
  homepage: https://github.com/Shopify/browser_sniffer
68
68
  licenses:
69
- - GPLv2 & MIT
69
+ - GPLv2
70
+ - MIT
70
71
  post_install_message:
71
72
  rdoc_options: []
72
73
  require_paths:
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  version: '0'
86
87
  segments:
87
88
  - 0
88
- hash: -639204093017043880
89
+ hash: 2435126936972094184
89
90
  requirements: []
90
91
  rubyforge_project:
91
92
  rubygems_version: 1.8.25