browserino 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +13 -5
- data/CHANGELOG.md +9 -0
- data/README.md +56 -14
- data/bin/browserino +53 -1
- data/browserino.gemspec +2 -1
- data/lib/browserino/agent.rb +17 -31
- data/lib/browserino/browser.rb +3 -1
- data/lib/browserino/core/helpers.rb +67 -17
- data/lib/browserino/core/patterns.rb +32 -0
- data/lib/browserino/core/questions.rb +13 -37
- data/lib/browserino/core/supported.rb +31 -0
- data/lib/browserino/version.rb +1 -1
- data/lib/browserino.rb +3 -1
- metadata +36 -22
- data/grep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzI3MzRiYjIxMjdhNTg5ZDMyZTgzYmNkOWZlOGIxMTQ4MzNiZWU4OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MzVkY2U0NGRjZDIwNmViMzc0NGVjN2RmNGQzYzMwYWRhMTZkZWNmYw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDkxZjk1YjJhY2ExNDdmZjU5MmQyMzc4YjZmNTZhNDU1OTI2MDM1M2JkMjY0
|
10
|
+
ODE0OTk4YmJkZTg2MGRkNTY2MzM3OGE3ODY0ZWZjYzY4MjI2ZjM4ZDVmMmJh
|
11
|
+
ZWY5YTMyYjExNWI5YjAzMTNkNjkxOGZiYjU3ZTY5NTdlNTgwYjM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjU3YmYzMzIwNmQ0NWY4MTVmNWQwNzRjZjdiMzdmNTNjZDdjMTIzNDQ0ZmU1
|
14
|
+
ZWU0NTJhNzU1NmQ1N2FhMTA3MWZmZTNjMGVmY2RiNDIwZWZhODc0MTk4MTA1
|
15
|
+
NzlkMmRmZWYyYTdhMjUyMjNmMTdkNzZlYzA0OWJkNjlhMjE4NDA=
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
## CHANGELOG
|
2
2
|
_dates are in dd-mm-yyyy format_
|
3
3
|
|
4
|
+
#### 26-05-2016 VERSION 2.8.0
|
5
|
+
|
6
|
+
- Added `search_engine?` method
|
7
|
+
- Added `holmes?` method
|
8
|
+
- Added `ask?` method
|
9
|
+
- Added `duckduckgo?` and alias `ddg?` methods
|
10
|
+
- Fixed `respond_to?` method signature
|
11
|
+
- Added executable for parsing useragents in terminal
|
12
|
+
|
4
13
|
#### 02-03-2016 VERSION 2.7.0
|
5
14
|
|
6
15
|
- Added `solaris?` method
|
data/README.md
CHANGED
@@ -21,6 +21,20 @@ Useragent references:
|
|
21
21
|
_dates are in dd-mm-yyyy format_
|
22
22
|
_older changes can be found in the [CHANGELOG.md](/CHANGELOG.md)_
|
23
23
|
|
24
|
+
#### 24-07-2016 VERSION 2.10.0
|
25
|
+
|
26
|
+
- Added support for the servo browser:
|
27
|
+
- Added `servo?` method
|
28
|
+
|
29
|
+
- Added detection for various programming languages:
|
30
|
+
- Added `library?` method
|
31
|
+
- Added `php?` method
|
32
|
+
- Added `perl?` method
|
33
|
+
- Added `python?` method
|
34
|
+
- Added `java` method
|
35
|
+
- Added `curl` method
|
36
|
+
- Added `pycurl` method
|
37
|
+
|
24
38
|
#### 29-05-2016 VERSION 2.9.0
|
25
39
|
|
26
40
|
- Stricter checking for:
|
@@ -29,8 +43,8 @@ _older changes can be found in the [CHANGELOG.md](/CHANGELOG.md)_
|
|
29
43
|
* `browser?`
|
30
44
|
* `platform?`
|
31
45
|
|
32
|
-
These
|
33
|
-
(e.g `agent.platform?(:firefox) # => true`)
|
46
|
+
These methods used to be callable with unrelated symbols
|
47
|
+
(e.g `agent.platform?(:firefox) # => true`), they will now correctly return false.
|
34
48
|
- Added support for consoles
|
35
49
|
* Added `console?` method
|
36
50
|
* Added `wii?`, `playstation?`, `xbox?` and `nintendo_ds?` methods
|
@@ -44,15 +58,6 @@ _older changes can be found in the [CHANGELOG.md](/CHANGELOG.md)_
|
|
44
58
|
|
45
59
|
- Removed Guard gem dependency
|
46
60
|
|
47
|
-
#### 26-05-2016 VERSION 2.8.0
|
48
|
-
|
49
|
-
- Added `search_engine?` method
|
50
|
-
- Added `holmes?` method
|
51
|
-
- Added `ask?` method
|
52
|
-
- Added `duckduckgo?` and alias `ddg?` methods
|
53
|
-
- Fixed `respond_to?` method signature
|
54
|
-
- Added executable for parsing useragents in terminal
|
55
|
-
|
56
61
|
## Installation
|
57
62
|
|
58
63
|
Add the following to your applications Gemfile:
|
@@ -204,6 +209,12 @@ agent.browser_version
|
|
204
209
|
agent.browser_version compat: true
|
205
210
|
# => '11.0'
|
206
211
|
|
212
|
+
agent.library_name
|
213
|
+
# => nil
|
214
|
+
|
215
|
+
agent.library_version
|
216
|
+
# => nil
|
217
|
+
|
207
218
|
agent.engine_name
|
208
219
|
# => 'trident'
|
209
220
|
|
@@ -257,6 +268,15 @@ agent.browser? :ie
|
|
257
268
|
# returns true if specific browser and version
|
258
269
|
agent.browser? :ie, version: '11.0'
|
259
270
|
|
271
|
+
# returns true if library is known
|
272
|
+
agent.library?
|
273
|
+
|
274
|
+
# returns true if specific library
|
275
|
+
agent.library? :php
|
276
|
+
|
277
|
+
# returns true if specific library and version
|
278
|
+
agent.library? :php, version: '5.9.0'
|
279
|
+
|
260
280
|
# returns true if there is a social media bot on your website
|
261
281
|
agent.social_media?
|
262
282
|
# => false
|
@@ -420,9 +440,9 @@ agent.platform? :android, version: :jelly_bean_16
|
|
420
440
|
# => true
|
421
441
|
```
|
422
442
|
|
423
|
-
##### `platform?`, `browser?`, `bot?`, `console?`, `search_engine
|
443
|
+
##### `platform?`, `browser?`, `bot?`, `console?`, `search_engine?`, `library` and `social_media?` methods
|
424
444
|
|
425
|
-
As you've seen above, the `platform?` function can take two arguments, a symbol with the system name and optionally a hash with a `:version` key to supply a version, the `browser?` method works in exactly the same way.
|
445
|
+
As you've seen above, the `platform?` function can take two arguments, a symbol with the system name and optionally a hash with a `:version` key to supply a version, the `browser?` and `library?` method works in exactly the same way.
|
426
446
|
|
427
447
|
The `bot?` and `social_media?` methods however aren't that complex since you don't need to know a bot / social media version or anything other than it's name so inside these methods, only a name can be passed:
|
428
448
|
|
@@ -448,7 +468,7 @@ agent.bot? :facebook, version: 1.1
|
|
448
468
|
# => ArgumentError
|
449
469
|
```
|
450
470
|
|
451
|
-
##### Checking a specific browser, system, bot or social media
|
471
|
+
##### Checking a specific browser, system, bot, library or social media
|
452
472
|
|
453
473
|
Every name you see in the below lists can be passed as symbol or string to their respective method
|
454
474
|
|
@@ -537,6 +557,28 @@ agent.bot? :google
|
|
537
557
|
agent.bot? :exa
|
538
558
|
```
|
539
559
|
|
560
|
+
**library**
|
561
|
+
|
562
|
+
* `php`
|
563
|
+
* `perl`
|
564
|
+
* `curl`
|
565
|
+
* `python`
|
566
|
+
* `java`
|
567
|
+
* `pycurl`
|
568
|
+
|
569
|
+
Examples:
|
570
|
+
|
571
|
+
```ruby
|
572
|
+
agent.php?
|
573
|
+
agent.pycurl?
|
574
|
+
|
575
|
+
agent.library?
|
576
|
+
|
577
|
+
agent.library? :curl
|
578
|
+
|
579
|
+
agent.library? :curl, version: 7.21
|
580
|
+
```
|
581
|
+
|
540
582
|
**browser**
|
541
583
|
|
542
584
|
* `chrome`
|
data/bin/browserino
CHANGED
@@ -3,6 +3,58 @@
|
|
3
3
|
require 'bundler/setup'
|
4
4
|
require 'browserino'
|
5
5
|
|
6
|
+
aliasses = [:fb, :ddg, :ff, :win, :osx, :bb]
|
7
|
+
|
6
8
|
case ARGV[0]
|
7
|
-
when 'parse'
|
9
|
+
when 'parse', '-p'
|
10
|
+
if ARGV[1]
|
11
|
+
puts Browserino.parse(ARGV[1]).to_console_s
|
12
|
+
else
|
13
|
+
puts ' Usage: browserino parse [ua]'
|
14
|
+
puts ' * ua: the user agent string you want to parse'
|
15
|
+
end
|
16
|
+
when 'list', '-l'
|
17
|
+
ARGV[1] ||= 'info'
|
18
|
+
type = (ARGV[1].to_s.gsub(/[\s\-]/, '_')).to_sym
|
19
|
+
if type == :info
|
20
|
+
puts ' Usage: browserino list [subject]'
|
21
|
+
puts ' * subject: the type you want to display'
|
22
|
+
puts ' * all - list everything that is supported'
|
23
|
+
puts ' * bots - list supported bots'
|
24
|
+
puts ' * browsers - list supported browsers'
|
25
|
+
puts ' * social-media - list supported social media'
|
26
|
+
puts ' * search-engines - list supported search engines'
|
27
|
+
puts ' * consoles - list supported consoles'
|
28
|
+
puts ' * libraries - list supported libraries'
|
29
|
+
puts ' * operating-systems - list supported operating systems'
|
30
|
+
else
|
31
|
+
res = {}
|
32
|
+
res[:bots] = Browserino::Core::SUPPORTED[:bots] - aliasses if type == :all || type == :bots
|
33
|
+
res[:browsers] = Browserino::Core::SUPPORTED[:browsers] - aliasses if type == :all || type == :browsers
|
34
|
+
res[:consoles] = Browserino::Core::SUPPORTED[:consoles] - aliasses if type == :all || type == :consoles
|
35
|
+
res[:libraries] = Browserino::Core::SUPPORTED[:libraries] - aliasses if type == :all || type == :libraries
|
36
|
+
res[:social_media] = Browserino::Core::SUPPORTED[:social_media] - aliasses if type == :all || type == :social_media
|
37
|
+
res[:search_engines] = Browserino::Core::SUPPORTED[:search_engines] - aliasses if type == :all || type == :search_engines
|
38
|
+
res[:operating_systems] = Browserino::Core::SUPPORTED[:operating_systems] - aliasses if type == :all || type == :operating_systems
|
39
|
+
|
40
|
+
out = res.each_with_object([]) do |(type, supported_names), arr|
|
41
|
+
arr << " \e[1;32;49m#{type.to_s.tr('_', ' ')}:\e[0m"
|
42
|
+
supported_names.each { |name| arr << " \e[1;95;49m- #{name}\e[0m" }
|
43
|
+
end
|
44
|
+
puts out
|
45
|
+
end
|
46
|
+
when 'console', '-c'
|
47
|
+
require 'pry'
|
48
|
+
puts "Starting Browserino #{Browserino::VERSION} on Ruby #{RUBY_VERSION}"
|
49
|
+
Pry.start
|
50
|
+
|
51
|
+
else
|
52
|
+
puts ' Usage: browserino [command] [args]'
|
53
|
+
puts "\n"
|
54
|
+
puts ' Calling browserino with anything other than these options will show this help'
|
55
|
+
puts ' Entering a [command] without [args] will show help for that command if it requires [args]'
|
56
|
+
puts "\n"
|
57
|
+
puts ' * parse or -p - parse a user agent'
|
58
|
+
puts ' * list or -l - list supported entities'
|
59
|
+
puts ' * console or -c - enter a console'
|
8
60
|
end
|
data/browserino.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Sidney Liebrand"]
|
10
10
|
spec.email = ["sidneyliebrand@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{A browser identification gem with Rails (>= 3.2.0) integration}
|
12
|
+
spec.summary = %q{A browser identification gem with command line and Rails (>= 3.2.0) integration}
|
13
13
|
spec.homepage = "https://github.com/SidOfc/browserino"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = ['browserino']
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_development_dependency "json", "<= 1.8.3"
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.10"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
24
|
spec.add_development_dependency "rspec"
|
data/lib/browserino/agent.rb
CHANGED
@@ -13,11 +13,6 @@ module Browserino
|
|
13
13
|
@info[:name]
|
14
14
|
end
|
15
15
|
|
16
|
-
alias_method :browser_name, :name
|
17
|
-
alias_method :bot_name, :name
|
18
|
-
alias_method :search_engine_name, :name
|
19
|
-
alias_method :social_media_name, :name
|
20
|
-
|
21
16
|
def browser_version(opts = {})
|
22
17
|
if ie? && engine_version && !opts[:compat]
|
23
18
|
(engine_version.to_f + 4.0).to_s
|
@@ -26,6 +21,14 @@ module Browserino
|
|
26
21
|
end
|
27
22
|
end
|
28
23
|
|
24
|
+
def library_version
|
25
|
+
@info[:library_version]
|
26
|
+
end
|
27
|
+
|
28
|
+
def library_name
|
29
|
+
@info[:name]
|
30
|
+
end
|
31
|
+
|
29
32
|
def engine_name
|
30
33
|
@info[:engine_name]
|
31
34
|
end
|
@@ -73,23 +76,18 @@ module Browserino
|
|
73
76
|
|
74
77
|
def to_s(sep = '')
|
75
78
|
prev = ''
|
76
|
-
|
79
|
+
props = hash_for_to_s
|
80
|
+
res = props.each_with_object([]) do |v, a|
|
77
81
|
a << case v[0]
|
78
82
|
when :browser_version, :engine_version
|
79
83
|
prev + sep + (v[1].split('.').first || '')
|
84
|
+
when :library_version
|
85
|
+
props[:name] + sep + (v[1].split('.').first || '')
|
80
86
|
else v[1]
|
81
87
|
end
|
82
88
|
prev = v[1]
|
83
89
|
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
def hash_for_to_s
|
88
|
-
out = to_h.each_with_object({}) do |a, h|
|
89
|
-
h[a[0]] = a[1].to_s.gsub(/[\s_]/, '-')
|
90
|
-
end
|
91
|
-
[:locale, :system_version].each { |k| out.delete(k) }
|
92
|
-
out
|
90
|
+
res.uniq.reject { |str| str == '' }.join ' '
|
93
91
|
end
|
94
92
|
|
95
93
|
def to_a
|
@@ -103,9 +101,10 @@ module Browserino
|
|
103
101
|
def method_missing(method_sym, *args, &block)
|
104
102
|
name = method_sym.to_s.tr('?', '')
|
105
103
|
invertable case type_id(method_sym)
|
106
|
-
when :system then correct_system?
|
107
|
-
when :agent then correct_agent?
|
108
|
-
when :console then correct_console?
|
104
|
+
when :system then correct_system? name, *args
|
105
|
+
when :agent then correct_agent? name, *args
|
106
|
+
when :console then correct_console? name
|
107
|
+
when :library then correct_library? name, *args
|
109
108
|
else super
|
110
109
|
end
|
111
110
|
end
|
@@ -113,18 +112,5 @@ module Browserino
|
|
113
112
|
def respond_to?(method_sym, *args, &block)
|
114
113
|
type_id(method_sym).nil? ? false : true
|
115
114
|
end
|
116
|
-
|
117
|
-
private
|
118
|
-
|
119
|
-
def post_process(h)
|
120
|
-
case h[:name]
|
121
|
-
when 'edge'
|
122
|
-
h[:engine_name] = 'edgehtml'
|
123
|
-
h[:engine_version] = h[:browser_version].to_s.split('.').shift.to_s
|
124
|
-
when 'ie'
|
125
|
-
h[:engine_name] = 'trident'
|
126
|
-
end
|
127
|
-
h
|
128
|
-
end
|
129
115
|
end
|
130
116
|
end
|
data/lib/browserino/browser.rb
CHANGED
@@ -3,6 +3,7 @@ module Browserino
|
|
3
3
|
def self.name(ua)
|
4
4
|
name = nil
|
5
5
|
patterns = Core::PATTERNS[:browser].merge(Core::PATTERNS[:bot])
|
6
|
+
.merge(Core::PATTERNS[:library])
|
6
7
|
agents = patterns.keys
|
7
8
|
|
8
9
|
until agents.empty? || !name.nil?
|
@@ -13,7 +14,8 @@ module Browserino
|
|
13
14
|
name
|
14
15
|
end
|
15
16
|
|
16
|
-
def self.version(ua,
|
17
|
+
def self.version(ua, name)
|
18
|
+
patterns = Core::PATTERNS[:browser][name] || Core::PATTERNS[:library][name]
|
17
19
|
if patterns
|
18
20
|
Browserino.extract_match(ua.match(patterns[:version]), :version) do |v|
|
19
21
|
v.tr('_', '.')
|
@@ -1,8 +1,55 @@
|
|
1
1
|
module Browserino
|
2
2
|
module Core
|
3
3
|
module Helpers
|
4
|
+
def browser_name
|
5
|
+
name_strict(:browsers)
|
6
|
+
end
|
7
|
+
|
8
|
+
def bot_name
|
9
|
+
name_strict(:bots)
|
10
|
+
end
|
11
|
+
|
12
|
+
def search_engine_name
|
13
|
+
name_strict(:search_engines)
|
14
|
+
end
|
15
|
+
|
16
|
+
def social_media_name
|
17
|
+
name_strict(:social_media)
|
18
|
+
end
|
19
|
+
|
4
20
|
private
|
5
21
|
|
22
|
+
def post_process(h)
|
23
|
+
h[:library_version] = nil
|
24
|
+
case h[:name].to_s.to_sym
|
25
|
+
when :edge
|
26
|
+
h[:engine_name] = 'edgehtml'
|
27
|
+
h[:engine_version] = h[:browser_version].to_s.split('.').shift.to_s
|
28
|
+
when :ie
|
29
|
+
h[:engine_name] = 'trident'
|
30
|
+
when *SUPPORTED[:libraries]
|
31
|
+
h[:library_version] = h[:browser_version].dup
|
32
|
+
h[:browser_version] = nil
|
33
|
+
end
|
34
|
+
h
|
35
|
+
end
|
36
|
+
|
37
|
+
def name_strict(cat)
|
38
|
+
name if category? cat
|
39
|
+
end
|
40
|
+
|
41
|
+
def hash_for_to_s
|
42
|
+
out = to_h.each_with_object({}) do |a, h|
|
43
|
+
h[a[0]] = a[1].to_s.gsub(/[\s_]/, '-')
|
44
|
+
end
|
45
|
+
|
46
|
+
[:locale, :system_version].each { |k| out.delete(k) }
|
47
|
+
out.delete(:browser_version) if out[:name] == ''
|
48
|
+
out.delete(:engine_version) if out[:engine_name] == ''
|
49
|
+
|
50
|
+
out
|
51
|
+
end
|
52
|
+
|
6
53
|
def invertable(res)
|
7
54
|
if @not
|
8
55
|
@not = false
|
@@ -45,25 +92,32 @@ module Browserino
|
|
45
92
|
end
|
46
93
|
end
|
47
94
|
|
95
|
+
def correct_library?(name, version = nil)
|
96
|
+
name == library_name && (version.nil? || compare_versions(version, library_version))
|
97
|
+
end
|
98
|
+
|
48
99
|
def correct_console?(name)
|
49
|
-
|
100
|
+
name == console_name
|
101
|
+
end
|
102
|
+
|
103
|
+
def category?(cat)
|
104
|
+
n = name.to_s.gsub(/[\s-]/, '_').to_sym
|
105
|
+
SUPPORTED.each { |t, s| return true if s.include?(n) && t == cat }
|
106
|
+
nil
|
50
107
|
end
|
51
108
|
|
52
109
|
def type_id(method_sym)
|
53
|
-
name = method_sym.to_s.tr('?', '')
|
54
|
-
|
55
|
-
if
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
elsif name == 'console'
|
60
|
-
:console
|
61
|
-
end
|
110
|
+
name = method_sym.to_s.downcase.tr('?', '').to_sym
|
111
|
+
return :library if SUPPORTED[:libraries].include? name
|
112
|
+
return :console if SUPPORTED[:consoles].include? name
|
113
|
+
return :system if SUPPORTED[:operating_systems].include? name
|
114
|
+
return :agent if SUPPORTED[:browsers].concat(SUPPORTED[:bots]).include? name
|
115
|
+
nil
|
62
116
|
end
|
63
117
|
|
64
118
|
def fetch_system_version_name(name)
|
65
|
-
const =
|
66
|
-
version =
|
119
|
+
const = name.to_s.tr(' ', '_').upcase.to_sym
|
120
|
+
version = internal_sys_version(const)
|
67
121
|
if version && Mapping.const?(const)
|
68
122
|
res = Mapping.const_get(const)
|
69
123
|
.select { |_, v| true if v.include?(version) }.keys.first
|
@@ -71,7 +125,7 @@ module Browserino
|
|
71
125
|
end
|
72
126
|
end
|
73
127
|
|
74
|
-
def
|
128
|
+
def internal_sys_version(name)
|
75
129
|
if system_version
|
76
130
|
if name =~ /mac|blackberry/i
|
77
131
|
system_version.split('.').first(2).join.to_i
|
@@ -82,10 +136,6 @@ module Browserino
|
|
82
136
|
end
|
83
137
|
end
|
84
138
|
end
|
85
|
-
|
86
|
-
def to_const_sym(s)
|
87
|
-
s.to_s.tr(' ', '_').upcase.to_sym
|
88
|
-
end
|
89
139
|
end
|
90
140
|
end
|
91
141
|
end
|
@@ -47,6 +47,11 @@ module Browserino
|
|
47
47
|
version: %r{seamonkey/(?<version>[\d\.]+)}i
|
48
48
|
},
|
49
49
|
|
50
|
+
servo: {
|
51
|
+
name: /(?<name>servo)/i,
|
52
|
+
version: %r{servo/(?<version>[\d\.]+)}i
|
53
|
+
},
|
54
|
+
|
50
55
|
firefox: {
|
51
56
|
name: /(?<name>(?:fire|water)(?:fox|bird)
|
52
57
|
|ice(?:weasel|cat)|netscape|superswan)/xi,
|
@@ -70,6 +75,33 @@ module Browserino
|
|
70
75
|
}
|
71
76
|
},
|
72
77
|
|
78
|
+
library: {
|
79
|
+
php: {
|
80
|
+
name: /(?<name>php)/i,
|
81
|
+
version: %r{php/(?<version>[\d\.]+)}i
|
82
|
+
},
|
83
|
+
python: {
|
84
|
+
name: /(?<name>python)/i,
|
85
|
+
version: %r{python-urllib/(?<version>[\d\.]+)}i
|
86
|
+
},
|
87
|
+
perl: {
|
88
|
+
name: /(?<name>perl)/i,
|
89
|
+
version: %r{perl/(?<version>[\d\.]+)}i
|
90
|
+
},
|
91
|
+
java: {
|
92
|
+
name: /(?<name>java)/i,
|
93
|
+
version: %r{java/(?<version>[\d\._]+)}i
|
94
|
+
},
|
95
|
+
pycurl: {
|
96
|
+
name: /(?<name>pycurl)/i,
|
97
|
+
version: %r{pycurl/(?<version>[\d\.]+)}i
|
98
|
+
},
|
99
|
+
curl: {
|
100
|
+
name: /(?<name>curl)/i,
|
101
|
+
version: %r{curl/(?<version>[\d\.a-z]+)}i
|
102
|
+
}
|
103
|
+
},
|
104
|
+
|
73
105
|
bot: {
|
74
106
|
google: { name: /(?<name>googlebot)/i },
|
75
107
|
yahoo_slurp: { name: /(?<name>yahoo\!\sslurp)/i },
|
@@ -1,20 +1,6 @@
|
|
1
1
|
module Browserino
|
2
2
|
module Core
|
3
3
|
module Questions
|
4
|
-
SOCIAL_MEDIA = [:facebook, :fb, :twitter, :linkedin,
|
5
|
-
:instagram, :pinterest, :tumblr].freeze
|
6
|
-
|
7
|
-
SEARCH_ENGINES = [:google, :bing, :yahoo_slurp,
|
8
|
-
:baiduspider, :duckduckgo, :ddg].freeze
|
9
|
-
|
10
|
-
BROWSERS = (Core::PATTERNS[:browser].keys + [:ff]).freeze
|
11
|
-
|
12
|
-
CONSOLES = [:xbox, :playstation, :nintendo_ds, :wii].freeze
|
13
|
-
|
14
|
-
OPERATING_SYSTEMS = (Browserino::Mapping
|
15
|
-
.constants(:true)
|
16
|
-
.map(&:downcase) + [:osx, :bb, :win]).freeze
|
17
|
-
|
18
4
|
def compat?
|
19
5
|
invertable ie? && browser_version != browser_version(compat: true)
|
20
6
|
end
|
@@ -59,22 +45,6 @@ module Browserino
|
|
59
45
|
duckduckgo?(*arg)
|
60
46
|
end
|
61
47
|
|
62
|
-
def playstation?
|
63
|
-
invertable console_name == 'playstation'
|
64
|
-
end
|
65
|
-
|
66
|
-
def nintendo_ds?
|
67
|
-
invertable console_name == 'nintendo_ds'
|
68
|
-
end
|
69
|
-
|
70
|
-
def xbox?
|
71
|
-
invertable console_name == 'xbox'
|
72
|
-
end
|
73
|
-
|
74
|
-
def wii?
|
75
|
-
invertable console_name == 'wii'
|
76
|
-
end
|
77
|
-
|
78
48
|
def bot?(name = nil)
|
79
49
|
is_bot = ua.strip.empty? || !bot_name.nil?
|
80
50
|
is_name = name.nil? || name.to_s.downcase.tr('_', ' ') == bot_name
|
@@ -83,29 +53,35 @@ module Browserino
|
|
83
53
|
|
84
54
|
def console?(name = nil)
|
85
55
|
arg = (name.nil? ? console_name : name).to_s.to_sym
|
86
|
-
invertable
|
56
|
+
invertable Core::SUPPORTED[:consoles].include? arg
|
87
57
|
end
|
88
58
|
|
89
59
|
def search_engine?(name = nil)
|
90
60
|
arg = (name.nil? ? search_engine_name : name).to_s.to_sym
|
91
|
-
invertable
|
61
|
+
invertable Core::SUPPORTED[:search_engines].include? arg
|
92
62
|
end
|
93
63
|
|
94
64
|
def social_media?(name = nil)
|
95
65
|
arg = (name.nil? ? bot_name : name).to_s.to_sym
|
96
|
-
invertable
|
66
|
+
invertable Core::SUPPORTED[:social_media].include? arg
|
97
67
|
end
|
98
68
|
|
99
69
|
def platform?(name = nil, opts = {})
|
100
70
|
arg = (name.nil? ? system_name : name).to_s.to_sym
|
101
|
-
invertable
|
102
|
-
(opts[:version].nil? ? true : send("#{
|
71
|
+
invertable Core::SUPPORTED[:operating_systems].include?(arg) &&
|
72
|
+
(opts[:version].nil? ? true : send("#{arg}?", opts[:version]))
|
73
|
+
end
|
74
|
+
|
75
|
+
def library?(name = nil, opts = {})
|
76
|
+
arg = (name.nil? ? library_name : name).to_s.to_sym
|
77
|
+
invertable Core::SUPPORTED[:libraries].include?(arg) &&
|
78
|
+
(opts[:version].nil? ? true : send("#{arg}?", opts[:version]))
|
103
79
|
end
|
104
80
|
|
105
81
|
def browser?(name = nil, opts = {})
|
106
82
|
arg = (name.nil? ? browser_name.tr(' ', '_') : name).to_s.to_sym
|
107
|
-
invertable
|
108
|
-
(opts[:version].nil? ? true : send("#{
|
83
|
+
invertable Core::SUPPORTED[:browsers].include?(arg) &&
|
84
|
+
(opts[:version].nil? ? true : send("#{arg}?", opts[:version]))
|
109
85
|
end
|
110
86
|
end
|
111
87
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Browserino
|
2
|
+
module Core
|
3
|
+
SUPPORTED_ALIASSES = {
|
4
|
+
browsers: {firefox: [:ff]},
|
5
|
+
social_media: {facebook: [:fb]},
|
6
|
+
search_engines: {duckduckgo: [:ddg]},
|
7
|
+
bots: {},
|
8
|
+
consoles: {},
|
9
|
+
operating_systems: {macintosh: [:osx], blackberry: [:bb],
|
10
|
+
windows: [:win]}
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
SUPPORTED = {
|
14
|
+
browsers: (PATTERNS[:browser].keys +
|
15
|
+
SUPPORTED_ALIASSES[:browsers].values.flatten),
|
16
|
+
social_media: [:facebook, :twitter, :linkedin,
|
17
|
+
:instagram, :pinterest, :tumblr] +
|
18
|
+
SUPPORTED_ALIASSES[:social_media].values.flatten,
|
19
|
+
search_engines: [:google, :bing, :yahoo_slurp,
|
20
|
+
:baiduspider, :duckduckgo] +
|
21
|
+
SUPPORTED_ALIASSES[:search_engines].values.flatten,
|
22
|
+
libraries: PATTERNS[:library].keys,
|
23
|
+
bots: (PATTERNS[:bot].keys + SUPPORTED_ALIASSES[:bots].values.flatten),
|
24
|
+
consoles: [:xbox, :playstation, :nintendo_ds, :wii] +
|
25
|
+
SUPPORTED_ALIASSES[:consoles].values.flatten,
|
26
|
+
operating_systems: (Browserino::Mapping
|
27
|
+
.constants(:true)
|
28
|
+
.map(&:downcase) + SUPPORTED_ALIASSES[:operating_systems].values.flatten)
|
29
|
+
}.freeze
|
30
|
+
end
|
31
|
+
end
|
data/lib/browserino/version.rb
CHANGED
data/lib/browserino.rb
CHANGED
@@ -10,6 +10,7 @@ require 'browserino/maps/windows'
|
|
10
10
|
require 'browserino/maps/windows_phone'
|
11
11
|
|
12
12
|
require 'browserino/core/patterns'
|
13
|
+
require 'browserino/core/supported'
|
13
14
|
require 'browserino/core/questions'
|
14
15
|
require 'browserino/core/helpers'
|
15
16
|
require 'browserino/core/lies'
|
@@ -28,6 +29,7 @@ require 'browserino/console'
|
|
28
29
|
|
29
30
|
# require_relative "../spec/user_agents"
|
30
31
|
# require_relative "../spec/user_agents_bots"
|
32
|
+
# require_relative "../spec/user_agents_consoles"
|
31
33
|
# require_relative "../spec/user_agents_browsers"
|
32
34
|
|
33
35
|
module Browserino
|
@@ -44,7 +46,7 @@ module Browserino
|
|
44
46
|
|
45
47
|
def fetch_info(ua, name)
|
46
48
|
{ name: name,
|
47
|
-
browser_version: Browser.version(ua,
|
49
|
+
browser_version: Browser.version(ua, name),
|
48
50
|
engine_name: Engine.name(ua),
|
49
51
|
engine_version: Engine.version(ua),
|
50
52
|
system_name: OperatingSystem.name(ua),
|
metadata
CHANGED
@@ -1,83 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browserino
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sidney Liebrand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - <=
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - <=
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.3
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- -
|
31
|
+
- - ~>
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '1.10'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- -
|
38
|
+
- - ~>
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '1.10'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ~>
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '10.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ~>
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ! '>='
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ! '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: coveralls
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ! '>='
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ! '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ! '>='
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ! '>='
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
description:
|
@@ -88,11 +102,11 @@ executables:
|
|
88
102
|
extensions: []
|
89
103
|
extra_rdoc_files: []
|
90
104
|
files:
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
-
|
105
|
+
- .coveralls.yml
|
106
|
+
- .gitignore
|
107
|
+
- .rspec
|
108
|
+
- .rubocop.yml
|
109
|
+
- .travis.yml
|
96
110
|
- CHANGELOG.md
|
97
111
|
- CODE_OF_CONDUCT.md
|
98
112
|
- Gemfile
|
@@ -103,7 +117,6 @@ files:
|
|
103
117
|
- bin/console
|
104
118
|
- bin/setup
|
105
119
|
- browserino.gemspec
|
106
|
-
- grep
|
107
120
|
- lib/browserino.rb
|
108
121
|
- lib/browserino/agent.rb
|
109
122
|
- lib/browserino/browser.rb
|
@@ -113,6 +126,7 @@ files:
|
|
113
126
|
- lib/browserino/core/lies.rb
|
114
127
|
- lib/browserino/core/patterns.rb
|
115
128
|
- lib/browserino/core/questions.rb
|
129
|
+
- lib/browserino/core/supported.rb
|
116
130
|
- lib/browserino/engine.rb
|
117
131
|
- lib/browserino/integrate/action_controller.rb
|
118
132
|
- lib/browserino/integrate/rails.rb
|
@@ -139,18 +153,18 @@ require_paths:
|
|
139
153
|
- lib
|
140
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
155
|
requirements:
|
142
|
-
- -
|
156
|
+
- - ! '>='
|
143
157
|
- !ruby/object:Gem::Version
|
144
158
|
version: '0'
|
145
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
160
|
requirements:
|
147
|
-
- -
|
161
|
+
- - ! '>='
|
148
162
|
- !ruby/object:Gem::Version
|
149
163
|
version: '0'
|
150
164
|
requirements: []
|
151
165
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.4.8
|
153
167
|
signing_key:
|
154
168
|
specification_version: 4
|
155
|
-
summary: A browser identification gem with Rails (>= 3.2.0) integration
|
169
|
+
summary: A browser identification gem with command line and Rails (>= 3.2.0) integration
|
156
170
|
test_files: []
|
data/grep
DELETED
File without changes
|