brauser 3.2.2 → 3.2.3
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/.gitignore +3 -0
- data/.travis-gemfile +2 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -4
- data/README.md +1 -0
- data/brauser.gemspec +2 -1
- data/doc/Brauser.html +3 -3
- data/doc/Brauser/Browser.html +252 -252
- data/doc/Brauser/BrowserMethods.html +3 -3
- data/doc/Brauser/BrowserMethods/Attributes.html +20 -20
- data/doc/Brauser/BrowserMethods/General.html +3 -3
- data/doc/Brauser/BrowserMethods/General/ClassMethods.html +27 -27
- data/doc/Brauser/BrowserMethods/Parsing.html +18 -18
- data/doc/Brauser/BrowserMethods/PartialQuerying.html +40 -38
- data/doc/Brauser/BrowserMethods/Querying.html +126 -21
- data/doc/Brauser/BrowserMethods/Register.html +3 -3
- data/doc/Brauser/BrowserMethods/Register/ClassMethods.html +5 -5
- data/doc/Brauser/Chainers.html +14 -13
- data/doc/Brauser/Definition.html +33 -23
- data/doc/Brauser/Hooks.html +3 -3
- data/doc/Brauser/Hooks/RubyOnRails.html +3 -3
- data/doc/Brauser/Queries.html +20 -19
- data/doc/Brauser/Query.html +15 -15
- data/doc/Brauser/Version.html +4 -4
- data/doc/_index.html +4 -4
- data/doc/css/style.css +1 -1
- data/doc/file.README.html +5 -4
- data/doc/frames.html +5 -7
- data/doc/index.html +5 -4
- data/doc/js/app.js +7 -2
- data/doc/method_list.html +17 -11
- data/doc/top-level-namespace.html +3 -3
- data/lib/brauser/browser.rb +59 -27
- data/lib/brauser/definition.rb +4 -3
- data/lib/brauser/query.rb +4 -2
- data/lib/brauser/version.rb +1 -1
- data/spec/brauser/browser_spec.rb +16 -0
- data/spec/supported.yml +3 -0
- metadata +9 -5
data/lib/brauser/definition.rb
CHANGED
@@ -39,13 +39,14 @@ module Brauser
|
|
39
39
|
# @return [Object|NilClass] A match if matcher succeeded, `nil` otherwise.
|
40
40
|
def match(type, *args)
|
41
41
|
matcher = self.send(type || :primary) rescue nil
|
42
|
+
target = args[1]
|
42
43
|
|
43
44
|
if matcher.is_a?(::Regexp) then
|
44
|
-
matcher.match(
|
45
|
+
matcher.match(target)
|
45
46
|
elsif matcher.respond_to?(:call) then
|
46
47
|
matcher.call(*args)
|
47
|
-
elsif matcher
|
48
|
-
|
48
|
+
elsif target == matcher
|
49
|
+
target
|
49
50
|
else
|
50
51
|
nil
|
51
52
|
end
|
data/lib/brauser/query.rb
CHANGED
@@ -24,7 +24,8 @@ module Brauser
|
|
24
24
|
|
25
25
|
# Checks if the browser is a specific version.
|
26
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,
|
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`.
|
28
29
|
# @return [Query] The query itself.
|
29
30
|
def v(versions = {})
|
30
31
|
@result = v?(versions)
|
@@ -71,7 +72,8 @@ module Brauser
|
|
71
72
|
#
|
72
73
|
# This version returns a boolean and it is equal to append a call to `#result` to the method `#v`.
|
73
74
|
#
|
74
|
-
# @param versions [String|Hash] A string in the form `operator version && ...` (example: `>= 7 && < 4`) or an hash with specific version to match against,
|
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`.
|
75
77
|
# @return [Boolean] `true` if current browser matches, `false` otherwise.
|
76
78
|
def v?(versions = {})
|
77
79
|
@result ? @target.v?(versions) : @result
|
data/lib/brauser/version.rb
CHANGED
@@ -500,6 +500,22 @@ describe Brauser::Browser do
|
|
500
500
|
end
|
501
501
|
end
|
502
502
|
|
503
|
+
describe "#supported?" do
|
504
|
+
it "should check if the browser is supported starting from a definition map" do
|
505
|
+
browser.parse_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.82 Safari/537.1")
|
506
|
+
expect(browser.supported?(chrome: 21)).to be_true
|
507
|
+
expect(browser.supported?(chrome: 31)).to be_false
|
508
|
+
expect(browser.supported?(chrome: "21.2")).to be_false
|
509
|
+
expect(browser.supported?(firefox: 11)).to be_false
|
510
|
+
end
|
511
|
+
|
512
|
+
it "should load definition files from a YAML file" do
|
513
|
+
path = File.dirname(__FILE__) + "/../supported.yml"
|
514
|
+
browser.parse_agent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.82 Safari/537.1")
|
515
|
+
expect(browser.supported?(path)).to be_true
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
503
519
|
describe "#initalize" do
|
504
520
|
it "initialized definitions" do
|
505
521
|
expect(::Brauser::Browser).to receive(:add_default_browsers)
|
data/spec/supported.yml
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brauser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shogun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lazier
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.3.
|
19
|
+
version: 3.3.9
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.3.
|
26
|
+
version: 3.3.9
|
27
27
|
description: A framework agnostic browser detection and querying helper.
|
28
28
|
email:
|
29
29
|
- shogun@cowtech.it
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- .travis-gemfile
|
36
36
|
- .travis.yml
|
37
37
|
- .yardopts
|
38
|
+
- CHANGELOG.md
|
38
39
|
- Gemfile
|
39
40
|
- README.md
|
40
41
|
- Rakefile
|
@@ -83,8 +84,10 @@ files:
|
|
83
84
|
- spec/brauser/query_spec.rb
|
84
85
|
- spec/coverage_helper.rb
|
85
86
|
- spec/spec_helper.rb
|
87
|
+
- spec/supported.yml
|
86
88
|
homepage: http://sw.cow.tc/brauser
|
87
|
-
licenses:
|
89
|
+
licenses:
|
90
|
+
- MIT
|
88
91
|
metadata: {}
|
89
92
|
post_install_message:
|
90
93
|
rdoc_options: []
|
@@ -113,4 +116,5 @@ test_files:
|
|
113
116
|
- spec/brauser/query_spec.rb
|
114
117
|
- spec/coverage_helper.rb
|
115
118
|
- spec/spec_helper.rb
|
119
|
+
- spec/supported.yml
|
116
120
|
has_rdoc:
|