diff --git a/lib/user-agent.rb b/lib/modern-user-agent.rb similarity index 94% rename from lib/user-agent.rb rename to lib/modern-user-agent.rb index 73710ce..0033f4f 100644 --- a/lib/user-agent.rb +++ b/lib/modern-user-agent.rb @@ -21,5 +21,5 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ -require 'user-agent/agent' -require 'user-agent/version' \ No newline at end of file +require 'modern-user-agent/agent' +require 'modern-user-agent/version' \ No newline at end of file diff --git a/lib/user-agent/agent.rb b/lib/modern-user-agent/agent.rb similarity index 70% rename from lib/user-agent/agent.rb rename to lib/modern-user-agent/agent.rb index 9628164..29e66b8 100644 --- a/lib/user-agent/agent.rb +++ b/lib/modern-user-agent/agent.rb @@ -1,4 +1,3 @@ - class Agent ## @@ -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 @@ -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 @@ -118,8 +119,10 @@ 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' @@ -127,7 +130,7 @@ def self.os_for_user_agent string 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 @@ -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 diff --git a/lib/modern-user-agent/version.rb b/lib/modern-user-agent/version.rb new file mode 100644 index 0000000..f98a6aa --- /dev/null +++ b/lib/modern-user-agent/version.rb @@ -0,0 +1,3 @@ +class Agent + VERSION = '1.2.0' +end diff --git a/lib/user-agent/version.rb b/lib/user-agent/version.rb deleted file mode 100644 index 96bdd03..0000000 --- a/lib/user-agent/version.rb +++ /dev/null @@ -1,4 +0,0 @@ - -class Agent - VERSION = '1.0.0' -end diff --git a/modern-user-agent.gemspec b/modern-user-agent.gemspec new file mode 100644 index 0000000..52dabbd --- /dev/null +++ b/modern-user-agent.gemspec @@ -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 = "tj@vision-media.ca" + 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 diff --git a/user-agent.gemspec b/user-agent.gemspec deleted file mode 100644 index 513934d..0000000 --- a/user-agent.gemspec +++ /dev/null @@ -1,30 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{user-agent} - s.version = "1.0.0" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = ["TJ Holowaychuk"] - s.date = %q{2009-10-08} - s.description = %q{User agent parser} - s.email = %q{tj@vision-media.ca} - s.extra_rdoc_files = ["README.rdoc", "lib/user-agent.rb", "lib/user-agent/agent.rb", "lib/user-agent/version.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"] - s.files = ["History.rdoc", "Manifest", "README.rdoc", "Rakefile", "lib/user-agent.rb", "lib/user-agent/agent.rb", "lib/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", "user-agent.gemspec"] - s.homepage = %q{} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "User-agent", "--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{user-agent} - s.rubygems_version = %q{1.3.5} - s.summary = %q{User agent parser} - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - else - end - else - end -end