brauser 3.3.2 → 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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/.travis-gemfile +4 -5
  4. data/.travis.yml +2 -2
  5. data/CHANGELOG.md +4 -0
  6. data/Gemfile +7 -8
  7. data/README.md +31 -95
  8. data/Rakefile +0 -1
  9. data/brauser.gemspec +4 -4
  10. data/default_definitions/browsers.rb +50 -0
  11. data/default_definitions/languages.rb +118 -0
  12. data/default_definitions/platforms.rb +24 -0
  13. data/doc/Brauser.html +6 -6
  14. data/doc/Brauser/Browser.html +3867 -580
  15. data/doc/Brauser/Definitions.html +537 -0
  16. data/doc/Brauser/Definitions/Base.html +342 -0
  17. data/doc/Brauser/Definitions/Browser.html +1047 -0
  18. data/doc/Brauser/Definitions/Language.html +496 -0
  19. data/doc/Brauser/Definitions/Platform.html +686 -0
  20. data/doc/Brauser/Hooks.html +2 -2
  21. data/doc/Brauser/Hooks/RubyOnRails.html +9 -9
  22. data/doc/Brauser/Parser.html +513 -0
  23. data/doc/Brauser/Value.html +601 -0
  24. data/doc/Brauser/Version.html +5 -5
  25. data/doc/_index.html +25 -108
  26. data/doc/class_list.html +1 -1
  27. data/doc/file.README.html +33 -97
  28. data/doc/index.html +33 -97
  29. data/doc/method_list.html +72 -120
  30. data/doc/top-level-namespace.html +2 -2
  31. data/lib/brauser.rb +13 -15
  32. data/lib/brauser/browser.rb +195 -66
  33. data/lib/brauser/definitions/base.rb +71 -0
  34. data/lib/brauser/definitions/browser.rb +80 -0
  35. data/lib/brauser/definitions/language.rb +29 -0
  36. data/lib/brauser/definitions/platform.rb +42 -0
  37. data/lib/brauser/hooks.rb +1 -2
  38. data/lib/brauser/parser.rb +47 -0
  39. data/lib/brauser/value.rb +39 -0
  40. data/lib/brauser/version.rb +3 -4
  41. data/spec/brauser/browser_spec.rb +73 -564
  42. data/spec/brauser/default_definitions_spec.rb +129 -0
  43. data/spec/brauser/definitions/base_spec.rb +48 -0
  44. data/spec/brauser/definitions/browser_spec.rb +47 -0
  45. data/spec/brauser/definitions/language_spec.rb +18 -0
  46. data/spec/brauser/definitions/platform_spec.rb +36 -0
  47. data/spec/brauser/hooks_spec.rb +5 -6
  48. data/spec/brauser/parser_spec.rb +31 -0
  49. data/spec/brauser/value_spec.rb +34 -0
  50. data/spec/coverage_helper.rb +0 -1
  51. data/spec/spec_helper.rb +0 -1
  52. metadata +50 -23
  53. data/lib/brauser/browseable/attributes.rb +0 -95
  54. data/lib/brauser/browseable/general.rb +0 -104
  55. data/lib/brauser/browseable/parsing.rb +0 -127
  56. data/lib/brauser/browseable/partial_querying.rb +0 -116
  57. data/lib/brauser/browseable/querying.rb +0 -63
  58. data/lib/brauser/browseable/register.rb +0 -73
  59. data/lib/brauser/definition.rb +0 -80
  60. data/lib/brauser/definitions/browsers.rb +0 -68
  61. data/lib/brauser/definitions/languages.rb +0 -130
  62. data/lib/brauser/definitions/platforms.rb +0 -30
  63. data/lib/brauser/query.rb +0 -36
  64. data/lib/brauser/queryable/chainers.rb +0 -56
  65. data/lib/brauser/queryable/queries.rb +0 -60
  66. data/spec/brauser/definition_spec.rb +0 -39
  67. data/spec/brauser/query_spec.rb +0 -111
