useragent_parser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'multi_json'
5
+
6
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+ # == Mock Framework
10
+ #
11
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
12
+ #
13
+ # config.mock_with :mocha
14
+ # config.mock_with :flexmock
15
+ # config.mock_with :rr
16
+ config.mock_with :rspec
17
+ end
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+ require 'useragent_parser'
5
+
6
+ describe UseragentParser do
7
+ YAML.load_file(File.expand_path(File.dirname(__FILE__)) + "/../fixtures/test_user_agent_parser.yaml")['test_cases'].each do |testcase|
8
+ it "should correctly parse the useragent header '#{testcase['user_agent_string']}'" do
9
+ js_ua = {}
10
+ if testcase['js_ua']
11
+ js_ua = eval(testcase['js_ua'].gsub("': '", "' => '")).values
12
+ end
13
+ result = UseragentParser.parse(testcase['user_agent_string'], *js_ua)
14
+ result['family'].should == testcase['family']
15
+ result['v1'].should == testcase['v1']
16
+ result['v2'].should == testcase['v2']
17
+ result['v3'].should == testcase['v3']
18
+ result['os_family'].should == testcase['os_family']
19
+ result['os_v1'].should == testcase['os_v1']
20
+ result['os_v2'].should == testcase['os_v2']
21
+ result['os_v3'].should == testcase['os_v3']
22
+ end
23
+ end
24
+
25
+ YAML.load_file(File.expand_path(File.dirname(__FILE__)) + "/../fixtures/firefox_user_agent_strings.yaml")['test_cases'].each do |testcase|
26
+ it "should correctly parse the useragent header '#{testcase['user_agent_string']}'" do
27
+ js_ua = {}
28
+ if testcase['js_ua']
29
+ js_ua = eval(testcase['js_ua'].gsub("': '", "' => '")).values
30
+ end
31
+ result = UseragentParser.parse(testcase['user_agent_string'], *js_ua)
32
+ result['family'].should == testcase['family']
33
+ result['v1'].should == testcase['v1']
34
+ result['v2'].should == testcase['v2']
35
+ result['v3'].should == testcase['v3']
36
+ end
37
+ end
38
+
39
+ YAML.load_file(File.expand_path(File.dirname(__FILE__)) + "/../fixtures/pgts_browser_list.yaml")['test_cases'].each do |testcase|
40
+ it "should correctly parse the useragent header '#{testcase['user_agent_string']}'" do
41
+ js_ua = {}
42
+ if testcase['js_ua']
43
+ js_ua = eval(testcase['js_ua'].gsub("': '", "' => '")).values
44
+ end
45
+ result = UseragentParser.parse(testcase['user_agent_string'], *js_ua)
46
+ result['family'].should == testcase['family']
47
+ result['v1'].should == testcase['v1']
48
+ result['v2'].should == testcase['v2']
49
+ result['v3'].should == testcase['v3']
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "useragent_parser/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "useragent_parser"
7
+ s.version = UseragentParser::VERSION
8
+ s.authors = ["Morton Jonuschat"]
9
+ s.email = ["yabawock@gmail.com"]
10
+ s.homepage = "https://github.com/yabawock/useragent_parser"
11
+ s.summary = %q{A library to extract informtion from Useragent headers}
12
+ s.description = %q{UseragentParser extracts browser and operating system information from the headers sent by most browsers and email clients}
13
+
14
+ s.rubyforge_project = "useragent_parser"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_development_dependency "rake", "~> 0.9.0"
23
+ s.add_development_dependency "rspec", "~> 2.6.0"
24
+ s.add_development_dependency "multi_json", "~> 1.0.1"
25
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: useragent_parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Morton Jonuschat
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-22 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70136153366660 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70136153366660
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70136153364760 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70136153364760
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &70136153362640 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.1
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70136153362640
47
+ description: UseragentParser extracts browser and operating system information from
48
+ the headers sent by most browsers and email clients
49
+ email:
50
+ - yabawock@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - config/user_agent_parser.yaml
61
+ - lib/useragent_parser.rb
62
+ - lib/useragent_parser/parser.rb
63
+ - lib/useragent_parser/version.rb
64
+ - spec/fixtures/firefox_user_agent_strings.yaml
65
+ - spec/fixtures/pgts_browser_list.yaml
66
+ - spec/fixtures/test_user_agent_parser.yaml
67
+ - spec/spec_helper.rb
68
+ - spec/useragent_parser/useragent_parser_spec.rb
69
+ - useragent_parser.gemspec
70
+ homepage: https://github.com/yabawock/useragent_parser
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ segments:
83
+ - 0
84
+ hash: -3240261621133021063
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ segments:
92
+ - 0
93
+ hash: -3240261621133021063
94
+ requirements: []
95
+ rubyforge_project: useragent_parser
96
+ rubygems_version: 1.8.6
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: A library to extract informtion from Useragent headers
100
+ test_files:
101
+ - spec/fixtures/firefox_user_agent_strings.yaml
102
+ - spec/fixtures/pgts_browser_list.yaml
103
+ - spec/fixtures/test_user_agent_parser.yaml
104
+ - spec/spec_helper.rb
105
+ - spec/useragent_parser/useragent_parser_spec.rb