browser_sniffer 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3b9d90e3c5dd24f14d794ad1e89ef205b6db0cef
4
+ data.tar.gz: 9a11c71c5520be24b4e5a6ac15dcc6a03b2ceede
5
+ SHA512:
6
+ metadata.gz: 15cb7c9f9a9feba942918b415f0789bf1a820268508d6281b8e2b00ac04b3d56f233501cd3bca1793ca605f5cb321329f5dbaeb2dcc4ecc22bf6f1487994ae15
7
+ data.tar.gz: ca138b97ef8a805048106958f2a0013fa93b6d0ec83a55c5081ec0da263df279a34e489ef548e85b6e73658b54cb97ce7d57658c97f81ae494a493a89889df59
@@ -1,4 +1,3 @@
1
- require File.expand_path("../.gemspec", __FILE__)
2
1
  require File.expand_path("../lib/browser_sniffer/version", __FILE__)
3
2
 
4
3
  Gem::Specification.new do |spec|
@@ -6,15 +5,15 @@ Gem::Specification.new do |spec|
6
5
  spec.version = BrowserSniffer::VERSION
7
6
  spec.authors = ["Shopify"]
8
7
  spec.email = ["gems@shopify.com"]
9
- spec.description = readme.description
10
- spec.summary = readme.summary
8
+ spec.description = "Parses user agent strings and boils it all down to a few simple classifications."
9
+ spec.summary = "Parses user agent strings and boils it all down to a few simple classifications."
11
10
  spec.homepage = "https://github.com/Shopify/browser_sniffer"
12
11
  spec.licenses = %W[GPLv2 MIT]
13
12
 
14
- spec.files = files
15
- spec.executables = files.executables
16
- spec.test_files = files.tests
17
- spec.require_paths = files.requires
13
+ spec.files = `git ls-files`.split("\n")
14
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ spec.require_paths = ["lib"]
18
17
 
19
18
  spec.required_ruby_version = ">= 1.9.3"
20
19
 
@@ -34,6 +34,7 @@ class BrowserSniffer
34
34
  'NT 6.0' => 'Vista',
35
35
  'NT 6.1' => '7',
36
36
  'NT 6.2' => '8',
37
+ 'NT 6.3' => '8.1',
37
38
  'ARM' => 'RT'
38
39
  }
39
40
  }
