browserino 3.0.1 → 4.0.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 +4 -4
- data/.rubocop.yml +10 -0
- data/.travis.yml +6 -7
- data/bin/browserino +20 -52
- data/bin/console +5 -8
- data/browserino.gemspec +2 -6
- data/lib/browserino/client.rb +216 -0
- data/lib/browserino/config.rb +90 -0
- data/lib/browserino/definitions/aliasses.rb +12 -0
- data/lib/browserino/definitions/filters.rb +67 -0
- data/lib/browserino/definitions/labels.rb +45 -0
- data/lib/browserino/definitions/matchers.rb +290 -0
- data/lib/browserino/identity.rb +55 -0
- data/lib/browserino/integrate/action_controller.rb +4 -2
- data/lib/browserino/integrate/rails.rb +2 -0
- data/lib/browserino/methods.rb +110 -0
- data/lib/browserino/options.rb +44 -0
- data/lib/browserino/version.rb +72 -1
- data/lib/browserino.rb +16 -58
- metadata +15 -61
- data/lib/browserino/agent.rb +0 -116
- data/lib/browserino/browser.rb +0 -28
- data/lib/browserino/console.rb +0 -10
- data/lib/browserino/core/alias.rb +0 -23
- data/lib/browserino/core/helpers.rb +0 -141
- data/lib/browserino/core/lies.rb +0 -14
- data/lib/browserino/core/mapping.rb +0 -78
- data/lib/browserino/core/patterns.rb +0 -142
- data/lib/browserino/core/questions.rb +0 -88
- data/lib/browserino/core/supported.rb +0 -31
- data/lib/browserino/engine.rb +0 -16
- data/lib/browserino/operating_system.rb +0 -33
- data/lib/browserino/unknown.rb +0 -3
@@ -1,88 +0,0 @@
|
|
1
|
-
module Browserino
|
2
|
-
module Core
|
3
|
-
module Questions
|
4
|
-
def compat?
|
5
|
-
invertable ie? && browser_version != browser_version(compat: true)
|
6
|
-
end
|
7
|
-
|
8
|
-
def known?
|
9
|
-
invertable !browser_name.nil? || !bot_name.nil?
|
10
|
-
end
|
11
|
-
|
12
|
-
def mobile?
|
13
|
-
invertable !ua.match(Core::PATTERNS[:operating_system][:mobile]).nil?
|
14
|
-
end
|
15
|
-
|
16
|
-
def x64?
|
17
|
-
invertable system_architecture == 'x64'
|
18
|
-
end
|
19
|
-
|
20
|
-
def x32?
|
21
|
-
invertable system_architecture == 'x32'
|
22
|
-
end
|
23
|
-
|
24
|
-
def osx?(*arg)
|
25
|
-
macintosh?(*arg)
|
26
|
-
end
|
27
|
-
|
28
|
-
def win?(*arg)
|
29
|
-
windows?(*arg)
|
30
|
-
end
|
31
|
-
|
32
|
-
def bb?(*arg)
|
33
|
-
blackberry?(*arg)
|
34
|
-
end
|
35
|
-
|
36
|
-
def fb?(*arg)
|
37
|
-
facebook?(*arg)
|
38
|
-
end
|
39
|
-
|
40
|
-
def ff?(*arg)
|
41
|
-
firefox?(*arg)
|
42
|
-
end
|
43
|
-
|
44
|
-
def ddg?(*arg)
|
45
|
-
duckduckgo?(*arg)
|
46
|
-
end
|
47
|
-
|
48
|
-
def bot?(name = nil)
|
49
|
-
is_bot = ua.strip.empty? || !bot_name.nil?
|
50
|
-
is_name = name.nil? || name.to_s.downcase.tr('_', ' ') == bot_name
|
51
|
-
invertable is_bot && is_name
|
52
|
-
end
|
53
|
-
|
54
|
-
def console?(name = nil)
|
55
|
-
arg = (name.nil? ? console_name : name).to_s.to_sym
|
56
|
-
invertable Core::SUPPORTED[:consoles].include? arg
|
57
|
-
end
|
58
|
-
|
59
|
-
def search_engine?(name = nil)
|
60
|
-
arg = (name.nil? ? search_engine_name : name).to_s.to_sym
|
61
|
-
invertable Core::SUPPORTED[:search_engines].include? arg
|
62
|
-
end
|
63
|
-
|
64
|
-
def social_media?(name = nil)
|
65
|
-
arg = (name.nil? ? bot_name : name).to_s.to_sym
|
66
|
-
invertable Core::SUPPORTED[:social_media].include? arg
|
67
|
-
end
|
68
|
-
|
69
|
-
def platform?(name = nil, opts = {})
|
70
|
-
arg = (name.nil? ? system_name : name).to_s.to_sym
|
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]))
|
79
|
-
end
|
80
|
-
|
81
|
-
def browser?(name = nil, opts = {})
|
82
|
-
arg = (name.nil? ? browser_name.tr(' ', '_') : name).to_s.to_sym
|
83
|
-
invertable Core::SUPPORTED[:browsers].include?(arg) &&
|
84
|
-
(opts[:version].nil? ? true : send("#{arg}?", opts[:version]))
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Browserino
|
2
|
-
module Core
|
3
|
-
SUPPORTED_ALIASSES = {
|
4
|
-
browsers: {firefox: [:ff], ie: [:internet_explorer]},
|
5
|
-
social_media: {facebook: [:fb]},
|
6
|
-
search_engines: {duckduckgo: [:ddg]},
|
7
|
-
bots: {},
|
8
|
-
consoles: {},
|
9
|
-
operating_systems: {macintosh: [:osx, :macos], 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/engine.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Browserino
|
2
|
-
module Engine
|
3
|
-
def self.name(ua)
|
4
|
-
Browserino.extract_match(ua.match(Core::PATTERNS[:engine][:name]), :name)
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.version(ua)
|
8
|
-
Browserino.extract_match(
|
9
|
-
ua.match(Core::PATTERNS[:engine][:version]),
|
10
|
-
:version
|
11
|
-
) do |v|
|
12
|
-
v.tr('_', '.')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Browserino
|
2
|
-
module OperatingSystem
|
3
|
-
def self.name(ua)
|
4
|
-
Browserino.extract_match(
|
5
|
-
ua.match(Core::PATTERNS[:operating_system][:name]),
|
6
|
-
:name
|
7
|
-
)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.version(ua)
|
11
|
-
Browserino.extract_match(
|
12
|
-
ua.match(Core::PATTERNS[:operating_system][:version]),
|
13
|
-
:version
|
14
|
-
) do |v|
|
15
|
-
v.tr('_', '.')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.architecture(ua)
|
20
|
-
Browserino.extract_match(
|
21
|
-
ua.match(Core::PATTERNS[:operating_system][:architecture]),
|
22
|
-
:architecture
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.locale(ua)
|
27
|
-
Browserino.extract_match(
|
28
|
-
ua.match(Core::PATTERNS[:operating_system][:locale]),
|
29
|
-
:locale
|
30
|
-
)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/lib/browserino/unknown.rb
DELETED