brauser 3.2.6 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +29 -0
  4. data/.travis-gemfile +1 -1
  5. data/.travis.yml +2 -1
  6. data/Gemfile +3 -3
  7. data/README.md +6 -6
  8. data/brauser.gemspec +1 -1
  9. data/doc/Brauser.html +7 -7
  10. data/doc/Brauser/Browseable.html +127 -0
  11. data/doc/Brauser/{BrowserMethods → Browseable}/Attributes.html +34 -30
  12. data/doc/Brauser/Browseable/DefaultDefinitions.html +387 -0
  13. data/doc/Brauser/{BrowserMethods → Browseable}/General.html +9 -9
  14. data/doc/Brauser/{BrowserMethods → Browseable}/General/ClassMethods.html +33 -33
  15. data/doc/Brauser/{BrowserMethods → Browseable}/Parsing.html +23 -23
  16. data/doc/Brauser/{BrowserMethods → Browseable}/PartialQuerying.html +59 -53
  17. data/doc/Brauser/{BrowserMethods → Browseable}/Querying.html +43 -37
  18. data/doc/Brauser/{BrowserMethods → Browseable}/Register.html +9 -9
  19. data/doc/Brauser/Browseable/Register/ClassMethods.html +516 -0
  20. data/doc/Brauser/Browser.html +787 -1362
  21. data/doc/Brauser/Definition.html +230 -40
  22. data/doc/Brauser/Hooks.html +4 -4
  23. data/doc/Brauser/Hooks/RubyOnRails.html +4 -4
  24. data/doc/Brauser/Query.html +53 -53
  25. data/doc/Brauser/{BrowserMethods.html → Queryable.html} +13 -11
  26. data/doc/Brauser/{Chainers.html → Queryable/Chainers.html} +51 -45
  27. data/doc/Brauser/{Queries.html → Queryable/Queries.html} +47 -41
  28. data/doc/Brauser/Version.html +6 -6
  29. data/doc/_index.html +41 -27
  30. data/doc/class_list.html +1 -1
  31. data/doc/css/style.css +1 -0
  32. data/doc/file.README.html +10 -10
  33. data/doc/frames.html +1 -1
  34. data/doc/index.html +10 -10
  35. data/doc/method_list.html +68 -74
  36. data/doc/top-level-namespace.html +4 -4
  37. data/lib/brauser.rb +14 -3
  38. data/lib/brauser/browseable/attributes.rb +95 -0
  39. data/lib/brauser/browseable/general.rb +104 -0
  40. data/lib/brauser/browseable/parsing.rb +127 -0
  41. data/lib/brauser/browseable/partial_querying.rb +116 -0
  42. data/lib/brauser/browseable/querying.rb +63 -0
  43. data/lib/brauser/browseable/register.rb +73 -0
  44. data/lib/brauser/browser.rb +34 -741
  45. data/lib/brauser/definition.rb +30 -5
  46. data/lib/brauser/definitions/browsers.rb +66 -0
  47. data/lib/brauser/definitions/languages.rb +130 -0
  48. data/lib/brauser/definitions/platforms.rb +30 -0
  49. data/lib/brauser/query.rb +4 -99
  50. data/lib/brauser/queryable/chainers.rb +56 -0
  51. data/lib/brauser/queryable/queries.rb +60 -0
  52. data/lib/brauser/version.rb +3 -2
  53. data/spec/brauser/browser_spec.rb +26 -29
  54. data/spec/brauser/query_spec.rb +15 -13
  55. metadata +30 -17
  56. data/.bundle/install.log +0 -106
  57. data/doc/Brauser/BrowserMethods/Register/ClassMethods.html +0 -770
@@ -38,12 +38,37 @@ module Brauser
38
38
  # @param args [Array] Arguments to pass to the matcher. The first is the definition itself.
39
39
  # @return [Object|NilClass] A match if matcher succeeded, `nil` otherwise.
40
40
  def match(type, *args)
41
- matcher = self.send(type || :primary) rescue nil
42
- target = args[1]
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
43
51
 
44
- if matcher.is_a?(::Regexp) then
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)
45
70
  matcher.match(target)
46
- elsif matcher.respond_to?(:call) then
71
+ elsif matcher.respond_to?(:call)
47
72
  matcher.call(*args)
48
73
  elsif target == matcher
49
74
  target
@@ -52,4 +77,4 @@ module Brauser
52
77
  end
53
78
  end
54
79
  end
55
- end
80
+ end
@@ -0,0 +1,66 @@
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 { |_, agent| Brauser::Definition.disambiguate_browser(agent, /msie/i, /opera/i) }, /(.+MSIE )([a-z0-9.]+)/i]
56
+ ]
57
+
58
+ # Default minor desktop browsers.
59
+ MINOR_DESKTOP_BROWSERS = [
60
+ [:quicktime, "Apple QuickTime", /quicktime/i, /(.+((QuickTime\/)|(qtver=)))([a-z0-9.]+)/i],
61
+ [:webkit, "WebKit Browser", /webkit/i, /(.+WebKit\/)([a-z0-9.]+)/i],
62
+ [:gecko, "Gecko Browser", /gecko/i, /(.+rv:|Gecko\/)([a-z0-9.]+)/i]
63
+ ]
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,130 @@
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
@@ -0,0 +1,30 @@
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
data/lib/brauser/query.rb CHANGED
@@ -4,106 +4,11 @@
4
4
  # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