@@ -59,6 +60,8 @@ class BrowserSniffer
59
60
  ], [:name, :version, :major], [
60
61
  /(?:ms|\()(ie)\s((\d+)?[\w\.]+)/i # Internet Explorer
61
62
  ], [:name, :version, :major, [:type, :ie]], [
63
+ /Mozilla\/5.0.*Windows NT 6\.\d.*Trident\/7\.\d.*rv:(\d+)\.\d*/i #IE11 on Win7
64
+ ], [:major, [:version, 7], [:name, 'Internet Explorer'], [:type, :ie]], [
62
65
  # Webkit/KHTML based
63
66
  /(rekonq)\/?((\d+)[\w\.]+)*/i, # Rekonq
64
67
  /(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i # Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt
@@ -77,6 +80,8 @@ class BrowserSniffer
77
80
  /((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i # Chrome for Android/iOS
78
81
  ], [[:name, 'Chrome'], :version, :major, [:type, :chrome]], [
79
82
  /version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i # Mobile Safari
83
+ ], [:version, :major, [:name, 'Mobile Safari'], [:type, :safari]], [
84
+ /Mozilla\/5.0 \(iPhone;(.*)AppleWebKit\/((\d+)?[\w\.]+).+?(mobile)\/\w?/i # ios webview
80
85
  ], [:version, :major, [:name, 'Mobile Safari'], [:type, :safari]], [
81
86
  /version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i # Safari & Safari Mobile
82
87
  ], [:version, :major, :name, [:type, :safari]], [
@@ -1,3 +1,3 @@
1
1
  class BrowserSniffer
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -20,6 +20,10 @@ class BrowserSniffer
20
20
  browser == :ie && major_browser_version == 8
21
21
  end
22
22
 
23
+ def ie11?
24
+ browser == :ie && major_browser_version == 11
25
+ end
26
+
23
27
  def handheld?
24
28
  form_factor == :handheld
25
29
  end
@@ -134,7 +138,7 @@ class BrowserSniffer
134
138
  result[field[0]] = field[1]
135
139
  elsif field[1].class == Hash
136
140
  if field[1][match[index + 1]]
137
- result[field[0]] = field[1][match[index + 1]]
141
+ result[field[0]] = field[1][match[index + 1]]
138
142
  else
139
143
  result[field[0]] = match[index + 1]
140
144
  end
@@ -381,6 +381,20 @@ class BrowserSnifferTest < MiniTest::Unit::TestCase
381
381
  :browser => :safari,
382
382
  :major_browser_version => 5
383
383
  },
384
+ :iphone_ios7_webview => {
385
+ :user_agent => "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11A465",
386
+ :form_factor => :handheld,
387
+ :ios? => true,
388
+ :android? => false,
389
+ :desktop? => false,
390
+ :engine => :webkit,
391
+ :major_engine_version => 537,
392
+ :os => :ios,
393
+ :os_version => '7.0',
394
+ :browser => :safari,
395
+ :browser_name => 'Mobile Safari',
396
+ :major_browser_version => 537
397
+ },
384
398
  :ipad_ios5 => {
385
399
  :user_agent => "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3",
386
400
  :form_factor => :tablet,
@@ -400,6 +414,7 @@ class BrowserSnifferTest < MiniTest::Unit::TestCase
400
414
  :ios? => false,
401
415
  :android? => false,
402
416
  :desktop? => true,
417
+ :ie11? => false,
403
418
  :engine => nil,
404
419
  :major_engine_version => nil,
405
420
  :os => :mac,
@@ -407,15 +422,58 @@ class BrowserSnifferTest < MiniTest::Unit::TestCase
407
422
  :browser => nil,
408
423
  :browser_name => 'Excel',
409
424
  :major_browser_version => 14
425
+ },
426
+ :win7_ie11 => {
427
+ :user_agent => "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko",
428
+ :form_factor => :desktop,
429
+ :ios? => false,
430
+ :ie11? => true,
431
+ :android? => false,
432
+ :desktop? => true,
433
+ :engine => :trident,
434
+ :major_engine_version => 7,
435
+ :os => :windows,
436
+ :os_version => "7",
437
+ :browser => :ie,
438
+ :major_browser_version => 11
439
+ },
440
+ :win8_ie11 => {
441
+ :user_agent => "Mozilla/5.0 (Windows NT 6.2; Trident/7.0; rv:11.0) like Gecko",
442
+ :form_factor => :desktop,
443
+ :ios? => false,
444
+ :ie11? => true,
445
+ :android? => false,
446
+ :desktop? => true,
447
+ :engine => :trident,
448
+ :major_engine_version => 7,
449
+ :os => :windows,
450
+ :os_version => "8",
451
+ :browser => :ie,
452
+ :major_browser_version => 11
453
+ },
454
+ :win8_1_ie11 => {
455
+ :user_agent => "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko",
456
+ :form_factor => :desktop,
457
+ :ios? => false,
458
+ :ie11? => true,
459
+ :android? => false,
460
+ :desktop? => true,
461
+ :engine => :trident,
462
+ :major_engine_version => 7,
463
+ :os => :windows,
464
+ :os_version => "8.1",
465
+ :browser => :ie,
466
+ :major_browser_version => 11
410
467
  }
411
468
  }
412
469
 
413
470
  AGENTS.each do |agent, attributes|
414
- define_method "test_sniff_#{agent}_corrently" do
471
+ define_method "test_sniff_#{agent}_correctly" do
415
472
  sniffer = BrowserSniffer.new(attributes[:user_agent])
416
473
  attributes.reject{|attr| attr == :user_agent}.each do |attribute, value|
417
474
  assert_equal value, sniffer.send(attribute), "#{attribute.to_s} did not match"
418
475
  end
419
476
  end
420
477
  end
478
+
421
479
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browser_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Shopify
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-20 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: Parses user agent strings and boils it all down to a few simple classifications.
@@ -50,9 +45,8 @@ executables: []
50
45
  extensions: []
51
46
  extra_rdoc_files: []
52
47
  files:
53
- - .gemspec.rb
54
- - .gitignore
55
- - .travis.yml
48
+ - ".gitignore"
49
+ - ".travis.yml"
56
50
  - Gemfile
57
51
  - LICENSE.txt
58
52
  - README.md
@@ -68,31 +62,27 @@ homepage: https://github.com/Shopify/browser_sniffer
68
62
  licenses:
69
63
  - GPLv2
70
64
  - MIT
65
+ metadata: {}
71
66
  post_install_message:
72
67
  rdoc_options: []
73
68
  require_paths:
74
69
  - lib
75
70
  required_ruby_version: !ruby/object:Gem::Requirement
76
- none: false
77
71
  requirements:
78
- - - ! '>='
72
+ - - ">="
79
73
  - !ruby/object:Gem::Version
80
74
  version: 1.9.3
81
75
  required_rubygems_version: !ruby/object:Gem::Requirement
82
- none: false
83
76
  requirements:
84
- - - ! '>='
77
+ - - ">="
85
78
  - !ruby/object:Gem::Version
86
79
  version: '0'
87
- segments:
88
- - 0
89
- hash: 2435126936972094184
90
80
  requirements: []
91
81
  rubyforge_project:
92
- rubygems_version: 1.8.25
82
+ rubygems_version: 2.2.0
93
83
  signing_key:
94
- specification_version: 3
95
- summary: ! '## Description'
84
+ specification_version: 4
85
+ summary: Parses user agent strings and boils it all down to a few simple classifications.
96
86
  test_files:
97
87
  - test/browser_sniffer_test.rb
98
88
  - test/test_helper.rb
data/.gemspec.rb DELETED
@@ -1,51 +0,0 @@
1
- class Readme < String
2
- attr_reader :path
3
-
4
- def initialize(path)
5
- @path = path
6
- super(File.read(self.path))
7
- end
8
-
9
- def summary
10
- if self =~ /^# (?:\S+)\s+(.+?)\s{2,}/m
11
- scrub $1
12
- else
13
- raise "could not find summary in #{path}"
14
- end
15
- end
16
-
17
- def description
18
- if self =~ /^## Description\s+(.+?)\s{2,}/m
19
- scrub $1
20
- else
21
- raise "could not find description in #{path}"
22
- end
23
- end
24
-
25
- private
26
- def scrub(string)
27
- string.delete("\\`").gsub(/\[([^\]]+)\]\([^)]*\)/, "\\1").tr("\n", " ").to_s
28
- end
29
- end
30
-
31
- class Files < Array
32
- def executables
33
- grep(%r{^bin/}) { |f| File.basename(f) }
34
- end
35
-
36
- def requires
37
- ["lib"]
38
- end
39
-
40
- def tests
41
- grep(%r{^(test|spec|features)/})
42
- end
43
- end
44
-
45
- def files
46
- @files ||= Files.new(`git ls-files`.split($/))
47
- end
48
-
49
- def readme(path = File.expand_path("./README.md"))
50
- (@readmes ||= {})[path] ||= Readme.new(path)
51
- end