brauser 4.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis-gemfile +2 -2
- data/.travis.yml +1 -3
- data/.yardopts +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +3 -3
- data/README.md +30 -2
- data/Rakefile +14 -2
- data/brauser.gemspec +1 -1
- data/doc/Brauser.html +3 -3
- data/doc/Brauser/Browser.html +2208 -1908
- data/doc/Brauser/Definitions.html +29 -25
- data/doc/Brauser/Definitions/Base.html +18 -16
- data/doc/Brauser/Definitions/Browser.html +215 -210
- data/doc/Brauser/Definitions/Language.html +40 -37
- data/doc/Brauser/Definitions/Platform.html +74 -70
- data/doc/Brauser/Hooks.html +4 -4
- data/doc/Brauser/Hooks/RubyOnRails.html +12 -10
- data/doc/Brauser/Parser.html +27 -24
- data/doc/Brauser/Value.html +44 -40
- data/doc/Brauser/Version.html +11 -7
- data/doc/_index.html +4 -4
- data/doc/class_list.html +5 -1
- data/doc/file.README.html +77 -50
- data/doc/file_list.html +5 -1
- data/doc/frames.html +1 -1
- data/doc/index.html +77 -50
- data/doc/js/full_list.js +4 -1
- data/doc/method_list.html +31 -21
- data/doc/top-level-namespace.html +3 -3
- data/lib/brauser/browser.rb +15 -5
- data/lib/brauser/definitions/platform.rb +1 -1
- data/lib/brauser/hooks.rb +1 -1
- data/lib/brauser/version.rb +1 -1
- data/spec/brauser/browser_spec.rb +14 -0
- data/spec/spec_helper.rb +1 -8
- metadata +5 -5
data/doc/Brauser/Value.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Brauser::Value
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7.
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -285,9 +285,10 @@
|
|
285
285
|
<td>
|
286
286
|
<pre class="code"><span class="info file"># File 'lib/brauser/value.rb', line 18</span>
|
287
287
|
|
288
|
-
<span class='kw'>def</span> <span class='
|
289
|
-
<span class='ivar'>@value</span> <span class='
|
290
|
-
<span class='kw'>end</span
|
288
|
+
<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_value identifier id'>value</span><span class='rparen token'>)</span>
|
289
|
+
<span class='rubyid_@value ivar id'>@value</span> <span class='assign token'>=</span> <span class='rubyid_value identifier id'>value</span>
|
290
|
+
<span class='rubyid_end end kw'>end</span>
|
291
|
+
</pre>
|
291
292
|
</td>
|
292
293
|
</tr>
|
293
294
|
</table>
|
@@ -382,9 +383,10 @@
|
|
382
383
|
<td>
|
383
384
|
<pre class="code"><span class="info file"># File 'lib/brauser/value.rb', line 35</span>
|
384
385
|
|
385
|
-
<span class='kw'>def</span> <span class='
|
386
|
-
<span class='ivar'>@value</span><span class='
|
387
|
-
<span class='kw'>end</span
|
386
|
+
<span class='rubyid_def def kw'>def</span> <span class='rubyid_method_missing identifier id'>method_missing</span><span class='lparen token'>(</span><span class='rubyid_method identifier id'>method</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='rubyid_args identifier id'>args</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
|
387
|
+
<span class='rubyid_@value ivar id'>@value</span><span class='dot token'>.</span><span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='rubyid_method identifier id'>method</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='rubyid_args identifier id'>args</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
|
388
|
+
<span class='rubyid_end end kw'>end</span>
|
389
|
+
</pre>
|
388
390
|
</td>
|
389
391
|
</tr>
|
390
392
|
</table>
|
@@ -471,34 +473,35 @@
|
|
471
473
|
<td>
|
472
474
|
<pre class="code"><span class="info file"># File 'lib/brauser/value.rb', line 11</span>
|
473
475
|
|
474
|
-
<span class='kw'>class</span> <span class='
|
475
|
-
<span class='
|
476
|
-
<span class='
|
477
|
-
|
478
|
-
<span class='comment'># Creates a new value
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
<span class='ivar'>@value</span> <span class='
|
483
|
-
<span class='kw'>end</span>
|
484
|
-
|
485
|
-
<span class='comment'># Check if an object is equal to another object or if it is contained in a list of objects
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
<span class='
|
491
|
-
<span class='kw'>end</span>
|
492
|
-
|
493
|
-
<span class='comment'># Delegates all the other values to the wrapped value
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
<span class='ivar'>@value</span><span class='
|
500
|
-
<span class='kw'>end</span>
|
501
|
-
<span class='kw'>end</span
|
476
|
+
<span class='rubyid_class class kw'>class</span> <span class='rubyid_Value constant id'>Value</span>
|
477
|
+
<span class='rubyid_attr_reader identifier id'>attr_reader</span> <span class='symbol val'>:value</span>
|
478
|
+
<span class='rubyid_delegate identifier id'>delegate</span> <span class='symbol val'>:to_s</span><span class='comma token'>,</span> <span class='symbol val'>:inspect</span><span class='comma token'>,</span> <span class='label val'>to:</span> <span class='symbol val'>:value</span>
|
479
|
+
|
480
|
+
<span class='comment val'># Creates a new value</span>
|
481
|
+
<span class='comment val'>#</span>
|
482
|
+
<span class='comment val'># @param value [Object] The wrapped value.</span>
|
483
|
+
<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_value identifier id'>value</span><span class='rparen token'>)</span>
|
484
|
+
<span class='rubyid_@value ivar id'>@value</span> <span class='assign token'>=</span> <span class='rubyid_value identifier id'>value</span>
|
485
|
+
<span class='rubyid_end end kw'>end</span>
|
486
|
+
|
487
|
+
<span class='comment val'># Check if an object is equal to another object or if it is contained in a list of objects.</span>
|
488
|
+
<span class='comment val'>#</span>
|
489
|
+
<span class='comment val'># @param other [Array|Object] The other object to match.</span>
|
490
|
+
<span class='comment val'># @return [Boolean] `true` if the current object is either equal or contained in the other object, `false` otherwise.</span>
|
491
|
+
<span class='rubyid_def def kw'>def</span> <span class='eq op'>==</span><span class='lparen token'>(</span><span class='rubyid_other identifier id'>other</span><span class='rparen token'>)</span>
|
492
|
+
<span class='rubyid_other identifier id'>other</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Array constant id'>Array</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='rubyid_other identifier id'>other</span><span class='dot token'>.</span><span class='rubyid_include? fid id'>include?</span><span class='lparen token'>(</span><span class='rubyid_@value ivar id'>@value</span><span class='rparen token'>)</span> <span class='colon op'>:</span> <span class='lparen token'>(</span><span class='rubyid_@value ivar id'>@value</span> <span class='eq op'>==</span> <span class='rubyid_other identifier id'>other</span><span class='rparen token'>)</span>
|
493
|
+
<span class='rubyid_end end kw'>end</span>
|
494
|
+
|
495
|
+
<span class='comment val'># Delegates all the other values to the wrapped value.</span>
|
496
|
+
<span class='comment val'>#</span>
|
497
|
+
<span class='comment val'># @param method [Symbol] The method to call.</span>
|
498
|
+
<span class='comment val'># @param args [Array] The arguments to pass to the method.</span>
|
499
|
+
<span class='comment val'># @param block [Proc] The block to pass to the method.</span>
|
500
|
+
<span class='rubyid_def def kw'>def</span> <span class='rubyid_method_missing identifier id'>method_missing</span><span class='lparen token'>(</span><span class='rubyid_method identifier id'>method</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='rubyid_args identifier id'>args</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
|
501
|
+
<span class='rubyid_@value ivar id'>@value</span><span class='dot token'>.</span><span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='rubyid_method identifier id'>method</span><span class='comma token'>,</span> <span class='mult op'>*</span><span class='rubyid_args identifier id'>args</span><span class='comma token'>,</span> <span class='bitand op'>&</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
|
502
|
+
<span class='rubyid_end end kw'>end</span>
|
503
|
+
<span class='rubyid_end end kw'>end</span>
|
504
|
+
</pre>
|
502
505
|
</td>
|
503
506
|
</tr>
|
504
507
|
</table>
|
@@ -579,9 +582,10 @@
|
|
579
582
|
<td>
|
580
583
|
<pre class="code"><span class="info file"># File 'lib/brauser/value.rb', line 26</span>
|
581
584
|
|
582
|
-
<span class='kw'>def</span> <span class='op'>==</span><span class='lparen'>(</span><span class='
|
583
|
-
<span class='
|
584
|
-
<span class='kw'>end</span
|
585
|
+
<span class='rubyid_def def kw'>def</span> <span class='eq op'>==</span><span class='lparen token'>(</span><span class='rubyid_other identifier id'>other</span><span class='rparen token'>)</span>
|
586
|
+
<span class='rubyid_other identifier id'>other</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Array constant id'>Array</span><span class='rparen token'>)</span> <span class='question op'>?</span> <span class='rubyid_other identifier id'>other</span><span class='dot token'>.</span><span class='rubyid_include? fid id'>include?</span><span class='lparen token'>(</span><span class='rubyid_@value ivar id'>@value</span><span class='rparen token'>)</span> <span class='colon op'>:</span> <span class='lparen token'>(</span><span class='rubyid_@value ivar id'>@value</span> <span class='eq op'>==</span> <span class='rubyid_other identifier id'>other</span><span class='rparen token'>)</span>
|
587
|
+
<span class='rubyid_end end kw'>end</span>
|
588
|
+
</pre>
|
585
589
|
</td>
|
586
590
|
</tr>
|
587
591
|
</table>
|
@@ -592,9 +596,9 @@
|
|
592
596
|
</div>
|
593
597
|
|
594
598
|
<div id="footer">
|
595
|
-
Generated on Mon
|
599
|
+
Generated on Mon Mar 2 13:10:31 2015 by
|
596
600
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
597
|
-
0.8.7.
|
601
|
+
0.8.7.6 (ruby-2.2.0).
|
598
602
|
</div>
|
599
603
|
|
600
604
|
</body>
|
data/doc/Brauser/Version.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Brauser::Version
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7.
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -119,7 +119,8 @@
|
|
119
119
|
|
120
120
|
</div>
|
121
121
|
</dt>
|
122
|
-
<dd><pre class="code"><span class='
|
122
|
+
<dd><pre class="code"><span class='integer val'>4</span>
|
123
|
+
</pre></dd>
|
123
124
|
|
124
125
|
<dt id="MINOR-constant" class="">MINOR =
|
125
126
|
<div class="docstring">
|
@@ -134,7 +135,8 @@
|
|
134
135
|
|
135
136
|
</div>
|
136
137
|
</dt>
|
137
|
-
<dd><pre class="code"><span class='
|
138
|
+
<dd><pre class="code"><span class='integer val'>1</span>
|
139
|
+
</pre></dd>
|
138
140
|
|
139
141
|
<dt id="PATCH-constant" class="">PATCH =
|
140
142
|
<div class="docstring">
|
@@ -149,7 +151,8 @@
|
|
149
151
|
|
150
152
|
</div>
|
151
153
|
</dt>
|
152
|
-
<dd><pre class="code"><span class='
|
154
|
+
<dd><pre class="code"><span class='integer val'>0</span>
|
155
|
+
</pre></dd>
|
153
156
|
|
154
157
|
<dt id="STRING-constant" class="">STRING =
|
155
158
|
<div class="docstring">
|
@@ -164,7 +167,8 @@
|
|
164
167
|
|
165
168
|
</div>
|
166
169
|
</dt>
|
167
|
-
<dd><pre class="code"><span class='
|
170
|
+
<dd><pre class="code"><span class='lbrack token'>[</span><span class='rubyid_MAJOR constant id'>MAJOR</span><span class='comma token'>,</span> <span class='rubyid_MINOR constant id'>MINOR</span><span class='comma token'>,</span> <span class='rubyid_PATCH constant id'>PATCH</span><span class='rbrack token'>]</span><span class='dot token'>.</span><span class='rubyid_compact identifier id'>compact</span><span class='dot token'>.</span><span class='rubyid_join identifier id'>join</span><span class='lparen token'>(</span><span class='string val'>"."</span><span class='rparen token'>)</span>
|
171
|
+
</pre></dd>
|
168
172
|
|
169
173
|
</dl>
|
170
174
|
|
@@ -180,9 +184,9 @@
|
|
180
184
|
</div>
|
181
185
|
|
182
186
|
<div id="footer">
|
183
|
-
Generated on Mon
|
187
|
+
Generated on Mon Mar 2 13:10:31 2015 by
|
184
188
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
|
-
0.8.7.
|
189
|
+
0.8.7.6 (ruby-2.2.0).
|
186
190
|
</div>
|
187
191
|
|
188
192
|
</body>
|
data/doc/_index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<head>
|
5
5
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
6
|
<title>
|
7
|
-
Documentation by YARD 0.8.7.
|
7
|
+
Documentation by YARD 0.8.7.6
|
8
8
|
|
9
9
|
</title>
|
10
10
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
<iframe id="search_frame"></iframe>
|
58
58
|
|
59
|
-
<div id="content"><h1 class="noborder title">Documentation by YARD 0.8.7.
|
59
|
+
<div id="content"><h1 class="noborder title">Documentation by YARD 0.8.7.6</h1>
|
60
60
|
<div id="listing">
|
61
61
|
<h1 class="alphaindex">Alphabetic Index</h1>
|
62
62
|
|
@@ -226,9 +226,9 @@
|
|
226
226
|
</div>
|
227
227
|
|
228
228
|
<div id="footer">
|
229
|
-
Generated on Mon
|
229
|
+
Generated on Mon Mar 2 13:10:30 2015 by
|
230
230
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
231
|
-
0.8.7.
|
231
|
+
0.8.7.6 (ruby-2.2.0).
|
232
232
|
</div>
|
233
233
|
|
234
234
|
</body>
|
data/doc/class_list.html
CHANGED
@@ -20,7 +20,11 @@
|
|
20
20
|
</head>
|
21
21
|
<body>
|
22
22
|
<script type="text/javascript" charset="utf-8">
|
23
|
-
|
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
|
}
|
data/doc/file.README.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7.
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -102,7 +102,7 @@ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
|
|
102
102
|
|
103
103
|
<h3 id="getting-browser-information">Getting browser information</h3>
|
104
104
|
|
105
|
-
<p>Once you instantiate the browser, you can query the browser about <code>name</code>, <code>version</code>, <code>platform</code>, <code>languages</code
|
105
|
+
<p>Once you instantiate the browser, you can query the browser about <code>name</code>, <code>version</code>, <code>platform</code>, <code>languages</code>.</p>
|
106
106
|
|
107
107
|
<p>You can also get readable name and platforms via <code>human_name</code>, <code>human_platform</code>, <code>human_languages</code>.</p>
|
108
108
|
|
@@ -116,99 +116,126 @@ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
|
|
116
116
|
|
117
117
|
<p>For example, if you do this in a ERB view:</p>
|
118
118
|
|
119
|
-
<p
|
120
|
-
|
119
|
+
<p>```html</p>
|
120
|
+
<body class="<%= browser.classes %>">
|
121
121
|
...
|
122
|
-
|
122
|
+
```
|
123
123
|
|
124
|
-
|
124
|
+
The view will get compiled to this:
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
```html
|
127
|
+
<body class="chrome version-1 version-1_2 version-1_2_3 platform-osx">
|
128
128
|
...
|
129
|
-
|
129
|
+
```
|
130
130
|
|
131
|
-
|
131
|
+
And thus scoping your CSS will be trivial.
|
132
132
|
|
133
|
-
|
133
|
+
### Querying the browser
|
134
134
|
|
135
|
-
|
135
|
+
Brauser supports querying about name, version, platform, language.
|
136
136
|
|
137
|
-
|
137
|
+
Name and platform support querying via the `==` operator, which supports a single value or a list of values.
|
138
138
|
|
139
|
-
|
140
|
-
# We talk about the ending ? later.
|
139
|
+
```ruby
|
140
|
+
# We'll talk about the ending "?" later.
|
141
141
|
browser.name == :chrome
|
142
142
|
# => true
|
143
143
|
browser.name == [:msie, :firefox]
|
144
144
|
# => false
|
145
|
-
|
145
|
+
```
|
146
146
|
|
147
|
-
|
147
|
+
The version is delegated to the versionomy gem. You can use comparison operator. The right hand part must be either a `String` or a `Versionomy::Value`.
|
148
148
|
|
149
|
-
|
149
|
+
```ruby
|
150
150
|
browser.version == "3"
|
151
151
|
# => false
|
152
152
|
browser.version >= "2"
|
153
153
|
# => true
|
154
|
-
|
154
|
+
```
|
155
155
|
|
156
|
-
|
156
|
+
The language support querying via the `accepts?` method, which supports a single value or a list of values.
|
157
157
|
|
158
|
-
|
158
|
+
```ruby
|
159
159
|
browser.accepts?(:it)
|
160
160
|
# => true
|
161
161
|
browser.accepts?(:it, :en)
|
162
162
|
# => true
|
163
|
-
|
163
|
+
```
|
164
164
|
|
165
|
-
|
165
|
+
All the querying can be combined in the single method `is?`:
|
166
166
|
|
167
|
-
|
167
|
+
```ruby
|
168
168
|
browser.is?(name: :chrome, version: ">= 4", platform: [:osx, :windows], languages: :it)
|
169
169
|
# => false
|
170
|
-
|
170
|
+
```
|
171
|
+
|
172
|
+
Name, platform and languages can be either symbols or array of symbols. Version must be a query in the form is `OPERATOR VALUE && ..`,
|
173
|
+
where `OPERATOR` is one of `["<", "<=", "=", "==", ">=", ">"]` and value specifies the version.
|
171
174
|
|
172
|
-
|
173
|
-
where <code>OPERATOR</code> is one of <code>["<", "<=", "=", "==", ">=", ">"]</code> and value specifies the version.</p>
|
175
|
+
### Prevent old browsers to access the Rails application.
|
174
176
|
|
175
|
-
|
177
|
+
If you want to easily prevent a legacy browser to open your application, create a file `supported-browsers.yml` in the `config` folder with a similar content:
|
176
178
|
|
177
|
-
|
179
|
+
```yaml
|
180
|
+
---
|
181
|
+
chrome: 29
|
182
|
+
firefox: 28
|
183
|
+
safari: 6.1
|
184
|
+
msie: 11
|
185
|
+
```
|
178
186
|
|
179
|
-
|
187
|
+
then create a filter in the `ApplicationController`:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
class ApplicationController < ActionController::Base
|
191
|
+
# ...
|
192
|
+
|
193
|
+
before_filter do
|
194
|
+
redirect_to(URL) unless browser.supported?(Rails.root + "config/supported-browsers.yml")
|
195
|
+
end
|
196
|
+
|
197
|
+
# ...
|
198
|
+
end
|
199
|
+
```
|
200
|
+
|
201
|
+
and you are set.
|
202
|
+
|
203
|
+
### Adding new browsers, platform and languages.
|
204
|
+
|
205
|
+
To add new browsers, simply call `::Brauser::Definitions.register(:browser, :id, ...)`.
|
206
|
+
|
207
|
+
The first argument can be `:browser`, `:platform` or `:language`.
|
180
208
|
The second argument is the id of the definition.
|
181
|
-
The remaining argument will be passed to the definition constructor
|
209
|
+
The remaining argument will be passed to the definition constructor.
|
182
210
|
|
183
|
-
|
211
|
+
For example, for Google Chrome the call should be:
|
184
212
|
|
185
|
-
|
213
|
+
```ruby
|
186
214
|
Brauser::Definitions.register(:browsers, :chrome, "Chrome", /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i)
|
187
|
-
|
188
|
-
|
189
|
-
<h2 id="contributing-to-brauser">Contributing to brauser</h2>
|
215
|
+
```
|
190
216
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
217
|
+
## Contributing to brauser
|
218
|
+
|
219
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
220
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
221
|
+
* Fork the project.
|
222
|
+
* Start a feature/bugfix branch.
|
223
|
+
* Commit and push until you are happy with your contribution.
|
224
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
225
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
200
226
|
|
201
|
-
|
227
|
+
## Copyright
|
202
228
|
|
203
|
-
|
229
|
+
Copyright (C) 2013 and above Shogun (shogun@cowtech.it).
|
204
230
|
|
205
|
-
|
231
|
+
Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
232
|
+
</body></body>
|
206
233
|
</div></div>
|
207
234
|
|
208
235
|
<div id="footer">
|
209
|
-
Generated on Mon
|
236
|
+
Generated on Mon Mar 2 13:10:30 2015 by
|
210
237
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
211
|
-
0.8.7.
|
238
|
+
0.8.7.6 (ruby-2.2.0).
|
212
239
|
</div>
|
213
240
|
|
214
241
|
</body>
|
data/doc/file_list.html
CHANGED
@@ -20,7 +20,11 @@
|
|
20
20
|
</head>
|
21
21
|
<body>
|
22
22
|
<script type="text/javascript" charset="utf-8">
|
23
|
-
|
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
|
}
|
data/doc/frames.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
5
|
<head>
|
6
6
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
7
|
-
<title>Documentation by YARD 0.8.7.
|
7
|
+
<title>Documentation by YARD 0.8.7.6</title>
|
8
8
|
</head>
|
9
9
|
<script type="text/javascript" charset="utf-8">
|
10
10
|
window.onload = function() {
|
data/doc/index.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7.
|
9
|
+
— Documentation by YARD 0.8.7.6
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -102,7 +102,7 @@ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
|
|
102
102
|
|
103
103
|
<h3 id="getting-browser-information">Getting browser information</h3>
|
104
104
|
|
105
|
-
<p>Once you instantiate the browser, you can query the browser about <code>name</code>, <code>version</code>, <code>platform</code>, <code>languages</code
|
105
|
+
<p>Once you instantiate the browser, you can query the browser about <code>name</code>, <code>version</code>, <code>platform</code>, <code>languages</code>.</p>
|
106
106
|
|
107
107
|
<p>You can also get readable name and platforms via <code>human_name</code>, <code>human_platform</code>, <code>human_languages</code>.</p>
|
108
108
|
|
@@ -116,99 +116,126 @@ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
|
|
116
116
|
|
117
117
|
<p>For example, if you do this in a ERB view:</p>
|
118
118
|
|
119
|
-
<p
|
120
|
-
|
119
|
+
<p>```html</p>
|
120
|
+
<body class="<%= browser.classes %>">
|
121
121
|
...
|
122
|
-
|
122
|
+
```
|
123
123
|
|
124
|
-
|
124
|
+
The view will get compiled to this:
|
125
125
|
|
126
|
-
|
127
|
-
|
126
|
+
```html
|
127
|
+
<body class="chrome version-1 version-1_2 version-1_2_3 platform-osx">
|
128
128
|
...
|
129
|
-
|
129
|
+
```
|
130
130
|
|
131
|
-
|
131
|
+
And thus scoping your CSS will be trivial.
|
132
132
|
|
133
|
-
|
133
|
+
### Querying the browser
|
134
134
|
|
135
|
-
|
135
|
+
Brauser supports querying about name, version, platform, language.
|
136
136
|
|
137
|
-
|
137
|
+
Name and platform support querying via the `==` operator, which supports a single value or a list of values.
|
138
138
|
|
139
|
-
|
140
|
-
# We talk about the ending ? later.
|
139
|
+
```ruby
|
140
|
+
# We'll talk about the ending "?" later.
|
141
141
|
browser.name == :chrome
|
142
142
|
# => true
|
143
143
|
browser.name == [:msie, :firefox]
|
144
144
|
# => false
|
145
|
-
|
145
|
+
```
|
146
146
|
|
147
|
-
|
147
|
+
The version is delegated to the versionomy gem. You can use comparison operator. The right hand part must be either a `String` or a `Versionomy::Value`.
|
148
148
|
|
149
|
-
|
149
|
+
```ruby
|
150
150
|
browser.version == "3"
|
151
151
|
# => false
|
152
152
|
browser.version >= "2"
|
153
153
|
# => true
|
154
|
-
|
154
|
+
```
|
155
155
|
|
156
|
-
|
156
|
+
The language support querying via the `accepts?` method, which supports a single value or a list of values.
|
157
157
|
|
158
|
-
|
158
|
+
```ruby
|
159
159
|
browser.accepts?(:it)
|
160
160
|
# => true
|
161
161
|
browser.accepts?(:it, :en)
|
162
162
|
# => true
|
163
|
-
|
163
|
+
```
|
164
164
|
|
165
|
-
|
165
|
+
All the querying can be combined in the single method `is?`:
|
166
166
|
|
167
|
-
|
167
|
+
```ruby
|
168
168
|
browser.is?(name: :chrome, version: ">= 4", platform: [:osx, :windows], languages: :it)
|
169
169
|
# => false
|
170
|
-
|
170
|
+
```
|
171
|
+
|
172
|
+
Name, platform and languages can be either symbols or array of symbols. Version must be a query in the form is `OPERATOR VALUE && ..`,
|
173
|
+
where `OPERATOR` is one of `["<", "<=", "=", "==", ">=", ">"]` and value specifies the version.
|
171
174
|
|
172
|
-
|
173
|
-
where <code>OPERATOR</code> is one of <code>["<", "<=", "=", "==", ">=", ">"]</code> and value specifies the version.</p>
|
175
|
+
### Prevent old browsers to access the Rails application.
|
174
176
|
|
175
|
-
|
177
|
+
If you want to easily prevent a legacy browser to open your application, create a file `supported-browsers.yml` in the `config` folder with a similar content:
|
176
178
|
|
177
|
-
|
179
|
+
```yaml
|
180
|
+
---
|
181
|
+
chrome: 29
|
182
|
+
firefox: 28
|
183
|
+
safari: 6.1
|
184
|
+
msie: 11
|
185
|
+
```
|
178
186
|
|
179
|
-
|
187
|
+
then create a filter in the `ApplicationController`:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
class ApplicationController < ActionController::Base
|
191
|
+
# ...
|
192
|
+
|
193
|
+
before_filter do
|
194
|
+
redirect_to(URL) unless browser.supported?(Rails.root + "config/supported-browsers.yml")
|
195
|
+
end
|
196
|
+
|
197
|
+
# ...
|
198
|
+
end
|
199
|
+
```
|
200
|
+
|
201
|
+
and you are set.
|
202
|
+
|
203
|
+
### Adding new browsers, platform and languages.
|
204
|
+
|
205
|
+
To add new browsers, simply call `::Brauser::Definitions.register(:browser, :id, ...)`.
|
206
|
+
|
207
|
+
The first argument can be `:browser`, `:platform` or `:language`.
|
180
208
|
The second argument is the id of the definition.
|
181
|
-
The remaining argument will be passed to the definition constructor
|
209
|
+
The remaining argument will be passed to the definition constructor.
|
182
210
|
|
183
|
-
|
211
|
+
For example, for Google Chrome the call should be:
|
184
212
|
|
185
|
-
|
213
|
+
```ruby
|
186
214
|
Brauser::Definitions.register(:browsers, :chrome, "Chrome", /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i)
|
187
|
-
|
188
|
-
|
189
|
-
<h2 id="contributing-to-brauser">Contributing to brauser</h2>
|
215
|
+
```
|
190
216
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
217
|
+
## Contributing to brauser
|
218
|
+
|
219
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
220
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
221
|
+
* Fork the project.
|
222
|
+
* Start a feature/bugfix branch.
|
223
|
+
* Commit and push until you are happy with your contribution.
|
224
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
225
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
200
226
|
|
201
|
-
|
227
|
+
## Copyright
|
202
228
|
|
203
|
-
|
229
|
+
Copyright (C) 2013 and above Shogun (shogun@cowtech.it).
|
204
230
|
|
205
|
-
|
231
|
+
Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
232
|
+
</body></body>
|
206
233
|
</div></div>
|
207
234
|
|
208
235
|
<div id="footer">
|
209
|
-
Generated on Mon
|
236
|
+
Generated on Mon Mar 2 13:10:30 2015 by
|
210
237
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
211
|
-
0.8.7.
|
238
|
+
0.8.7.6 (ruby-2.2.0).
|
212
239
|
</div>
|
213
240
|
|
214
241
|
</body>
|