brauser 4.0.0 → 4.1.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.
data/doc/js/full_list.js CHANGED
@@ -123,7 +123,10 @@ function linkList() {
123
123
  }
124
124
  }
125
125
  if (clicked) clicked.removeClass('clicked');
126
- var win = window.top.frames.main ? window.top.frames.main : window.parent;
126
+ var win;
127
+ try {
128
+ win = window.top.frames.main ? window.top.frames.main : window.parent;
129
+ } catch (e) { win = window.parent; }
127
130
  if (this.tagName.toLowerCase() == "a") {
128
131
  clicked = $(this).parents('li').addClass('clicked');
129
132
  win.location = this.href;
data/doc/method_list.html CHANGED
@@ -20,7 +20,11 @@
20
20
  </head>
21
21
  <body>
22
22
  <script type="text/javascript" charset="utf-8">
23
- if (window.top.frames.main) {
23
+ var hasFrames = false;
24
+ try {
25
+ hasFrames = window.top.frames.main ? true : false;
26
+ } catch (e) { }
27
+ if (hasFrames) {
24
28
  document.getElementById('base_target').target = 'main';
25
29
  document.body.className = 'frames';
26
30
  }
@@ -138,20 +142,20 @@
138
142
 
139
143
 
140
144
  <li class="r2 ">
141
- <span class='object_link'><a href="Brauser/Value.html#initialize-instance_method" title="Brauser::Value#initialize (method)">#initialize</a></span>
142
- <small>Brauser::Value</small>
145
+ <span class='object_link'><a href="Brauser/Definitions/Platform.html#initialize-instance_method" title="Brauser::Definitions::Platform#initialize (method)">#initialize</a></span>
146
+ <small>Brauser::Definitions::Platform</small>
143
147
  </li>
144
148
 
145
149
 
146
150
  <li class="r1 ">
147
- <span class='object_link'><a href="Brauser/Definitions/Browser.html#initialize-instance_method" title="Brauser::Definitions::Browser#initialize (method)">#initialize</a></span>
148
- <small>Brauser::Definitions::Browser</small>
151
+ <span class='object_link'><a href="Brauser/Value.html#initialize-instance_method" title="Brauser::Value#initialize (method)">#initialize</a></span>
152
+ <small>Brauser::Value</small>
149
153
  </li>
150
154
 
151
155
 
152
156
  <li class="r2 ">
153
- <span class='object_link'><a href="Brauser/Definitions/Platform.html#initialize-instance_method" title="Brauser::Definitions::Platform#initialize (method)">#initialize</a></span>
154
- <small>Brauser::Definitions::Platform</small>
157
+ <span class='object_link'><a href="Brauser/Definitions/Browser.html#initialize-instance_method" title="Brauser::Definitions::Browser#initialize (method)">#initialize</a></span>
158
+ <small>Brauser::Definitions::Browser</small>
155
159
  </li>
156
160
 
157
161
 
@@ -192,14 +196,14 @@
192
196
 
193
197
 
194
198
  <li class="r1 ">
195
- <span class='object_link'><a href="Brauser/Definitions/Browser.html#match-instance_method" title="Brauser::Definitions::Browser#match (method)">#match</a></span>
196
- <small>Brauser::Definitions::Browser</small>
199
+ <span class='object_link'><a href="Brauser/Definitions/Platform.html#match-instance_method" title="Brauser::Definitions::Platform#match (method)">#match</a></span>
200
+ <small>Brauser::Definitions::Platform</small>
197
201
  </li>
198
202
 
199
203
 
200
204
  <li class="r2 ">
201
- <span class='object_link'><a href="Brauser/Definitions/Platform.html#match-instance_method" title="Brauser::Definitions::Platform#match (method)">#match</a></span>
202
- <small>Brauser::Definitions::Platform</small>
205
+ <span class='object_link'><a href="Brauser/Definitions/Browser.html#match-instance_method" title="Brauser::Definitions::Browser#match (method)">#match</a></span>
206
+ <small>Brauser::Definitions::Browser</small>
203
207
  </li>
204
208
 
205
209
 
@@ -210,20 +214,20 @@
210
214
 
211
215
 
212
216
  <li class="r2 ">
213
- <span class='object_link'><a href="Brauser/Value.html#method_missing-instance_method" title="Brauser::Value#method_missing (method)">#method_missing</a></span>
214
- <small>Brauser::Value</small>
217
+ <span class='object_link'><a href="Brauser/Browser.html#method_missing-instance_method" title="Brauser::Browser#method_missing (method)">#method_missing</a></span>
218
+ <small>Brauser::Browser</small>
215
219
  </li>
216
220
 
217
221
 
218
222
  <li class="r1 ">
219
- <span class='object_link'><a href="Brauser/Browser.html#method_missing-instance_method" title="Brauser::Browser#method_missing (method)">#method_missing</a></span>
220
- <small>Brauser::Browser</small>
223
+ <span class='object_link'><a href="Brauser/Value.html#method_missing-instance_method" title="Brauser::Value#method_missing (method)">#method_missing</a></span>
224
+ <small>Brauser::Value</small>
221
225
  </li>
222
226
 
223
227
 
224
228
  <li class="r2 ">
225
- <span class='object_link'><a href="Brauser/Definitions/Language.html#name-instance_method" title="Brauser::Definitions::Language#name (method)">#name</a></span>
226
- <small>Brauser::Definitions::Language</small>
229
+ <span class='object_link'><a href="Brauser/Definitions/Platform.html#name-instance_method" title="Brauser::Definitions::Platform#name (method)">#name</a></span>
230
+ <small>Brauser::Definitions::Platform</small>
227
231
  </li>
228
232
 
229
233
 
@@ -234,8 +238,8 @@
234
238
 
235
239
 
236
240
  <li class="r2 ">
237
- <span class='object_link'><a href="Brauser/Definitions/Platform.html#name-instance_method" title="Brauser::Definitions::Platform#name (method)">#name</a></span>
238
- <small>Brauser::Definitions::Platform</small>
241
+ <span class='object_link'><a href="Brauser/Definitions/Language.html#name-instance_method" title="Brauser::Definitions::Language#name (method)">#name</a></span>
242
+ <small>Brauser::Definitions::Language</small>
239
243
  </li>
240
244
 
241
245
 
@@ -276,18 +280,24 @@
276
280
 
277
281
 
278
282
  <li class="r1 ">
283
+ <span class='object_link'><a href="Brauser/Browser.html#supported%3F-instance_method" title="Brauser::Browser#supported? (method)">#supported?</a></span>
284
+ <small>Brauser::Browser</small>
285
+ </li>
286
+
287
+
288
+ <li class="r2 ">
279
289
  <span class='object_link'><a href="Brauser/Value.html#value-instance_method" title="Brauser::Value#value (method)">#value</a></span>
280
290
  <small>Brauser::Value</small>
281
291
  </li>
282
292
 
283
293
 
284
- <li class="r2 ">
294
+ <li class="r1 ">
285
295
  <span class='object_link'><a href="Brauser/Browser.html#version-instance_method" title="Brauser::Browser#version (method)">#version</a></span>
286
296
  <small>Brauser::Browser</small>
287
297
  </li>
288
298
 
289
299
 
290
- <li class="r1 ">
300
+ <li class="r2 ">
291
301
  <span class='object_link'><a href="Brauser/Definitions/Browser.html#version_matcher-instance_method" title="Brauser::Definitions::Browser#version_matcher (method)">#version_matcher</a></span>
292
302
  <small>Brauser::Definitions::Browser</small>
293
303
  </li>
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.8.7.4
9
+ &mdash; Documentation by YARD 0.8.7.6
10
10
 
11
11
  </title>
12
12
 
@@ -103,9 +103,9 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Mon Sep 29 16:43:31 2014 by
106
+ Generated on Mon Mar 2 13:10:31 2015 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.7.4 (ruby-2.1.3).
108
+ 0.8.7.6 (ruby-2.2.0).
109
109
  </div>
110
110
 
111
111
  </body>
@@ -73,13 +73,13 @@ module Brauser
73
73
 
74
74
  # Checks if the browser matches a specific query.
75
75
  #
76
- # @param name [Symbol|Array] The list of names to check. Also, this meta-name is supported: `:tablet`.
77
- # @param engine [Symbol|Array] Alias for `name`, **which has precedence over this.**
78
- # @param version [String] The query to match the version.
76
+ # @param name [Symbol|Array|NilClass] The list of names to check. Also, this meta-name is supported: `:tablet`.
77
+ # @param engine [Symbol|Array|NilClass] Alias for `name`, **which has precedence over this.**
78
+ # @param version [String|NilClass] The query to match the version.
79
79
  # It must be a query in the form is `OPERATOR VALUE && ..`, where `OPERATOR` is one of `["<", "<=", "=", "==", ">=", ">"]`.
80
80
  # You can also pass the value "capable", which will return true for Webkit browsers, IE 10 or above, Firefox 28 and above and Opera 15 and above.
81
- # @param platform [Symbol|Array] The list of platforms to check.
82
- # @param languages [Symbol|Array] The list of languages to check.
81
+ # @param platform [Symbol|Array|NilClass] The list of platforms to check.
82
+ # @param languages [Symbol|Array|NilClass] The list of languages to check.
83
83
  # @return [Boolean] `true` if browser match the query, `false` otherwise.
84
84
  def is?(name: nil, engine: nil, version: nil, platform: nil, languages: nil)
85
85
  name ||= engine
@@ -90,6 +90,16 @@ module Brauser
90
90
  rv
91
91
  end
92
92
 
93
+ # Check if the browser is supported.
94
+ #
95
+ # @param browsers [Hash|String] A map of name and minimum supported major version, or a path to YAML file containing the map.
96
+ # @return [Boolean] `true` if current browser is supported, `false` otherwise. If the name is not found in the map, `false` is returned.
97
+ def supported?(browsers = {})
98
+ browsers = YAML.load_file(browsers.to_s).symbolize_keys unless browsers.is_a?(Hash)
99
+ minimum_version = browsers.with_indifferent_access[name.value]
100
+ minimum_version ? is?(version: ">= #{minimum_version}") : false
101
+ end
102
+
93
103
  # Check if the browser is a specific one
94
104
  #
95
105
  # @param method The browser engine to check.
@@ -18,7 +18,7 @@ module Brauser
18
18
  #
19
19
  # @param id [Symbol] The platform id.
20
20
  # @param name [String] The platform name.
21
- # @param matcher [Regexp|Proc] The pattern or the block to recognize the platform. **Ignore if a block is given**
21
+ # @param matcher [Regexp|Proc] The pattern or the block to recognize the platform. **Ignored if a block is given.**
22
22
  def initialize(id, name, matcher = /.*/, **_, &block)
23
23
  @id = id
24
24
  @name = name
data/lib/brauser/hooks.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  #
5
5
 
6
6
  module Brauser
7
- # A set of Hooks for adding brauser to web frameworks.
7
+ # A set of hooks for adding brauser to web frameworks.
8
8
  module Hooks
9
9
  # Hook for integration with Ruby on Rails.
10
10
  module RubyOnRails
@@ -13,7 +13,7 @@ module Brauser
13
13
  MAJOR = 4
14
14
 
15
15
  # The minor version.
16
- MINOR = 0
16
+ MINOR = 1
17
17
 
18
18
  # The patch version.
19
19
  PATCH = 0
@@ -101,6 +101,20 @@ describe Brauser::Browser do
101
101
  end
102
102
  end
103
103
 
104
+ describe "#supported?" do
105
+ it "should check whether the browser is supported" do
106
+ expect(subject.supported?({chrome: 21})).to be_truthy
107
+ expect(subject.supported?({chrome: 20})).to be_truthy
108
+ expect(subject.supported?({chrome: 22})).to be_falsey
109
+ expect(subject.supported?({})).to be_falsey
110
+ end
111
+
112
+ it "should load from a file" do
113
+ expect(YAML).to receive(:load_file).with("/dev/null").and_return({chrome: 21})
114
+ expect(subject.supported?("/dev/null")).to be_truthy
115
+ end
116
+ end
117
+
104
118
  describe "#method_missing" do
105
119
  it "should attempt to run #is? with the method as name if it ends with a ?" do
106
120
  expect(subject.chrome?).to be_truthy
data/spec/spec_helper.rb CHANGED
@@ -3,12 +3,5 @@
3
3
  # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
4
4
  #
5
5
 
6
- require "rubygems"
7
6
  require "bundler/setup"
8
- require "brauser"
9
-
10
- RSpec.configure do |config|
11
- config.expect_with :rspec do |c|
12
- c.syntax = :expect
13
- end
14
- end
7
+ require File.dirname(__FILE__) + "/../lib/brauser"
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: 4.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2015-03-02 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: '4.0'
19
+ version: '4.2'
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: '4.0'
26
+ version: '4.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: versionomy
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project: brauser
144
- rubygems_version: 2.2.2
144
+ rubygems_version: 2.4.5
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: A framework agnostic browser detection and querying helper.