useragent 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57ea2b0443f5668ef48faaa64c211ae77f8da3bd
4
- data.tar.gz: 2724e6d003fa5f8233f1ccc05067944ae4792f15
3
+ metadata.gz: f2754f847309df982314904e199ceb1a2330ee16
4
+ data.tar.gz: 9f51e5fd8fa695b019bd689460944a97aa633517
5
5
  SHA512:
6
- metadata.gz: 29b3a9b05288a5d4ccd5a25a2849c1fe905d971996873eb2f77cf1ab3e74ef27581b18cc44b5727e47d251b1b750bb37b20711cfdf2cd2079e1b161a143f10d3
7
- data.tar.gz: 2293b7b8c6026843c7c57e347c2deb919f050962a09af8f9572b15e86378b06985a33a0ecd337fcbdc69ec39caad352a8866429548e92b97bb377d47f782141f
6
+ metadata.gz: e1287809659ebbf180b230f8145e11532266db9cd7af33db141f40de75fa459921a68bac3e512ed00fcd3389f845022632ab7733ed42fdc743b6be5133a01f79
7
+ data.tar.gz: 3ddbef57e44135b8e83479c2bf4d0e55912e01e4d2d1575e69001c5b5c97054d2d865e1c31fcd9a3064ce09723cb6715e87e0dc2431913f9f3b69e04f590e97a
@@ -18,13 +18,12 @@ class UserAgent
18
18
  string = DEFAULT_USER_AGENT
19
19
  end
20
20
 
21
- agents = []
21
+ agents = Browsers::Base.new
22
22
  while m = string.to_s.match(MATCHER)
23
23
  agents << new(m[1], m[2], m[4])
24
24
  string = string[m[0].length..-1].strip
25
25
  end
26
26
  Browsers.extend(agents)
27
- agents
28
27
  end
29
28
 
30
29
  attr_reader :product, :version, :comment
@@ -1,4 +1,4 @@
1
- require 'user_agent/browsers/all'
1
+ require 'user_agent/browsers/base'
2
2
  require 'user_agent/browsers/chrome'
3
3
  require 'user_agent/browsers/gecko'
4
4
  require 'user_agent/browsers/internet_explorer'
@@ -18,10 +18,10 @@ class UserAgent
18
18
  end
19
19
 
20
20
  def self.extend(array)
21
- array.extend(All)
22
21
  all.each do |extension|
23
- return array.extend(extension) if extension.extend?(array)
22
+ return extension.new(array) if extension.extend?(array)
24
23
  end
24
+ array
25
25
  end
26
26
  end
27
27
  end
@@ -1,6 +1,6 @@
1
1
  class UserAgent
2
2
  module Browsers
3
- module All
3
+ class Base < Array
4
4
  include Comparable
5
5
 
6
6
  def <=>(other)
@@ -1,6 +1,6 @@
1
1
  class UserAgent
2
2
  module Browsers
3
- module Chrome
3
+ class Chrome < Base
4
4
  def self.extend?(agent)
5
5
  agent.detect { |useragent|
6
6
  useragent.product == 'Chrome' ||
@@ -1,6 +1,6 @@
1
1
  class UserAgent
2
2
  module Browsers
3
- module Gecko
3
+ class Gecko < Base
4
4
  def self.extend?(agent)
5
5
  agent.application && agent.application.product == "Mozilla"
6
6
  end
@@ -1,6 +1,6 @@
1
1
  class UserAgent
2
2
  module Browsers
3
- module InternetExplorer
3
+ class InternetExplorer < Base
4
4
  def self.extend?(agent)
5
5
  agent.application &&
6
6
  agent.application.comment &&
@@ -1,6 +1,6 @@
1
1
  class UserAgent
2
2
  module Browsers
3
- module Opera
3
+ class Opera < Base
4
4
  def self.extend?(agent)
5
5
  (agent.first && agent.first.product == 'Opera') ||
6
6
  (agent.application && agent.application.product == 'Opera')
@@ -1,6 +1,6 @@
1
1
  class UserAgent
2
2
  module Browsers
3
- module Webkit
3
+ class Webkit < Base
4
4
  def self.extend?(agent)
5
5
  agent.detect { |useragent| useragent.product == 'AppleWebKit' }
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: useragent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Peek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-15 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -47,7 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - lib/user_agent.rb
49
49
  - lib/user_agent/browsers.rb
50
- - lib/user_agent/browsers/all.rb
50
+ - lib/user_agent/browsers/base.rb
51
51
  - lib/user_agent/browsers/chrome.rb
52
52
  - lib/user_agent/browsers/gecko.rb
53
53
  - lib/user_agent/browsers/internet_explorer.rb