user_agent_list 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/lib/user_agent_list.rb +35 -0
- data/lib/user_agent_list/parser_ua.rb +35 -0
- data/lib/user_agent_list/version.rb +3 -0
- data/user_agent_list.gemspec +25 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 00b45e452c4585e20dd156daaba7df05f1c31833
|
4
|
+
data.tar.gz: f6828758149b5d42352943b2a8ee5d593a581ad4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bf5c098331b65cce3212ab96a4924b88ce370a6473e7200da0510574d9401b1fc9d30893af94710ada1e7c5a5c8a3b75916fe78a90c46c32cf1313d6ab59122
|
7
|
+
data.tar.gz: 8dcb30205f33da73ac01344d0e4c34559dfc14b9de31b75161e6079ea5d82025a8686172687a069c3f564ba6e62c58fd83b473d24af421f4e077b73db6dcc795
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 chebyte
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
[![Beerpay](https://beerpay.io/hashdog/user_agent_list/badge.svg?style=flat-square)](https://beerpay.io/hashdog/user_agent_list)
|
2
|
+
# UserAgentList
|
3
|
+
|
4
|
+
Minimal ruby gem for list all user-agents supported by useragentstring.com site!
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem install user_agent_list
|
10
|
+
```
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
List supported UA browsers
|
14
|
+
```ruby
|
15
|
+
UserAgentList.supported_browsers
|
16
|
+
```
|
17
|
+
|
18
|
+
Get UA list
|
19
|
+
```ruby
|
20
|
+
UserAgentList.all
|
21
|
+
```
|
22
|
+
|
23
|
+
Find UA by browser name
|
24
|
+
```ruby
|
25
|
+
UserAgentList.by_browser('Chrome')
|
26
|
+
```
|
27
|
+
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/chebyte/user_agent_list.
|
32
|
+
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'user_agent_list/version'
|
2
|
+
require_relative 'user_agent_list/parser_ua'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'open-uri'
|
5
|
+
|
6
|
+
module UserAgentList
|
7
|
+
include ParserUa
|
8
|
+
extend self
|
9
|
+
class BrowserNotSupported < StandardError;end
|
10
|
+
|
11
|
+
SUPPORTED_BROWSERS = ["ABrowse", "Acoo Browser", "America Online Browser",
|
12
|
+
"AmigaVoyager", "AOL", "Arora", "Avant Browser", "Beonex",
|
13
|
+
"BonEcho", "Browzar", "Camino", "Charon", "Cheshire", "Chimera",
|
14
|
+
"Chrome", "ChromePlus", "Classilla", "CometBird", "Comodo_Dragon",
|
15
|
+
"Conkeror", "Crazy Browser", "Cyberdog", "Deepnet Explorer",
|
16
|
+
"DeskBrowse", "Dillo", "Dooble", "Edge", "Element Browser", "Elinks",
|
17
|
+
"Enigma Browser", "EnigmaFox", "Epiphany", "Escape", "Firebird", "Firefox",
|
18
|
+
"Fireweb Navigator", "Flock", "Fluid", "Galaxy", "Galeon", "GranParadiso",
|
19
|
+
"GreenBrowser", "Hana", "HotJava", "IBM WebExplorer", "IBrowse", "iCab", "Iceape",
|
20
|
+
"IceCat", "Iceweasel", "iNet Browser", "Internet Explorer", "iRider", "Iron",
|
21
|
+
"K-Meleon", "K-Ninja", "Kapiko", "Kazehakase", "KKman", "KMLite", "Konqueror",
|
22
|
+
"LeechCraft", "Links", "Lobo", "lolifox", "Lorentz", "Lunascape", "Lynx", "Madfox",
|
23
|
+
"Maxthon", "Midori", "Minefield", "Mozilla", "myibrow", "MyIE2", "Namoroka",
|
24
|
+
"Navscape", "NCSA_Mosaic", "NetNewsWire", "NetPositive", "Netscape", "NetSurf",
|
25
|
+
"OmniWeb", "Opera", "Orca", "Oregano", "osb-browser", "Palemoon", "Phoenix", "Pogo",
|
26
|
+
"Prism", "QtWeb Internet Browser", "Rekonq", "retawq", "RockMelt", "Safari",
|
27
|
+
"SeaMonkey", "Shiira", "Shiretoko", "Sleipnir", "SlimBrowser", "Stainless",
|
28
|
+
"Sundance", "Sunrise", "surf", "Sylera", "Tencent Traveler", "TenFourFox",
|
29
|
+
"theWorld Browser", "uzbl", "Vimprobable", "Vonkeror", "w3m", "WeltweitimnetzBrowser",
|
30
|
+
"WorldWideWeb", "Wyzo"].freeze
|
31
|
+
|
32
|
+
def supported_browsers
|
33
|
+
SUPPORTED_BROWSERS
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module UserAgentList
|
2
|
+
module ParserUa
|
3
|
+
def all
|
4
|
+
result = {}
|
5
|
+
parser.css('h3').each do |item|
|
6
|
+
parser.css("a:contains('#{item.text}')").each do |link|
|
7
|
+
result[item] ||= []
|
8
|
+
result[item] << link.children.text
|
9
|
+
end
|
10
|
+
end
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
def by_browser(string)
|
15
|
+
raise BrowserNotSupported, "#{string} is not supported" unless SUPPORTED_BROWSERS.include?(string)
|
16
|
+
|
17
|
+
result = []
|
18
|
+
parser.css("a:contains('#{string}')").each do |link|
|
19
|
+
result << link.children.text
|
20
|
+
end
|
21
|
+
result
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def useragentstring_url
|
27
|
+
"http://www.useragentstring.com/pages/Browserlist/"
|
28
|
+
end
|
29
|
+
|
30
|
+
def parser
|
31
|
+
@doc ||= Nokogiri::HTML(open(useragentstring_url).read)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'user_agent_list/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "user_agent_list"
|
8
|
+
spec.version = UserAgentList::VERSION
|
9
|
+
spec.authors = ["chebyte"]
|
10
|
+
spec.email = ["mauro@hashdog.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Minimal ruby gem for list all user-agents supported by useragentstring.com site!}
|
13
|
+
spec.description = %q{Minimal ruby gem for list all user-agents supported by useragentstring.com site!}
|
14
|
+
spec.homepage = "http://hashdog.com"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_dependency "nokogiri", "~> 1.6.6.2"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: user_agent_list
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chebyte
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.6.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.6.2
|
55
|
+
description: Minimal ruby gem for list all user-agents supported by useragentstring.com
|
56
|
+
site!
|
57
|
+
email:
|
58
|
+
- mauro@hashdog.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/user_agent_list.rb
|
69
|
+
- lib/user_agent_list/parser_ua.rb
|
70
|
+
- lib/user_agent_list/version.rb
|
71
|
+
- user_agent_list.gemspec
|
72
|
+
homepage: http://hashdog.com
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Minimal ruby gem for list all user-agents supported by useragentstring.com
|
96
|
+
site!
|
97
|
+
test_files: []
|