brauser 3.3.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.travis-gemfile +4 -5
- data/.travis.yml +2 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile +7 -8
- data/README.md +31 -95
- data/Rakefile +0 -1
- data/brauser.gemspec +4 -4
- data/default_definitions/browsers.rb +50 -0
- data/default_definitions/languages.rb +118 -0
- data/default_definitions/platforms.rb +24 -0
- data/doc/Brauser.html +6 -6
- data/doc/Brauser/Browser.html +3867 -580
- data/doc/Brauser/Definitions.html +537 -0
- data/doc/Brauser/Definitions/Base.html +342 -0
- data/doc/Brauser/Definitions/Browser.html +1047 -0
- data/doc/Brauser/Definitions/Language.html +496 -0
- data/doc/Brauser/Definitions/Platform.html +686 -0
- data/doc/Brauser/Hooks.html +2 -2
- data/doc/Brauser/Hooks/RubyOnRails.html +9 -9
- data/doc/Brauser/Parser.html +513 -0
- data/doc/Brauser/Value.html +601 -0
- data/doc/Brauser/Version.html +5 -5
- data/doc/_index.html +25 -108
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +33 -97
- data/doc/index.html +33 -97
- data/doc/method_list.html +72 -120
- data/doc/top-level-namespace.html +2 -2
- data/lib/brauser.rb +13 -15
- data/lib/brauser/browser.rb +195 -66
- data/lib/brauser/definitions/base.rb +71 -0
- data/lib/brauser/definitions/browser.rb +80 -0
- data/lib/brauser/definitions/language.rb +29 -0
- data/lib/brauser/definitions/platform.rb +42 -0
- data/lib/brauser/hooks.rb +1 -2
- data/lib/brauser/parser.rb +47 -0
- data/lib/brauser/value.rb +39 -0
- data/lib/brauser/version.rb +3 -4
- data/spec/brauser/browser_spec.rb +73 -564
- data/spec/brauser/default_definitions_spec.rb +129 -0
- data/spec/brauser/definitions/base_spec.rb +48 -0
- data/spec/brauser/definitions/browser_spec.rb +47 -0
- data/spec/brauser/definitions/language_spec.rb +18 -0
- data/spec/brauser/definitions/platform_spec.rb +36 -0
- data/spec/brauser/hooks_spec.rb +5 -6
- data/spec/brauser/parser_spec.rb +31 -0
- data/spec/brauser/value_spec.rb +34 -0
- data/spec/coverage_helper.rb +0 -1
- data/spec/spec_helper.rb +0 -1
- metadata +50 -23
- data/lib/brauser/browseable/attributes.rb +0 -95
- data/lib/brauser/browseable/general.rb +0 -104
- data/lib/brauser/browseable/parsing.rb +0 -127
- data/lib/brauser/browseable/partial_querying.rb +0 -116
- data/lib/brauser/browseable/querying.rb +0 -63
- data/lib/brauser/browseable/register.rb +0 -73
- data/lib/brauser/definition.rb +0 -80
- data/lib/brauser/definitions/browsers.rb +0 -68
- data/lib/brauser/definitions/languages.rb +0 -130
- data/lib/brauser/definitions/platforms.rb +0 -30
- data/lib/brauser/query.rb +0 -36
- data/lib/brauser/queryable/chainers.rb +0 -56
- data/lib/brauser/queryable/queries.rb +0 -60
- data/spec/brauser/definition_spec.rb +0 -39
- data/spec/brauser/query_spec.rb +0 -111
data/doc/Brauser/Version.html
CHANGED
@@ -119,7 +119,7 @@
|
|
119
119
|
|
120
120
|
</div>
|
121
121
|
</dt>
|
122
|
-
<dd><pre class="code"><span class='int'>
|
122
|
+
<dd><pre class="code"><span class='int'>4</span></pre></dd>
|
123
123
|
|
124
124
|
<dt id="MINOR-constant" class="">MINOR =
|
125
125
|
<div class="docstring">
|
@@ -134,7 +134,7 @@
|
|
134
134
|
|
135
135
|
</div>
|
136
136
|
</dt>
|
137
|
-
<dd><pre class="code"><span class='int'>
|
137
|
+
<dd><pre class="code"><span class='int'>0</span></pre></dd>
|
138
138
|
|
139
139
|
<dt id="PATCH-constant" class="">PATCH =
|
140
140
|
<div class="docstring">
|
@@ -149,7 +149,7 @@
|
|
149
149
|
|
150
150
|
</div>
|
151
151
|
</dt>
|
152
|
-
<dd><pre class="code"><span class='int'>
|
152
|
+
<dd><pre class="code"><span class='int'>0</span></pre></dd>
|
153
153
|
|
154
154
|
<dt id="STRING-constant" class="">STRING =
|
155
155
|
<div class="docstring">
|
@@ -180,9 +180,9 @@
|
|
180
180
|
</div>
|
181
181
|
|
182
182
|
<div id="footer">
|
183
|
-
Generated on
|
183
|
+
Generated on Mon Sep 29 16:43:31 2014 by
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
|
-
0.8.7.4 (ruby-2.1.
|
185
|
+
0.8.7.4 (ruby-2.1.3).
|
186
186
|
</div>
|
187
187
|
|
188
188
|
</body>
|
data/doc/_index.html
CHANGED
@@ -80,34 +80,19 @@
|
|
80
80
|
<td valign='top' width="33%">
|
81
81
|
|
82
82
|
|
83
|
-
<ul id="alpha_A" class="alpha">
|
84
|
-
<li class="letter">A</li>
|
85
|
-
<ul>
|
86
|
-
|
87
|
-
<li>
|
88
|
-
<span class='object_link'><a href="Brauser/Browseable/Attributes.html" title="Brauser::Browseable::Attributes (module)">Attributes</a></span>
|
89
|
-
|
90
|
-
<small>(Brauser::Browseable)</small>
|
91
|
-
|
92
|
-
</li>
|
93
|
-
|
94
|
-
</ul>
|
95
|
-
</ul>
|
96
|
-
|
97
|
-
|
98
83
|
<ul id="alpha_B" class="alpha">
|
99
84
|
<li class="letter">B</li>
|
100
85
|
<ul>
|
101
86
|
|
102
87
|
<li>
|
103
|
-
<span class='object_link'><a href="Brauser.html" title="Brauser (
|
88
|
+
<span class='object_link'><a href="Brauser/Definitions/Base.html" title="Brauser::Definitions::Base (class)">Base</a></span>
|
89
|
+
|
90
|
+
<small>(Brauser::Definitions)</small>
|
104
91
|
|
105
92
|
</li>
|
106
93
|
|
107
94
|
<li>
|
108
|
-
<span class='object_link'><a href="Brauser
|
109
|
-
|
110
|
-
<small>(Brauser)</small>
|
95
|
+
<span class='object_link'><a href="Brauser.html" title="Brauser (module)">Brauser</a></span>
|
111
96
|
|
112
97
|
</li>
|
113
98
|
|
@@ -118,32 +103,10 @@
|
|
118
103
|
|
119
104
|
</li>
|
120
105
|
|
121
|
-
</ul>
|
122
|
-
</ul>
|
123
|
-
|
124
|
-
|
125
|
-
<ul id="alpha_C" class="alpha">
|
126
|
-
<li class="letter">C</li>
|
127
|
-
<ul>
|
128
|
-
|
129
|
-
<li>
|
130
|
-
<span class='object_link'><a href="Brauser/Queryable/Chainers.html" title="Brauser::Queryable::Chainers (module)">Chainers</a></span>
|
131
|
-
|
132
|
-
<small>(Brauser::Queryable)</small>
|
133
|
-
|
134
|
-
</li>
|
135
|
-
|
136
|
-
<li>
|
137
|
-
<span class='object_link'><a href="Brauser/Browseable/General/ClassMethods.html" title="Brauser::Browseable::General::ClassMethods (module)">ClassMethods</a></span>
|
138
|
-
|
139
|
-
<small>(Brauser::Browseable::General)</small>
|
140
|
-
|
141
|
-
</li>
|
142
|
-
|
143
106
|
<li>
|
144
|
-
<span class='object_link'><a href="Brauser/
|
107
|
+
<span class='object_link'><a href="Brauser/Definitions/Browser.html" title="Brauser::Definitions::Browser (class)">Browser</a></span>
|
145
108
|
|
146
|
-
<small>(Brauser::
|
109
|
+
<small>(Brauser::Definitions)</small>
|
147
110
|
|
148
111
|
</li>
|
149
112
|
|
@@ -156,14 +119,7 @@
|
|
156
119
|
<ul>
|
157
120
|
|
158
121
|
<li>
|
159
|
-
<span class='object_link'><a href="Brauser/
|
160
|
-
|
161
|
-
<small>(Brauser::Browseable)</small>
|
162
|
-
|
163
|
-
</li>
|
164
|
-
|
165
|
-
<li>
|
166
|
-
<span class='object_link'><a href="Brauser/Definition.html" title="Brauser::Definition (class)">Definition</a></span>
|
122
|
+
<span class='object_link'><a href="Brauser/Definitions.html" title="Brauser::Definitions (module)">Definitions</a></span>
|
167
123
|
|
168
124
|
<small>(Brauser)</small>
|
169
125
|
|
@@ -173,21 +129,6 @@
|
|
173
129
|
</ul>
|
174
130
|
|
175
131
|
|
176
|
-
<ul id="alpha_G" class="alpha">
|
177
|
-
<li class="letter">G</li>
|
178
|
-
<ul>
|
179
|
-
|
180
|
-
<li>
|
181
|
-
<span class='object_link'><a href="Brauser/Browseable/General.html" title="Brauser::Browseable::General (module)">General</a></span>
|
182
|
-
|
183
|
-
<small>(Brauser::Browseable)</small>
|
184
|
-
|
185
|
-
</li>
|
186
|
-
|
187
|
-
</ul>
|
188
|
-
</ul>
|
189
|
-
|
190
|
-
|
191
132
|
<ul id="alpha_H" class="alpha">
|
192
133
|
<li class="letter">H</li>
|
193
134
|
<ul>
|
@@ -203,21 +144,14 @@
|
|
203
144
|
</ul>
|
204
145
|
|
205
146
|
|
206
|
-
<ul id="
|
207
|
-
<li class="letter">
|
147
|
+
<ul id="alpha_L" class="alpha">
|
148
|
+
<li class="letter">L</li>
|
208
149
|
<ul>
|
209
150
|
|
210
151
|
<li>
|
211
|
-
<span class='object_link'><a href="Brauser/
|
152
|
+
<span class='object_link'><a href="Brauser/Definitions/Language.html" title="Brauser::Definitions::Language (class)">Language</a></span>
|
212
153
|
|
213
|
-
<small>(Brauser::
|
214
|
-
|
215
|
-
</li>
|
216
|
-
|
217
|
-
<li>
|
218
|
-
<span class='object_link'><a href="Brauser/Browseable/PartialQuerying.html" title="Brauser::Browseable::PartialQuerying (module)">PartialQuerying</a></span>
|
219
|
-
|
220
|
-
<small>(Brauser::Browseable)</small>
|
154
|
+
<small>(Brauser::Definitions)</small>
|
221
155
|
|
222
156
|
</li>
|
223
157
|
|
@@ -225,38 +159,21 @@
|
|
225
159
|
</ul>
|
226
160
|
|
227
161
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
<ul id="alpha_Q" class="alpha">
|
232
|
-
<li class="letter">Q</li>
|
162
|
+
<ul id="alpha_P" class="alpha">
|
163
|
+
<li class="letter">P</li>
|
233
164
|
<ul>
|
234
165
|
|
235
166
|
<li>
|
236
|
-
<span class='object_link'><a href="Brauser/
|
237
|
-
|
238
|
-
<small>(Brauser::Queryable)</small>
|
239
|
-
|
240
|
-
</li>
|
241
|
-
|
242
|
-
<li>
|
243
|
-
<span class='object_link'><a href="Brauser/Query.html" title="Brauser::Query (class)">Query</a></span>
|
244
|
-
|
245
|
-
<small>(Brauser)</small>
|
246
|
-
|
247
|
-
</li>
|
248
|
-
|
249
|
-
<li>
|
250
|
-
<span class='object_link'><a href="Brauser/Queryable.html" title="Brauser::Queryable (module)">Queryable</a></span>
|
167
|
+
<span class='object_link'><a href="Brauser/Parser.html" title="Brauser::Parser (class)">Parser</a></span>
|
251
168
|
|
252
169
|
<small>(Brauser)</small>
|
253
170
|
|
254
171
|
</li>
|
255
172
|
|
256
173
|
<li>
|
257
|
-
<span class='object_link'><a href="Brauser/
|
174
|
+
<span class='object_link'><a href="Brauser/Definitions/Platform.html" title="Brauser::Definitions::Platform (class)">Platform</a></span>
|
258
175
|
|
259
|
-
<small>(Brauser::
|
176
|
+
<small>(Brauser::Definitions)</small>
|
260
177
|
|
261
178
|
</li>
|
262
179
|
|
@@ -268,13 +185,6 @@
|
|
268
185
|
<li class="letter">R</li>
|
269
186
|
<ul>
|
270
187
|
|
271
|
-
<li>
|
272
|
-
<span class='object_link'><a href="Brauser/Browseable/Register.html" title="Brauser::Browseable::Register (module)">Register</a></span>
|
273
|
-
|
274
|
-
<small>(Brauser::Browseable)</small>
|
275
|
-
|
276
|
-
</li>
|
277
|
-
|
278
188
|
<li>
|
279
189
|
<span class='object_link'><a href="Brauser/Hooks/RubyOnRails.html" title="Brauser::Hooks::RubyOnRails (module)">RubyOnRails</a></span>
|
280
190
|
|
@@ -290,6 +200,13 @@
|
|
290
200
|
<li class="letter">V</li>
|
291
201
|
<ul>
|
292
202
|
|
203
|
+
<li>
|
204
|
+
<span class='object_link'><a href="Brauser/Value.html" title="Brauser::Value (class)">Value</a></span>
|
205
|
+
|
206
|
+
<small>(Brauser)</small>
|
207
|
+
|
208
|
+
</li>
|
209
|
+
|
293
210
|
<li>
|
294
211
|
<span class='object_link'><a href="Brauser/Version.html" title="Brauser::Version (module)">Version</a></span>
|
295
212
|
|
@@ -309,9 +226,9 @@
|
|
309
226
|
</div>
|
310
227
|
|
311
228
|
<div id="footer">
|
312
|
-
Generated on
|
229
|
+
Generated on Mon Sep 29 16:43:31 2014 by
|
313
230
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
314
|
-
0.8.7.4 (ruby-2.1.
|
231
|
+
0.8.7.4 (ruby-2.1.3).
|
315
232
|
</div>
|
316
233
|
|
317
234
|
</body>
|
data/doc/class_list.html
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
<ul id="full_list" class="class">
|
48
48
|
<li><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></li>
|
49
|
-
<li><a class='toggle'></a> <span class='object_link'><a href="Brauser.html" title="Brauser (module)">Brauser</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><
|
49
|
+
<li><a class='toggle'></a> <span class='object_link'><a href="Brauser.html" title="Brauser (module)">Brauser</a></span><small class='search_info'>Top Level Namespace</small></li><ul><li><span class='object_link'><a href="Brauser/Browser.html" title="Brauser::Browser (class)">Browser</a></span> < Object<small class='search_info'>Brauser</small></li><li><a class='toggle'></a> <span class='object_link'><a href="Brauser/Definitions.html" title="Brauser::Definitions (module)">Definitions</a></span><small class='search_info'>Brauser</small></li><ul><li><span class='object_link'><a href="Brauser/Definitions/Base.html" title="Brauser::Definitions::Base (class)">Base</a></span> < Object<small class='search_info'>Brauser::Definitions</small></li><li><span class='object_link'><a href="Brauser/Definitions/Browser.html" title="Brauser::Definitions::Browser (class)">Browser</a></span> < Base<small class='search_info'>Brauser::Definitions</small></li><li><span class='object_link'><a href="Brauser/Definitions/Language.html" title="Brauser::Definitions::Language (class)">Language</a></span> < Base<small class='search_info'>Brauser::Definitions</small></li><li><span class='object_link'><a href="Brauser/Definitions/Platform.html" title="Brauser::Definitions::Platform (class)">Platform</a></span> < Base<small class='search_info'>Brauser::Definitions</small></li></ul><li><a class='toggle'></a> <span class='object_link'><a href="Brauser/Hooks.html" title="Brauser::Hooks (module)">Hooks</a></span><small class='search_info'>Brauser</small></li><ul><li><span class='object_link'><a href="Brauser/Hooks/RubyOnRails.html" title="Brauser::Hooks::RubyOnRails (module)">RubyOnRails</a></span><small class='search_info'>Brauser::Hooks</small></li></ul><li><span class='object_link'><a href="Brauser/Parser.html" title="Brauser::Parser (class)">Parser</a></span> < Object<small class='search_info'>Brauser</small></li><li><span class='object_link'><a href="Brauser/Value.html" title="Brauser::Value (class)">Value</a></span> < Object<small class='search_info'>Brauser</small></li><li><span class='object_link'><a href="Brauser/Version.html" title="Brauser::Version (module)">Version</a></span><small class='search_info'>Brauser</small></li></ul>
|
50
50
|
|
51
51
|
</ul>
|
52
52
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -72,7 +72,7 @@
|
|
72
72
|
|
73
73
|
<p>A framework agnostic browser detection and querying helper.</p>
|
74
74
|
|
75
|
-
<p>http://sw.
|
75
|
+
<p>http://sw.cowtech.it/brauser</p>
|
76
76
|
|
77
77
|
<p>http://rdoc.info/gems/brauser</p>
|
78
78
|
|
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
<h3 id="installation">Installation</h3>
|
84
84
|
|
85
|
-
<p>Brauser comes with a Ruby on Rails hooks (more
|
85
|
+
<p>Brauser comes with a Ruby on Rails hooks (more frameworks to follow), so for Rails you have just to add this to your Gemfile:</p>
|
86
86
|
|
87
87
|
<p><code>ruby
|
88
88
|
gem "brauser"
|
@@ -102,11 +102,15 @@ 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
|
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
|
-
<p>
|
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
|
|
109
|
-
<p>The
|
109
|
+
<p>The version is handle via the <a href="http://dazuma.github.io/versionomy/">versionomy</a> gem.</p>
|
110
|
+
|
111
|
+
<p>The name and the platform are returned as <code>Symbol</code> and can be in the range of names and engines registered via <code>Brauser::Definitions.register</code>.</p>
|
112
|
+
|
113
|
+
<p>The languages are returned as an hash where values are the priorities.</p>
|
110
114
|
|
111
115
|
<p>Also, you can get global information using <code>browser.to_s</code> or <code>browser.classes</code>. This will return an array or a string already formatted to be used in your views to scope your CSS.</p>
|
112
116
|
|
@@ -128,126 +132,58 @@ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
|
|
128
132
|
|
129
133
|
<h3 id="querying-the-browser">Querying the browser</h3>
|
130
134
|
|
131
|
-
<p>Brauser supports querying about name
|
135
|
+
<p>Brauser supports querying about name, version, platform, language.</p>
|
132
136
|
|
133
|
-
<p>
|
137
|
+
<p>name and platform support querying via the <code>==</code> operator, which supports a single value or a list of values. </p>
|
134
138
|
|
135
139
|
<p><code>ruby
|
136
140
|
# We talk about the ending ? later.
|
137
|
-
browser.
|
141
|
+
browser.name == :chrome
|
138
142
|
# => true
|
139
|
-
browser.
|
140
|
-
# => false
|
141
|
-
browser.is?(:chrome, {lt: "2"}, :osx)
|
142
|
-
# => true
|
143
|
-
browser.is?(:chrome, ">= 3", :windows)
|
143
|
+
browser.name == [:msie, :firefox]
|
144
144
|
# => false
|
145
145
|
</code></p>
|
146
146
|
|
147
|
-
<p>The
|
148
|
-
|
149
|
-
<p>The <code>version</code> (short: <code>v</code>) method queries about the browser version. You can specify the comparison with an hash or a little expression.</p>
|
150
|
-
|
151
|
-
<p>In the case of hash, the syntax is <code>{:operator => value}</code>, where <code>:operator</code> is one of <code>[:lt, :lte, :eq, :gte, :gt]</code> and value can be a Float or a String.</p>
|
152
|
-
|
153
|
-
<p>In the case of expression, the syntax is <code>OPERATOR VALUE && ..</code>, where <code>OPERATOR</code> is one of <code>["<", "<=", "=", "==", ">=", ">"]</code> and value specifies the version.</p>
|
154
|
-
|
155
|
-
<p>Examples:</p>
|
147
|
+
<p>The version is delegated to the versionomy gem. You can use comparison operator. The right hand part must be either a <code>String</code> or a <code>Versionomy::Value</code>.</p>
|
156
148
|
|
157
149
|
<p><code>ruby
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
browser.is?("< 2 && > 1")
|
150
|
+
browser.version == "3"
|
151
|
+
# => false
|
152
|
+
browser.version >= "2"
|
162
153
|
# => true
|
163
154
|
</code></p>
|
164
155
|
|
165
|
-
<p>The
|
156
|
+
<p>The language support querying via the <code>accepts?</code> method, which supports a single value or a list of values.</p>
|
166
157
|
|
167
158
|
<p><code>ruby
|
168
|
-
browser.
|
159
|
+
browser.accepts?(:it)
|
169
160
|
# => true
|
170
|
-
browser.
|
171
|
-
# => false
|
172
|
-
</code></p>
|
173
|
-
|
174
|
-
<p>At the end, the method <code>accepts</code> checks if the browser accepts one of the specified languages. Languages should be passed as language codes in <code>String</code>.</p>
|
175
|
-
|
176
|
-
<p><code>ruby
|
177
|
-
browser.accepts?("en")
|
161
|
+
browser.accepts?(:it, :en)
|
178
162
|
# => true
|
179
|
-
browser.accepts?(["de", "es"])
|
180
|
-
# => false
|
181
163
|
</code></p>
|
182
164
|
|
183
|
-
<p>
|
184
|
-
|
185
|
-
<p>The former return a <code>Query</code> object, which supports the same query method of the browser and thus enables concatenation.</p>
|
186
|
-
|
187
|
-
<p>The latter return a boolean object, and it’s equivalent to calling <code>result</code> on the query after concatenation.</p>
|
188
|
-
|
189
|
-
<p>Ideally, you should use the <code>?</code> version to end the query and fetch the result.</p>
|
165
|
+
<p>All the querying can be combined in the single method <code>is?</code>:</p>
|
190
166
|
|
191
167
|
<p><code>ruby
|
192
|
-
|
193
|
-
|
194
|
-
browser.is(:chrome, {lt: "2"}, :osx).result
|
195
|
-
browser.is(:chrome).version({lt: "2"}).on?(:osx)
|
196
|
-
browser.is(:chrome).version({lt: "2"}).on(:osx).result
|
168
|
+
browser.is?(name: :chrome, version: ">= 4", platform: [:osx, :windows], languages: :it)
|
169
|
+
# => false
|
197
170
|
</code></p>
|
198
171
|
|
199
|
-
<p>
|
172
|
+
<p>Name, platform and languages can be either symbols or array of symbols. Version must be a query in the form is <code>OPERATOR VALUE && ..</code>,
|
173
|
+
where <code>OPERATOR</code> is one of <code>["<", "<=", "=", "==", ">=", ">"]</code> and value specifies the version.</p>
|
200
174
|
|
201
|
-
<
|
175
|
+
<h3 id="adding-new-browsers-platform-and-languages">Adding new browsers, platform and languages.</h3>
|
202
176
|
|
203
|
-
<p>
|
177
|
+
<p>To add new browsers, simply call <code>::Brauser::Definitions.register(:browser, :id, ...)</code>.</p>
|
204
178
|
|
205
|
-
<p>
|
206
|
-
|
207
|
-
|
208
|
-
# These expressions are equivalent.
|
209
|
-
browser.is(:chrome).version(“< 2 && > 1.2”).on(:osx).result
|
210
|
-
browser.is_chrome_v_lt_2_and_gt_1_2_on_osx.result</p>
|
211
|
-
|
212
|
-
<h1 id="these-expressions-are-equivalent">These expressions are equivalent.</h1>
|
213
|
-
<p>browser.is(:chrome).version(“< 2 && > 1.2”).on?(:osx)
|
214
|
-
browser.is_chrome_v_lt_2_and_gt_1_2_on_osx?
|
215
|
-
```</p>
|
216
|
-
|
217
|
-
<h3 id="adding-new-browsers">Adding new browsers</h3>
|
218
|
-
|
219
|
-
<p>To add new browsers, simply call <code>::Brauser::Browser.add(:browsers, ...)</code>.</p>
|
220
|
-
|
221
|
-
<p>This methods accepts a single instance or an array of instances of the <code>::Brauser::Definition</code> class.</p>
|
179
|
+
<p>The first argument can be <code>:browser</code>, <code>:platform</code> or <code>:language</code>.
|
180
|
+
The second argument is the id of the definition.
|
181
|
+
The remaining argument will be passed to the definition constructor.</p>
|
222
182
|
|
223
183
|
<p>For example, for Google Chrome the call should be:</p>
|
224
184
|
|
225
185
|
<p><code>ruby
|
226
|
-
Brauser::
|
227
|
-
</code></p>
|
228
|
-
|
229
|
-
<h3 id="adding-new-platforms">Adding new platforms</h3>
|
230
|
-
|
231
|
-
<p>To add new platforms, simply call <code>::Brauser::Browser.add(:platforms, ...)</code>.</p>
|
232
|
-
|
233
|
-
<p>This methods accepts a single instance or an array of instances of the <code>::Brauser::Definition</code> class.</p>
|
234
|
-
|
235
|
-
<p>For example, for Mac OS X the call should be:</p>
|
236
|
-
|
237
|
-
<p><code>ruby
|
238
|
-
Brauser::Browsers.add(:platforms, ::Brauser::Definition.new(:osx, /mac|macintosh|mac os x/i, "Apple MacOS X"))
|
239
|
-
</code></p>
|
240
|
-
|
241
|
-
<h3 id="adding-new-languages">Adding new languages</h3>
|
242
|
-
|
243
|
-
<p>To add new languages, simply call <code>::Brauser::Browser.add(:languages, ...)</code>.</p>
|
244
|
-
|
245
|
-
<p>This methods accepts a single instance or an array of instances of the <code>::Brauser::Definition</code> class.</p>
|
246
|
-
|
247
|
-
<p>For example, for Italian the call should be:</p>
|
248
|
-
|
249
|
-
<p><code>ruby
|
250
|
-
Brauser::Browsers.add(:languages, ::Brauser::Definition.new(:it, "Italian"))
|
186
|
+
Brauser::Definitions.register(:browsers, :chrome, "Chrome", /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i)
|
251
187
|
</code></p>
|
252
188
|
|
253
189
|
<h2 id="contributing-to-brauser">Contributing to brauser</h2>
|
@@ -270,9 +206,9 @@ Brauser::Browsers.add(:languages, ::Brauser::Definition.new(:it, "Italian"))
|
|
270
206
|
</div></div>
|
271
207
|
|
272
208
|
<div id="footer">
|
273
|
-
Generated on
|
209
|
+
Generated on Mon Sep 29 16:43:31 2014 by
|
274
210
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
275
|
-
0.8.7.4 (ruby-2.1.
|
211
|
+
0.8.7.4 (ruby-2.1.3).
|
276
212
|
</div>
|
277
213
|
|
278
214
|
</body>
|