Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Windows 8.0, 8.1. And Internet Explorer 11 #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/user-agent.rb → lib/modern-user-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++

require 'user-agent/agent'
require 'user-agent/version'
require 'modern-user-agent/agent'
require 'modern-user-agent/version'
36 changes: 20 additions & 16 deletions lib/user-agent/agent.rb → lib/modern-user-agent/agent.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

class Agent

##
Expand Down Expand Up @@ -89,11 +88,12 @@ def self.engine_version_for_user_agent string

def self.version_for_user_agent string
case name = name_for_user_agent(string)
when :Chrome ; $1 if string =~ /chrome\/([\d\w\.\-]+)/i
when :Safari ; $1 if string =~ /version\/([\d\w\.\-]+)/i
when :PS3 ; $1 if string =~ /([\d\w\.\-]+)\)\s*$/i
when :PSP ; $1 if string =~ /([\d\w\.\-]+)\)?\s*$/i
else $1 if string =~ /#{name}[\/ ]([\d\w\.\-]+)/i
when :Chrome ; $1 if string =~ /chrome\/([\d\w\.\-]+)/i
when :Safari ; $1 if string =~ /version\/([\d\w\.\-]+)/i
when :PS3 ; $1 if string =~ /([\d\w\.\-]+)\)\s*$/i
when :'Internet Explorer' ; "#{$1}.#{$2}" if string =~ /rv:(\d+).(\d+)/i
when :PSP ; $1 if string =~ /([\d\w\.\-]+)\)?\s*$/i
else $1 if string =~ /#{name}[\/ ]([\d\w\.\-]+)/i
end
end

Expand All @@ -102,14 +102,15 @@ def self.version_for_user_agent string

def self.engine_for_user_agent string
case string
when /webkit/i ; :webkit
when /khtml/i ; :khtml
when /konqueror/i ; :konqueror
when /chrome/i ; :chrome
when /presto/i ; :presto
when /gecko/i ; :gecko
when /msie/i ; :msie
else :unknown
when /webkit/i ; :webkit
when /khtml/i ; :khtml
when /konqueror/i ; :konqueror
when /chrome/i ; :chrome
when /presto/i ; :presto
when /trident\/(\d+).(\d+)/i ; :trident
when /gecko/i ; :gecko
when /msie/i ; :msie
else :unknown
end
end

Expand All @@ -118,16 +119,18 @@ def self.engine_for_user_agent string

def self.os_for_user_agent string
case string
when /windows nt 6\.3/i ; :'Windows 8.1'
when /windows nt 6\.2/i ; :'Windows 8'
when /windows nt 6\.1/i ; :'Windows 7'
when /windows nt 6\.0/i ; :'Windows Vista'
when /windows nt 6\.\d+/i ; :'Windows 7'
when /windows nt 5\.2/i ; :'Windows 2003'
when /windows nt 5\.1/i ; :'Windows XP'
when /windows nt 5\.0/i ; :'Windows 2000'
when /os x (\d+)[._](\d+)/i ; :"OS X #{$1}.#{$2}"
when /linux/i ; :Linux
when /wii/i ; :Wii
when /playstation 3/i ; :Playstation
when /playstation portable/i ; :Playstation
when /playstation portable/i ; :'Playstation Portable'
else ; :Unknown
end
end
Expand All @@ -140,6 +143,7 @@ def self.name_for_user_agent string
when /konqueror/i ; :Konqueror
when /chrome/i ; :Chrome
when /safari/i ; :Safari
when /trident\/(\d+).(\d+)/i ; :'Internet Explorer'
when /msie/i ; :IE
when /opera/i ; :Opera
when /playstation 3/i ; :PS3
Expand Down
3 changes: 3 additions & 0 deletions lib/modern-user-agent/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Agent
VERSION = '1.2.0'
end
4 changes: 0 additions & 4 deletions lib/user-agent/version.rb

This file was deleted.

20 changes: 20 additions & 0 deletions modern-user-agent.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = "modern-user-agent"
s.version = "1.2.0"

s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = [ "TJ Holowaychuk", "Alex Reed" ]
s.date = "2013-10-08"
s.description = "User Agent parser. Fixed version of the gem 'UserAgent', works on new versions of Windows and Internet Explorer."
s.email = "[email protected]"
s.extra_rdoc_files = [ "README.rdoc", "lib/modern-user-agent.rb", "lib/modern-user-agent/agent.rb", "lib/modern-user-agent/version.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake" ]
s.files = [ "History.rdoc", "Manifest", "README.rdoc", "Rakefile", "lib/modern-user-agent.rb", "lib/modern-user-agent/agent.rb", "lib/modern-user-agent/version.rb", "spec/agent_spec.rb", "spec/agents_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "modern-user-agent.gemspec" ]
s.homepage = ""
s.rdoc_options = [ "--line-numbers", "--inline-source", "--title", "User-agent", "--main", "README.rdoc" ]
s.require_paths = [ "lib" ]
s.rubyforge_project = "user-agent"
s.rubygems_version = "1.3.5"
s.summary = "User agent parser"
end
30 changes: 0 additions & 30 deletions user-agent.gemspec

This file was deleted.