@@ -1,73 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # The interface of brauser browsers.
9
- module Browseable
10
- # Methods for register recognized browsers, versions and platforms.
11
- module Register
12
- extend ActiveSupport::Concern
13
-
14
- # Class methods.
15
- module ClassMethods
16
- # Adds a definitions for recognition.
17
- #
18
- # @param type [Symbol] The type of the definition. Can be `:browsers`, `:platforms` or `:languages`.
19
- # @param definition [Definition|Array] The definition to add. Can be also an array of definitions.
20
- # @return [Boolean] `true` if at least one definition has been added, `false` otherwise.
21
- def add(type, definition)
22
- rv = false
23
-
24
- if [:browsers, :platforms, :languages].include?(type)
25
- prepare_definitions_for(type)
26
-
27
- definition.ensure_array.each do |d|
28
- next unless d.is_a?(::Brauser::Definition)
29
- @definitions[type][d.tag] = d
30
- rv = true
31
- end
32
- end
33
-
34
- rv
35
- end
36
-
37
- # Adds definitions for a default list of browsers that can be recognized.
38
- #
39
- # @return [Boolean] `true` if at least one browser has been added, `false` otherwise.
40
- def add_default_browsers
41
- add(:browsers, (
42
- ::Brauser::Browseable::DefaultDefinitions::MOBILE_BROWSERS + ::Brauser::Browseable::DefaultDefinitions::MAJOR_DESKTOP_BROWSERS +
43
- ::Brauser::Browseable::DefaultDefinitions::MSIE_BROWSERS + ::Brauser::Browseable::DefaultDefinitions::MINOR_DESKTOP_BROWSERS
44
- ).map { |browser| ::Brauser::Definition.send(:new, *browser) })
45
- end
46
-
47
- # Adds a default list of platforms that can be recognized.
48
- #
49
- # @return [Boolean] `true` if at least one platform has been added, `false` otherwise.
50
- def add_default_platforms
51
- add(:platforms, ::Brauser::Browseable::DefaultDefinitions::PLATFORMS.map { |platform| ::Brauser::Definition.send(:new, *platform) })
52
- end
53
-
54
- # Adds a default list of languages that can be recognized.
55
- #
56
- # @return [Boolean] `true` if at least one language has been added, `false` otherwise.
57
- def add_default_languages
58
- add(:languages, ::Brauser::Browseable::DefaultDefinitions::LANGUAGES.map { |code, name| ::Brauser::Definition.new(code, name, code) })
59
- end
60
-
61
- private
62
-
63
- # Prepares definition for a specific type.
64
- #
65
- # @param type [Symbol] The type to prepare.
66
- def prepare_definitions_for(type)
67
- @definitions ||= {}
68
- @definitions[type] ||= {}
69
- end
70
- end
71
- end
72
- end
73
- end
@@ -1,80 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # A class which hold a definition of a browser, a platform or a language
9
- # This class represents a detection of the current user browser.
10
- #
11
- # @attribute tag
12
- # @return [String|Symbol] An identifier for this definition.
13
- # @attribute label
14
- # @return [String] A human readable label for this definition.
15
- # @attribute primary
16
- # @return [String|Symbol|Proc] The primary matcher of this definition. Used to match browser engine, platform name and language.
17
- # @attribute secondary
18
- # @return [String|Symbol|Proc] The secondary matcher of this definition. Used to match browser version.
19
- class Definition
20
- attr_accessor :tag, :label, :primary, :secondary
21
-
22
- # Creates a new definition.
23
- #
24
- # @param tag [String|Symbol] An identifier for this definition.
25
- # @param label [String] A human readable label for this definition.
26
- # @param primary [String|Symbol|Proc] The primary matcher of this definition.
27
- # @param secondary [String|Symbol|Proc] The secondary matcher of this definition.
28
- def initialize(tag = nil, label = nil, primary = nil, secondary = nil)
29
- self.tag = tag if tag
30
- self.label = label if label
31
- self.primary = primary if primary
32
- self.secondary = secondary if secondary
33
- end
34
-
35
- # Performs a match of this definition.
36
- #
37
- # @param type [Symbol] The matcher to perform. Can be `:primary` (default) or `:secondary`.
38
- # @param args [Array] Arguments to pass to the matcher. The first is the definition itself.
39
- # @return [Object|NilClass] A match if matcher succeeded, `nil` otherwise.
40
- def match(type, *args)
41
- begin
42
- matcher = send(type || :primary)
43
- rescue NoMethodError
44
- nil
45
- end
46
-
47
- perform_match(matcher, args[1], args)
48
- end
49
-
50
- private
51
-
52
- # Recognizes a browser disambiguating against another.
53
- #
54
- # @param agent [String] The agent to match.
55
- # @param positive_matcher [Regexp] The expression to match.
56
- # @param negative_matcher [Regexp] The expression NOT to match.
57
- # @return [Boolean] `true` if matching succeeded, `false otherwise`.
58
- def self.disambiguate_browser(agent, positive_matcher, negative_matcher)
59
- agent =~ positive_matcher && agent !~ negative_matcher
60
- end
61
-
62
- # Performs a match against a target.
63
- #
64
- # @param matcher [Object] The matcher to run, can be a `Regexp`, a `Proc` or a string.
65
- # @param target [String] The string to match.
66
- # @param args [Array] Arguments to pass to the matcher. The first is definition itself.
67
- # @return [Object|NilClass] A match if matcher succeeded, `nil` otherwise.
68
- def perform_match(matcher, target, args)
69
- if matcher.is_a?(::Regexp)
70
- matcher.match(target)
71
- elsif matcher.respond_to?(:call)
72
- matcher.call(*args)
73
- elsif target == matcher
74
- target
75
- else
76
- nil
77
- end
78
- end
79
- end
80
- end
@@ -1,68 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # The interface of brauser browsers.
9
- module Browseable
10
- # The default browsers definitions.
11
- module DefaultDefinitions
12
- # Default mobile browsers.
13
- MOBILE_BROWSERS = [
14
- [:coremedia, "Apple CoreMedia", /coremedia/i, /.+CoreMedia v([a-z0-9.]+)/i],
15
-
16
- [:opera_mobile, "Opera Mobile", /opera mobi/i, /.+Opera Mobi.+((.+Opera )|(Version\/))([a-z0-9.]+)/i],
17
- [:opera, "Opera", /opera/i, proc { |_, agent|
18
- version = ((agent !~ /wii/i) ? /((.+Opera )|(Version\/))(?<version>[a-z0-9.]+)/i : /(.+Nintendo Wii; U; ; )(?<version>[a-z0-9.]+)/i).match(agent)
19
- version ? version["version"] : nil
20
- }],
21
-
22
- [:android, "Android", /android/i, /(.+Android )([a-z0-9.]+)/i],
23
- [:blackberry, "RIM BlackBerry", /blackberry/i, /(.+Version\/)([a-z0-9.]+)/i],
24
- [:kindle, "Amazon Kindle", /(kindle)/i, /(.+(Kindle|Silk)\/)([a-z0-9.]+)/i],
25
- [:psp, "Sony Playstation Portable", /psp/i, /(.+PlayStation Portable\); )([a-z0-9.]+)/i],
26
- [:ps3, "Sony Playstation 3", /playstation 3/i, /(.+PLAYSTATION 3; )([a-z0-9.]+)/i],
27
- [:windows_phone, "Microsoft Windows Phone", /windows phone/i, /(.+IEMobile\/)([a-z0-9.]+)/i],
28
- [:wii, "Nintendo Wii", /nintendo wii/, /(.+Nintendo Wii; U; ; )([a-z0-9.]+)/i],
29
-
30
- [:chrome_ios, "Chrome iOS", /crios/i, /(.+CriOS\/)([a-z0-9.]+)/i],
31
- [:ipod, "Apple iPod", /ipod/i, /(.+Version\/)([a-z0-9.]+)/i],
32
- [:iphone, "Apple iPhone", /iphone/i, /(.+Version\/)([a-z0-9.]+)/i],
33
- [:ipad, "Apple iPad", /ipad/i, /(.+Version\/)([a-z0-9.]+)/i],
34
-
35
- [:mobile, "Other Mobile Browser", /(mobile|symbian|midp|windows ce)/i, /.+\/([a-z0-9.]+)/i]
36
- ]
37
-
38
- # Default major desktop browsers.
39
- MAJOR_DESKTOP_BROWSERS = [
40
- [:chrome, "Google Chrome", /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i],
41
- [:netscape, "Netscape Navigator", /(netscape|navigator)\//i, /((Netscape|Navigator)\/)([a-z0-9.]+)/i],
42
- [:firefox, "Mozilla Firefox", /firefox/i, /(.+Firefox\/)([a-z0-9.]+)/i],
43
- [:safari, "Apple Safari", proc { |_, agent|
44
- Brauser::Definition.disambiguate_browser(agent, /safari/i, /((chrome)|(chromium)|(crios))/i)
45
- }, /(.+Version\/)([a-z0-9.]+)/i]
46
- ]
47
-
48
- # Default Microsoft Internet Explorer browsers.
49
- MSIE_BROWSERS = [
50
- [:msie_compatibility, "Microsoft Internet Explorer (Compatibility View)", /(msie 7\.0).+(trident)/i, proc { |_, agent|
51
- version = /(.+trident\/)(?<version>[a-z0-9.]+)/i.match(agent)["version"].split(".")
52
- version[0] = version[0].to_integer + 4
53
- version.join(".")
54
- }],
55
- [:msie, "Microsoft Internet Explorer", proc {
56
- |_, agent| Brauser::Definition.disambiguate_browser(agent, /trident|msie/i, /opera/i)
57
- }, /(.+MSIE |trident.+rv:)([a-z0-9.]+)/i]
58
- ]
59
-
60
- # Default minor desktop browsers.
61
- MINOR_DESKTOP_BROWSERS = [
62
- [:quicktime, "Apple QuickTime", /quicktime/i, /(.+((QuickTime\/)|(qtver=)))([a-z0-9.]+)/i],
63
- [:webkit, "WebKit Browser", /webkit/i, /(.+WebKit\/)([a-z0-9.]+)/i],
64
- [:gecko, "Gecko Browser", /gecko/i, /(.+rv:|Gecko\/)([a-z0-9.]+)/i]
65
- ]
66
- end
67
- end
68
- end
@@ -1,130 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # The interface of brauser browsers.
9
- module Browseable
10
- # The default browsers definitions.
11
- module DefaultDefinitions
12
- # Default languages.
13
- LANGUAGES = {
14
- "af" => "Afrikaans",
15
- "sq" => "Albanian",
16
- "eu" => "Basque",
17
- "bg" => "Bulgarian",
18
- "be" => "Byelorussian",
19
- "ca" => "Catalan",
20
- "zh" => "Chinese",
21
- "zh-cn" => "Chinese/China",
22
- "zh-tw" => "Chinese/Taiwan",
23
- "zh-hk" => "Chinese/Hong Kong",
24
- "zh-sg" => "Chinese/singapore",
25
- "hr" => "Croatian",
26
- "cs" => "Czech",
27
- "da" => "Danish",
28
- "nl" => "Dutch",
29
- "nl-nl" => "Dutch/Netherlands",
30
- "nl-be" => "Dutch/Belgium",
31
- "en" => "English",
32
- "en-gb" => "English/United Kingdom",
33
- "en-us" => "English/United States",
34
- "en-au" => "English/Australian",
35
- "en-ca" => "English/Canada",
36
- "en-nz" => "English/New Zealand",
37
- "en-ie" => "English/Ireland",
38
- "en-za" => "English/South Africa",
39
- "en-jm" => "English/Jamaica",
40
- "en-bz" => "English/Belize",
41
- "en-tt" => "English/Trinidad",
42
- "et" => "Estonian",
43
- "fo" => "Faeroese",
44
- "fa" => "Farsi",
45
- "fi" => "Finnish",
46
- "fr" => "French",
47
- "fr-be" => "French/Belgium",
48
- "fr-fr" => "French/France",
49
- "fr-ch" => "French/Switzerland",
50
- "fr-ca" => "French/Canada",
51
- "fr-lu" => "French/Luxembourg",
52
- "gd" => "Gaelic",
53
- "gl" => "Galician",
54
- "de" => "German",
55
- "de-at" => "German/Austria",
56
- "de-de" => "German/Germany",
57
- "de-ch" => "German/Switzerland",
58
- "de-lu" => "German/Luxembourg",
59
- "de-li" => "German/Liechtenstein",
60
- "el" => "Greek",
61
- "he" => "Hebrew",
62
- "he-il" => "Hebrew/Israel",
63
- "hi" => "Hindi",
64
- "hu" => "Hungarian",
65
- "ie-ee" => "Internet Explorer/Easter Egg",
66
- "is" => "Icelandic",
67
- "id" => "Indonesian",
68
- "in" => "Indonesian",
69
- "ga" => "Irish",
70
- "it" => "Italian",
71
- "it-ch" => "Italian/ Switzerland",
72
- "ja" => "Japanese",
73
- "km" => "Khmer",
74
- "km-kh" => "Khmer/Cambodia",
75
- "ko" => "Korean",
76
- "lv" => "Latvian",
77
- "lt" => "Lithuanian",
78
- "mk" => "Macedonian",
79
- "ms" => "Malaysian",
80
- "mt" => "Maltese",
81
- "no" => "Norwegian",
82
- "pl" => "Polish",
83
- "pt" => "Portuguese",
84
- "pt-br" => "Portuguese/Brazil",
85
- "rm" => "Rhaeto-Romanic",
86
- "ro" => "Romanian",
87
- "ro-mo" => "Romanian/Moldavia",
88
- "ru" => "Russian",
89
- "ru-mo" => "Russian /Moldavia",
90
- "sr" => "Serbian",
91
- "sk" => "Slovack",
92
- "sl" => "Slovenian",
93
- "sb" => "Sorbian",
94
- "es" => "Spanish",
95
- "es-do" => "Spanish",
96
- "es-ar" => "Spanish/Argentina",
97
- "es-co" => "Spanish/Colombia",
98
- "es-mx" => "Spanish/Mexico",
99
- "es-es" => "Spanish/Spain",
100
- "es-gt" => "Spanish/Guatemala",
101
- "es-cr" => "Spanish/Costa Rica",
102
- "es-pa" => "Spanish/Panama",
103
- "es-ve" => "Spanish/Venezuela",
104
- "es-pe" => "Spanish/Peru",
105
- "es-ec" => "Spanish/Ecuador",
106
- "es-cl" => "Spanish/Chile",
107
- "es-uy" => "Spanish/Uruguay",
108
- "es-py" => "Spanish/Paraguay",
109
- "es-bo" => "Spanish/Bolivia",
110
- "es-sv" => "Spanish/El salvador",
111
- "es-hn" => "Spanish/Honduras",
112
- "es-ni" => "Spanish/Nicaragua",
113
- "es-pr" => "Spanish/Puerto Rico",
114
- "sx" => "Sutu",
115
- "sv" => "Swedish",
116
- "sv-se" => "Swedish/Sweden",
117
- "sv-fi" => "Swedish/Finland",
118
- "ts" => "Thai",
119
- "tn" => "Tswana",
120
- "tr" => "Turkish",
121
- "uk" => "Ukrainian",
122
- "ur" => "Urdu",
123
- "vi" => "Vietnamese",
124
- "xh" => "Xshosa",
125
- "ji" => "Yiddish",
126
- "zu" => "Zulu"
127
- }
128
- end
129
- end
130
- end
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # The interface of brauser browsers.
9
- module Browseable
10
- # The default browsers definitions.
11
- module DefaultDefinitions
12
- # Default platforms.
13
- PLATFORMS = [
14
- [:symbian, "Symbian", /s60|symb/i],
15
- [:windows_phone, "Microsoft Windows Phone", /windows phone/i],
16
- [:kindle, "Nokia Symbian", /kindle|silk/i],
17
- [:ios, "Apple iOS", proc { |_, agent| [:iphone, :ipad, :ipod, :chrome_ios].include?(name) || agent =~ /ipad|iphone|ipod|crios/i }],
18
- [:android, "Android", /android/i],
19
- [:blackberry, "RIM BlackBerry", /blackberry/i],
20
- [:psp, "Sony Playstation Portable", /psp/i],
21
- [:ps3, "Sony Playstation 3", /playstation 3/i],
22
- [:wii, "Nintendo Wii", /wii/i],
23
-
24
- [:linux, "Linux", /linux/i],
25
- [:osx, "Apple MacOS X", /mac|macintosh|mac os x/i],
26
- [:windows, "Microsoft Windows", /windows/i]
27
- ]
28
- end
29
- end
30
- end
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # A query to a browser. This class enables concatenation, like:
9
- #
10
- # ```ruby
11
- # Brauser::Browser.new.is(:msie).version(">= 7").on?(:windows)
12
- # ```
13
- #
14
- # To end concatenation, use the `?` form of the queries or call `.result`.
15
- #
16
- # @attribute target
17
- # @return [Browser] The current browser.
18
- # @attribute result
19
- # @return [Boolean] The current result.
20
- class Query
21
- attr_accessor :target
22
- attr_accessor :result
23
-
24
- include Brauser::Queryable::Chainers
25
- include Brauser::Queryable::Queries
26
-
27
- # Creates a new query.
28
- #
29
- # @param target [Browser] The current browser.
30
- # @param result [Boolean] The current result.
31
- def initialize(target, result = true)
32
- @target = target
33
- @result = result
34
- end
35
- end
36
- end
@@ -1,56 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # This file is part of the brauser gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
- # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
- #
6
-
7
- module Brauser
8
- # The interface of brauser queries.
9
- module Queryable
10
- # Methods to chain queries.
11
- module Chainers
12
- # Checks if the browser is a specific name and optionally of a specific version and platform.
13
- #
14
- # @see #version?
15
- # @see #on?
16
- #
17
- # @param names [Symbol|Array] A list of specific names to match. Also, this meta-names are supported: `:capable` and `:tablet`.
18
- # @param versions [Hash] An hash with specific version to match against. Need to be in any form that {#v} understands.
19
- # @param platforms [Symbol|Array] A list of specific platform to match. Valid values are all those possible for the platform attribute.
20
- # @return [Query] The query itself.
21
- def is(names = [], versions = {}, platforms = [])
22
- @result = is?(names, versions, platforms)
23
- self
24
- end
25
-
26
- # Checks if the browser is a specific version.
27
- #
28
- # @param versions [String|Hash] A string in the form `operator version && ...` (example: `>= 7 && < 4`) or an hash with specific version to match against,
29
- # in form `{:operator => version}`, where operator is one of `:lt, :lte, :eq, :gt, :gte`.
30
- # @return [Query] The query itself.
31
- def version(versions = {})
32
- @result = version?(versions)
33
- self
34
- end
35
- alias_method :v, :version
36
-
37
- # Check if the browser is on a specific platform.
38
- #
39
- # @param platforms [Symbol|Array] A list of specific platform to match.
40
- # @return [Query] The query itself.
41
- def on(platforms = [])
42
- @result = on?(platforms)
43
- self
44
- end
45
-
46
- # Check if the browser accepts the specified languages.
47
- #
48
- # @param langs [String|Array] A list of languages to match against.
49
- # @return [Query] The query itself.
50
- def accepts(langs = [])
51
- @result = accepts?(langs)
52
- self
53
- end
54
- end
55
- end
56
- end