5
  #
6
6
 
7
- # A framework agnostic browser detection and querying helper.
8
7
  module Brauser
9
- # Methods to chain queries.
10
- module Chainers
11
- # Checks if the browser is a specific name and optionally of a specific version and platform.
12
- #
13
- # @see #version?
14
- # @see #on?
15
- #
16
- # @param names [Symbol|Array] A list of specific names to match. Also, this meta-names are supported: `:capable` and `:tablet`.
17
- # @param versions [Hash] An hash with specific version to match against. Need to be in any form that {#v} understands.
18
- # @param platforms [Symbol|Array] A list of specific platform to match. Valid values are all those possible for the platform attribute.
19
- # @return [Query] The query itself.
20
- def is(names = [], versions = {}, platforms = [])
21
- @result = is?(names, versions, platforms)
22
- self
23
- end
24
-
25
- # Checks if the browser is a specific version.
26
- #
27
- # @param versions [String|Hash] A string in the form `operator version && ...` (example: `>= 7 && < 4`) or an hash with specific version to match against,
28
- # in form `{:operator => version}`, where operator is one of `:lt, :lte, :eq, :gt, :gte`.
29
- # @return [Query] The query itself.
30
- def v(versions = {})
31
- @result = v?(versions)
32
- self
33
- end
34
-
35
- # Check if the browser is on a specific platform.
36
- #
37
- # @param platforms [Symbol|Array] A list of specific platform to match.
38
- # @return [Query] The query itself.
39
- def on(platforms = [])
40
- @result = on?(platforms)
41
- self
42
- end
43
-
44
- # Check if the browser accepts the specified languages.
45
- #
46
- # @param langs [String|Array] A list of languages to match against.
47
- # @return [Query] The query itself.
48
- def accepts(langs = [])
49
- @result = accepts?(langs)
50
- self
51
- end
52
- end
53
-
54
- # Methods to make queries.
55
- module Queries
56
- # Checks if the browser is a specific name and optionally of a specific version and platform.
57
- #
58
- # This version returns a boolean and it is equal to append a call to `#result` to the method `#is`.
59
- #
60
- # @see #v?
61
- # @see #on?
62
- #
63
- # @param names [Symbol|Array] A list of specific names to match. Also, this meta-names are supported: `:capable` and `:tablet`.
64
- # @param versions [Hash] An hash with specific version to match against. Need to be in any form that `#v` understands.
65
- # @param platforms [Symbol|Array] A list of specific platform to match. Valid values are all those possible for the platform attribute.
66
- # @return [Boolean] `true` if current browser matches, `false` otherwise.
67
- def is?(names = [], versions = {}, platforms = [])
68
- @result ? @target.is?(names, versions, platforms) : @result
69
- end
70
-
71
- # Checks if the browser is a specific version.
72
- #
73
- # This version returns a boolean and it is equal to append a call to `#result` to the method `#v`.
74
- #
75
- # @param versions [String|Hash] A string in the form `operator version && ...` (example: `>= 7 && < 4`) or an hash with specific version to match against,
76
- # in form `{:operator => version}`, where operator is one of `:lt, :lte, :eq, :gt, :gte`.
77
- # @return [Boolean] `true` if current browser matches, `false` otherwise.
78
- def v?(versions = {})
79
- @result ? @target.v?(versions) : @result
80
- end
81
-
82
- # Check if the browser is on a specific platform.
83
- #
84
- # This version returns a boolean and it is equal to append a call to `#result` to the method `#on.
85
- #
86
- # @param platforms [Symbol|Array] A list of specific platform to match.
87
- # @return [Boolean] `true` if current browser matches, `false` otherwise.
88
- def on?(platforms = [])
89
- @result ? @target.on?(platforms) : @result
90
- end
91
-
92
- # Check if the browser accepts the specified languages.
93
- #
94
- # This version returns a boolean and it is equal to append a call to `#result` to the method `#accepts.
95
- #
96
- # @param langs [String|Array] A list of languages to match against.
97
- # @return [Boolean] `true` if current browser matches, `false` otherwise.
98
- def accepts?(langs = [])
99
- @result ? @target.accepts?(langs) : @result
100
- end
101
- end
102
-
103
8
  # A query to a browser. This class enables concatenation, like:
104
9
  #
105
10
  # ```ruby
106
- # Brauser::Browser.new.is(:msie).v(">= 7").on?(:windows)
11
+ # Brauser::Browser.new.is(:msie).version(">= 7").on?(:windows)
107
12
  # ```
108
13
  #
109
14
  # To end concatenation, use the `?` form of the queries or call `.result`.
@@ -116,8 +21,8 @@ module Brauser
116
21
  attr_accessor :target
117
22
  attr_accessor :result
118
23
 
119
- include Brauser::Chainers
120
- include Brauser::Queries
24
+ include Brauser::Queryable::Chainers
25
+ include Brauser::Queryable::Queries
121
26
 
122
27
  # Creates a new query.
123
28
  #
@@ -128,4 +33,4 @@ module Brauser
128
33
  @result = result
129
34
  end
130
35
  end
131
- end
36
+ end
@@ -0,0 +1,56 @@
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