brauser 2.0.0 → 2.0.1

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/_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.3
7
+ Documentation by YARD 0.8.4.1
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.3</h1>
59
+ <div id="content"><h1 class="noborder title">Documentation by YARD 0.8.4.1</h1>
60
60
  <div id="listing">
61
61
  <h1 class="alphaindex">Alphabetic Index</h1>
62
62
 
@@ -266,9 +266,9 @@
266
266
  </div>
267
267
 
268
268
  <div id="footer">
269
- Generated on Sat Feb 2 17:47:18 2013 by
269
+ Generated on Fri Feb 8 08:12:31 2013 by
270
270
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
271
- 0.8.3 (ruby-1.9.3).
271
+ 0.8.4.1 (ruby-1.9.3).
272
272
  </div>
273
273
 
274
274
  </body>
data/doc/file.README.html CHANGED
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.8.3
9
+ &mdash; Documentation by YARD 0.8.4.1
10
10
 
11
11
  </title>
12
12
 
@@ -61,41 +61,43 @@
61
61
 
62
62
  <iframe id="search_frame"></iframe>
63
63
 
64
- <div id="content"><div id='filecontents'><h1>brauser</h1>
64
+ <div id="content"><div id='filecontents'><h1 id="brauser">brauser</h1>
65
65
 
66
- <p><a href="http://travis-ci.org/ShogunPanda/brauser"><img src="https://secure.travis-ci.org/ShogunPanda/brauser.png?branch=master" alt="Build Status"></a>
67
- <a href="https://gemnasium.com/ShogunPanda/brauser"><img src="https://gemnasium.com/ShogunPanda/brauser.png?travis" alt="Dependency Status"></a>
68
- <a href="https://codeclimate.com/github/ShogunPanda/brauser"><img src="https://codeclimate.com/github/ShogunPanda/brauser.png" alt="Code Climate"></a></p>
66
+ <p><a href="http://travis-ci.org/ShogunPanda/brauser"><img src="https://secure.travis-ci.org/ShogunPanda/brauser.png?branch=master" alt="Build Status" /></a>
67
+ <a href="https://gemnasium.com/ShogunPanda/brauser"><img src="https://gemnasium.com/ShogunPanda/brauser.png?travis" alt="Dependency Status" /></a>
68
+ <a href="https://codeclimate.com/github/ShogunPanda/brauser"><img src="https://codeclimate.com/github/ShogunPanda/brauser.png" alt="Code Climate" /></a></p>
69
69
 
70
70
  <p>A framework agnostic browser detection and querying helper.</p>
71
71
 
72
- <p><a href="http://sw.cow.tc/brauser">http://sw.cow.tc/brauser</a></p>
72
+ <p>http://sw.cow.tc/brauser</p>
73
73
 
74
- <p><a href="http://rdoc.info/gems/brauser">http://rdoc.info/gems/brauser</a></p>
74
+ <p>http://rdoc.info/gems/brauser</p>
75
75
 
76
- <h2>Description</h2>
76
+ <h2 id="description">Description</h2>
77
77
 
78
78
  <p>Brauser is a framework agnostic helper that helps you in targeting your applications against most diffused browsers.</p>
79
79
 
80
- <h3>Installation</h3>
80
+ <h3 id="installation">Installation</h3>
81
81
 
82
82
  <p>Brauser comes with a Ruby on Rails hooks (more framework to follow), so for Rails you have just to add this to your Gemfile:</p>
83
83
 
84
- <pre class="code ruby"><code><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>brauser</span><span class='tstring_end'>&quot;</span></span>
85
- </code></pre>
84
+ <p><code>ruby
85
+ gem "brauser"
86
+ </code></p>
86
87
 
87
88
  <p>Once done that, every controller in your application will have a <code>browser</code> method (also extended to views/layout via <code>helper_method</code>).</p>
88
89
 
89
- <p>If you don&#39;t use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:</p>
90
+ <p>If you don&#8217;t use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:</p>
90
91
 
91
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span> <span class='op'>=</span> <span class='const'>Brauser</span><span class='op'>::</span><span class='const'>Browser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>USER_AGENT_HEADER</span><span class='comma'>,</span> <span class='const'>ACCEPT_LANGUAGE_HEADER</span><span class='rparen'>)</span>
92
- </code></pre>
92
+ <p><code>ruby
93
+ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
94
+ </code></p>
93
95
 
94
96
  <p>where the first argument is the HTTP header <code>User-Agent</code>, and the second is the HTTP header <code>Accept-Language</code>.</p>
95
97
 
96
- <p>For the rest of this document, let&#39;s assume you use Chrome 1.2.3 on Mac OS X.</p>
98
+ <p>For the rest of this document, let&#8217;s assume you use Chrome 1.2.3 on Mac OS X.</p>
97
99
 
98
- <h3>Getting browser information</h3>
100
+ <h3 id="getting-browser-information">Getting browser information</h3>
99
101
 
100
102
  <p>Once you instantiate the browser, you can query the browser about <code>name</code>, <code>version</code> and <code>platform</code>. You can also get readable name and platforms via <code>readable_name</code> and <code>platform_name</code>.</p>
101
103
 
@@ -107,34 +109,37 @@
107
109
 
108
110
  <p>For example, if you do this in a ERB view:</p>
109
111
 
110
- <pre class="code html"><code>&lt;body class=&quot;&lt;%= browser.classes %&gt;&quot;&gt;
112
+ <p><code>html
113
+ &lt;body class="&lt;%= browser.classes %&gt;"&gt;
111
114
  ...
112
- </code></pre>
115
+ </code></p>
113
116
 
114
117
  <p>The view will get compiled to this:</p>
115
118
 
116
- <pre class="code html"><code>&lt;body class=&quot;chrome version-1 version-1_2 version-1_2_3 platform-osx&quot;&gt;
119
+ <p><code>html
120
+ &lt;body class="chrome version-1 version-1_2 version-1_2_3 platform-osx"&gt;
117
121
  ...
118
- </code></pre>
122
+ </code></p>
119
123
 
120
124
  <p>And thus scoping your CSS will be trivial.</p>
121
125
 
122
- <h3>Querying the browser</h3>
126
+ <h3 id="querying-the-browser">Querying the browser</h3>
123
127
 
124
128
  <p>Brauser supports querying about name (method <code>is</code>), version (method <code>v</code>), platform (method <code>on</code>) and language (method <code>accepts</code>).</p>
125
129
 
126
130
  <p>The <code>is</code> method queries about a browser name (or a list of names) and optionally by version and platform:</p>
127
131
 
128
- <pre class="code ruby"><code><span class='comment'># We talk about the ending ? later.
129
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span>
130
- <span class='comment'># =&gt; true
131
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='symbol'>:msie</span><span class='comma'>,</span> <span class='symbol'>:firefox</span><span class='rbracket'>]</span><span class='rparen'>)</span>
132
- <span class='comment'># =&gt; false
133
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
134
- <span class='comment'># =&gt; true
135
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&gt;= 3</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:windows</span><span class='rparen'>)</span>
136
- <span class='comment'># =&gt; false
137
- </span></code></pre>
132
+ <p><code>ruby
133
+ # We talk about the ending ? later.
134
+ browser.is?(:chrome)
135
+ # =&gt; true
136
+ browser.is?([:msie, :firefox])
137
+ # =&gt; false
138
+ browser.is?(:chrome, {:lt =&gt; "2"}, :osx)
139
+ # =&gt; true
140
+ browser.is?(:chrome, "&gt;= 3", :windows)
141
+ # =&gt; false
142
+ </code></p>
138
143
 
139
144
  <p>The method <code>is</code> is the only which supports direct internal propagation to version and platform.</p>
140
145
 
@@ -142,47 +147,51 @@
142
147
 
143
148
  <p>In the case of hash, the syntax is <code>{:operator =&gt; 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>
144
149
 
145
- <p>In the case of expression, the syntax is <code>OPERATOR VALUE &amp;&amp; ..</code>, where <code>OPERATOR</code> is one of <code>[&quot;&lt;&quot;, &quot;&lt;=&quot;, &quot;=&quot;, &quot;==&quot;, &quot;&gt;=&quot;, &quot;&gt;&quot;]</code> and value specifies the version.</p>
150
+ <p>In the case of expression, the syntax is <code>OPERATOR VALUE &amp;&amp; ..</code>, where <code>OPERATOR</code> is one of <code>["&lt;", "&lt;=", "=", "==", "&gt;=", "&gt;"]</code> and value specifies the version.</p>
146
151
 
147
152
  <p>Examples:</p>
148
153
 
149
- <pre class="code ruby"><code><span class='comment'># Those two methods are equivalent.
150
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_v?'>v?</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:gt</span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='rbrace'>}</span><span class='rparen'>)</span>
151
- <span class='comment'># =&gt; true
152
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt; 2 &amp;&amp; &gt; 1</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
153
- <span class='comment'># =&gt; true
154
- </span></code></pre>
154
+ <p><code>ruby
155
+ # Those two methods are equivalent.
156
+ browser.v?({:lt =&gt; "2", :gt =&gt; 1})
157
+ # =&gt; true
158
+ browser.is?("&lt; 2 &amp;&amp; &gt; 1")
159
+ # =&gt; true
160
+ </code></p>
155
161
 
156
162
  <p>The method <code>on</code> check is the current browser in one of the specifed platform. The platform should be passed as <code>Symbol</code>.</p>
157
163
 
158
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span>
159
- <span class='comment'># =&gt; true
160
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='symbol'>:windows</span><span class='comma'>,</span> <span class='symbol'>:ios</span><span class='rbracket'>]</span><span class='rparen'>)</span>
161
- <span class='comment'># =&gt; false
162
- </span></code></pre>
164
+ <p><code>ruby
165
+ browser.on?(:osx)
166
+ # =&gt; true
167
+ browser.on?([:windows, :ios])
168
+ # =&gt; false
169
+ </code></p>
163
170
 
164
171
  <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>
165
172
 
166
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_accepts?'>accepts?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
167
- <span class='comment'># =&gt; true
168
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_accepts?'>accepts?</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>de</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>es</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
169
- <span class='comment'># =&gt; false
170
- </span></code></pre>
173
+ <p><code>ruby
174
+ browser.accepts?("en")
175
+ # =&gt; true
176
+ browser.accepts?(["de", "es"])
177
+ # =&gt; false
178
+ </code></p>
171
179
 
172
- <p>Every query method exists in two forms: the concatenation one (the method name doesn&#39;t end with a <code>?</code>.</p>
180
+ <p>Every query method exists in two forms: the concatenation one (the method name doesn&#8217;t end with a <code>?</code>.</p>
173
181
 
174
182
  <p>The former return a <code>Query</code> object, which supports the same query method of the browser and thus enables concatenation.</p>
175
183
 
176
- <p>The latter return a boolean object, and it&#39;s equivalent to calling <code>result</code> on the query after concatenation.</p>
184
+ <p>The latter return a boolean object, and it&#8217;s equivalent to calling <code>result</code> on the query after concatenation.</p>
177
185
 
178
186
  <p>Ideally, you should use the <code>?</code> version to end the query and fetch the result.</p>
179
187
 
180
- <pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
181
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
182
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
183
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span>
184
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
185
- </code></pre>
188
+ <p><code>ruby
189
+ # These expressions are equivalent.
190
+ browser.is?(:chrome, {:lt =&gt; "2"}, :osx)
191
+ browser.is(:chrome, {:lt =&gt; "2"}, :osx).result
192
+ browser.is(:chrome).v({:lt =&gt; "2"}).on?(:osx)
193
+ browser.is(:chrome).v({:lt =&gt; "2"}).on(:osx).result
194
+ </code></p>
186
195
 
187
196
  <p>Finally, Brauser support dynamic query operator to write simple queries without using concatenation.</p>
188
197
 
@@ -192,51 +201,54 @@
192
201
 
193
202
  <p>Example:</p>
194
203
 
195
- <pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
196
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt; 2 &amp;&amp; &gt; 1.2</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
197
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is_chrome__v_lt_2_and_gt_1_2__on_osx'>is_chrome__v_lt_2_and_gt_1_2__on_osx</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
204
+ <p>```ruby
205
+ # These expressions are equivalent.
206
+ browser.is(:chrome).v(&#8220;&lt; 2 &amp;&amp; &gt; 1.2&#8221;).on(:osx).result
207
+ browser.is_chrome__v_lt<em>2_and_gt</em>1_2__on_osx.result</p>
198
208
 
199
- <span class='comment'># These expressions are equivalent.
200
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt; 2 &amp;&amp; &gt; 1.2</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span>
201
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is_chrome__v_lt_2_and_gt_1_2__on_osx?'>is_chrome__v_lt_2_and_gt_1_2__on_osx?</span>
202
- </code></pre>
209
+ <h1 id="these-expressions-are-equivalent">These expressions are equivalent.</h1>
210
+ <p>browser.is(:chrome).v(&#8220;&lt; 2 &amp;&amp; &gt; 1.2&#8221;).on?(:osx)
211
+ browser.is_chrome__v_lt<em>2_and_gt</em>1_2__on_osx?
212
+ ```</p>
203
213
 
204
- <h3>Adding new browsers</h3>
214
+ <h3 id="adding-new-browsers">Adding new browsers</h3>
205
215
 
206
216
  <p>To add new browsers, simply call <code>register_browser</code>.</p>
207
217
 
208
218
  <p>This methods accepts a single entry or an array of entries in the following format: <code>[name, name_match, version_match, label]</code>:</p>
209
219
 
210
220
  <ul>
211
- <li><code>name</code> is the name of the browser. Should be a <code>Symbol</code>.</li>
212
- <li><code>name_match</code> is a <code>Regexp</code> to match against the user agent to detect the current browser.</li>
213
- <li><code>version_match</code> is a <code>Regexp</code> which last capture group holds the version of the browser.</li>
214
- <li><code>label</code> is the human readable name of the browser.</li>
221
+ <li><code>name</code> is the name of the browser. Should be a <code>Symbol</code>.</li>
222
+ <li><code>name_match</code> is a <code>Regexp</code> to match against the user agent to detect the current browser.</li>
223
+ <li><code>version_match</code> is a <code>Regexp</code> which last capture group holds the version of the browser.</li>
224
+ <li><code>label</code> is the human readable name of the browser.</li>
215
225
  </ul>
216
226
 
217
227
  <p>For example, for Google Chrome the call should be:</p>
218
228
 
219
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_register_browser'>register_browser</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>((chrome)|(chromium))</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.+Chrom[a-z]+\/)([a-z0-9.]+)</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Google Chrome</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
220
- </code></pre>
229
+ <p><code>ruby
230
+ browser.register_browser(:chrome, /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i, "Google Chrome")
231
+ </code></p>
221
232
 
222
- <h3>Adding new platforms</h3>
233
+ <h3 id="adding-new-platforms">Adding new platforms</h3>
223
234
 
224
235
  <p>To add new platforms, simply call <code>register_platform</code>.</p>
225
236
 
226
237
  <p>This method accepts a single entry or an array of entries in the following format: <code>[name, matcher, label]</code>:</p>
227
238
 
228
239
  <ul>
229
- <li><code>name</code> is the name of the platform. Should be a <code>Symbol</code>.</li>
230
- <li><code>matcher</code> is a <code>Regexp</code> to match against the user agent to detect the current platform.</li>
231
- <li><code>label</code> is the human readable name of the platform.</li>
240
+ <li><code>name</code> is the name of the platform. Should be a <code>Symbol</code>.</li>
241
+ <li><code>matcher</code> is a <code>Regexp</code> to match against the user agent to detect the current platform.</li>
242
+ <li><code>label</code> is the human readable name of the platform.</li>
232
243
  </ul>
233
244
 
234
245
  <p>For example, for Mac OS X the call should be:</p>
235
246
 
236
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_register_platform'>register_platform</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>mac|macintosh|mac os x</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Apple MacOS X</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
237
- </code></pre>
247
+ <p><code>ruby
248
+ browser.register_platform(:osx, /mac|macintosh|mac os x/i, "Apple MacOS X")
249
+ </code></p>
238
250
 
239
- <h3>Adding new languages</h3>
251
+ <h3 id="adding-new-languages">Adding new languages</h3>
240
252
 
241
253
  <p>To add new languages, simply call <code>register_language</code>.</p>
242
254
 
@@ -244,32 +256,33 @@
244
256
 
245
257
  <p>For example, for Italian the call should be:</p>
246
258
 
247
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_register_language'>register_language</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>it</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Italian</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
248
- </code></pre>
259
+ <p><code>ruby
260
+ browser.register_language("it", "Italian")
261
+ </code></p>
249
262
 
250
- <h2>Contributing to brauser</h2>
263
+ <h2 id="contributing-to-brauser">Contributing to brauser</h2>
251
264
 
252
265
  <ul>
253
- <li>Check out the latest master to make sure the feature hasn&#39;t been implemented or the bug hasn&#39;t been fixed yet.</li>
254
- <li>Check out the issue tracker to make sure someone already hasn&#39;t requested it and/or contributed it.</li>
255
- <li>Fork the project.</li>
256
- <li>Start a feature/bugfix branch.</li>
257
- <li>Commit and push until you are happy with your contribution.</li>
258
- <li>Make sure to add tests for it. This is important so I don&#39;t break it in a future version unintentionally.</li>
259
- <li>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.</li>
266
+ <li>Check out the latest master to make sure the feature hasn&#8217;t been implemented or the bug hasn&#8217;t been fixed yet.</li>
267
+ <li>Check out the issue tracker to make sure someone already hasn&#8217;t requested it and/or contributed it.</li>
268
+ <li>Fork the project.</li>
269
+ <li>Start a feature/bugfix branch.</li>
270
+ <li>Commit and push until you are happy with your contribution.</li>
271
+ <li>Make sure to add tests for it. This is important so I don&#8217;t break it in a future version unintentionally.</li>
272
+ <li>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.</li>
260
273
  </ul>
261
274
 
262
- <h2>Copyright</h2>
275
+ <h2 id="copyright">Copyright</h2>
263
276
 
264
- <p>Copyright (C) 2013 and above Shogun (<a href="mailto:shogun_panda@me.com">shogun_panda@me.com</a>).</p>
277
+ <p>Copyright (C) 2013 and above Shogun (shogun_panda@me.com).</p>
265
278
 
266
- <p>Licensed under the MIT license, which can be found at <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>.</p>
279
+ <p>Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.</p>
267
280
  </div></div>
268
281
 
269
282
  <div id="footer">
270
- Generated on Sat Feb 2 17:47:18 2013 by
283
+ Generated on Fri Feb 8 08:12:31 2013 by
271
284
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
272
- 0.8.3 (ruby-1.9.3).
285
+ 0.8.4.1 (ruby-1.9.3).
273
286
  </div>
274
287
 
275
288
  </body>
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.3</title>
7
+ <title>Documentation by YARD 0.8.4.1</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
- &mdash; Documentation by YARD 0.8.3
9
+ &mdash; Documentation by YARD 0.8.4.1
10
10
 
11
11
  </title>
12
12
 
@@ -61,41 +61,43 @@
61
61
 
62
62
  <iframe id="search_frame"></iframe>
63
63
 
64
- <div id="content"><div id='filecontents'><h1>brauser</h1>
64
+ <div id="content"><div id='filecontents'><h1 id="brauser">brauser</h1>
65
65
 
66
- <p><a href="http://travis-ci.org/ShogunPanda/brauser"><img src="https://secure.travis-ci.org/ShogunPanda/brauser.png?branch=master" alt="Build Status"></a>
67
- <a href="https://gemnasium.com/ShogunPanda/brauser"><img src="https://gemnasium.com/ShogunPanda/brauser.png?travis" alt="Dependency Status"></a>
68
- <a href="https://codeclimate.com/github/ShogunPanda/brauser"><img src="https://codeclimate.com/github/ShogunPanda/brauser.png" alt="Code Climate"></a></p>
66
+ <p><a href="http://travis-ci.org/ShogunPanda/brauser"><img src="https://secure.travis-ci.org/ShogunPanda/brauser.png?branch=master" alt="Build Status" /></a>
67
+ <a href="https://gemnasium.com/ShogunPanda/brauser"><img src="https://gemnasium.com/ShogunPanda/brauser.png?travis" alt="Dependency Status" /></a>
68
+ <a href="https://codeclimate.com/github/ShogunPanda/brauser"><img src="https://codeclimate.com/github/ShogunPanda/brauser.png" alt="Code Climate" /></a></p>
69
69
 
70
70
  <p>A framework agnostic browser detection and querying helper.</p>
71
71
 
72
- <p><a href="http://sw.cow.tc/brauser">http://sw.cow.tc/brauser</a></p>
72
+ <p>http://sw.cow.tc/brauser</p>
73
73
 
74
- <p><a href="http://rdoc.info/gems/brauser">http://rdoc.info/gems/brauser</a></p>
74
+ <p>http://rdoc.info/gems/brauser</p>
75
75
 
76
- <h2>Description</h2>
76
+ <h2 id="description">Description</h2>
77
77
 
78
78
  <p>Brauser is a framework agnostic helper that helps you in targeting your applications against most diffused browsers.</p>
79
79
 
80
- <h3>Installation</h3>
80
+ <h3 id="installation">Installation</h3>
81
81
 
82
82
  <p>Brauser comes with a Ruby on Rails hooks (more framework to follow), so for Rails you have just to add this to your Gemfile:</p>
83
83
 
84
- <pre class="code ruby"><code><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>brauser</span><span class='tstring_end'>&quot;</span></span>
85
- </code></pre>
84
+ <p><code>ruby
85
+ gem "brauser"
86
+ </code></p>
86
87
 
87
88
  <p>Once done that, every controller in your application will have a <code>browser</code> method (also extended to views/layout via <code>helper_method</code>).</p>
88
89
 
89
- <p>If you don&#39;t use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:</p>
90
+ <p>If you don&#8217;t use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:</p>
90
91
 
91
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span> <span class='op'>=</span> <span class='const'>Brauser</span><span class='op'>::</span><span class='const'>Browser</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>USER_AGENT_HEADER</span><span class='comma'>,</span> <span class='const'>ACCEPT_LANGUAGE_HEADER</span><span class='rparen'>)</span>
92
- </code></pre>
92
+ <p><code>ruby
93
+ browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
94
+ </code></p>
93
95
 
94
96
  <p>where the first argument is the HTTP header <code>User-Agent</code>, and the second is the HTTP header <code>Accept-Language</code>.</p>
95
97
 
96
- <p>For the rest of this document, let&#39;s assume you use Chrome 1.2.3 on Mac OS X.</p>
98
+ <p>For the rest of this document, let&#8217;s assume you use Chrome 1.2.3 on Mac OS X.</p>
97
99
 
98
- <h3>Getting browser information</h3>
100
+ <h3 id="getting-browser-information">Getting browser information</h3>
99
101
 
100
102
  <p>Once you instantiate the browser, you can query the browser about <code>name</code>, <code>version</code> and <code>platform</code>. You can also get readable name and platforms via <code>readable_name</code> and <code>platform_name</code>.</p>
101
103
 
@@ -107,34 +109,37 @@
107
109
 
108
110
  <p>For example, if you do this in a ERB view:</p>
109
111
 
110
- <pre class="code html"><code>&lt;body class=&quot;&lt;%= browser.classes %&gt;&quot;&gt;
112
+ <p><code>html
113
+ &lt;body class="&lt;%= browser.classes %&gt;"&gt;
111
114
  ...
112
- </code></pre>
115
+ </code></p>
113
116
 
114
117
  <p>The view will get compiled to this:</p>
115
118
 
116
- <pre class="code html"><code>&lt;body class=&quot;chrome version-1 version-1_2 version-1_2_3 platform-osx&quot;&gt;
119
+ <p><code>html
120
+ &lt;body class="chrome version-1 version-1_2 version-1_2_3 platform-osx"&gt;
117
121
  ...
118
- </code></pre>
122
+ </code></p>
119
123
 
120
124
  <p>And thus scoping your CSS will be trivial.</p>
121
125
 
122
- <h3>Querying the browser</h3>
126
+ <h3 id="querying-the-browser">Querying the browser</h3>
123
127
 
124
128
  <p>Brauser supports querying about name (method <code>is</code>), version (method <code>v</code>), platform (method <code>on</code>) and language (method <code>accepts</code>).</p>
125
129
 
126
130
  <p>The <code>is</code> method queries about a browser name (or a list of names) and optionally by version and platform:</p>
127
131
 
128
- <pre class="code ruby"><code><span class='comment'># We talk about the ending ? later.
129
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span>
130
- <span class='comment'># =&gt; true
131
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='symbol'>:msie</span><span class='comma'>,</span> <span class='symbol'>:firefox</span><span class='rbracket'>]</span><span class='rparen'>)</span>
132
- <span class='comment'># =&gt; false
133
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
134
- <span class='comment'># =&gt; true
135
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&gt;= 3</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:windows</span><span class='rparen'>)</span>
136
- <span class='comment'># =&gt; false
137
- </span></code></pre>
132
+ <p><code>ruby
133
+ # We talk about the ending ? later.
134
+ browser.is?(:chrome)
135
+ # =&gt; true
136
+ browser.is?([:msie, :firefox])
137
+ # =&gt; false
138
+ browser.is?(:chrome, {:lt =&gt; "2"}, :osx)
139
+ # =&gt; true
140
+ browser.is?(:chrome, "&gt;= 3", :windows)
141
+ # =&gt; false
142
+ </code></p>
138
143
 
139
144
  <p>The method <code>is</code> is the only which supports direct internal propagation to version and platform.</p>
140
145
 
@@ -142,47 +147,51 @@
142
147
 
143
148
  <p>In the case of hash, the syntax is <code>{:operator =&gt; 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>
144
149
 
145
- <p>In the case of expression, the syntax is <code>OPERATOR VALUE &amp;&amp; ..</code>, where <code>OPERATOR</code> is one of <code>[&quot;&lt;&quot;, &quot;&lt;=&quot;, &quot;=&quot;, &quot;==&quot;, &quot;&gt;=&quot;, &quot;&gt;&quot;]</code> and value specifies the version.</p>
150
+ <p>In the case of expression, the syntax is <code>OPERATOR VALUE &amp;&amp; ..</code>, where <code>OPERATOR</code> is one of <code>["&lt;", "&lt;=", "=", "==", "&gt;=", "&gt;"]</code> and value specifies the version.</p>
146
151
 
147
152
  <p>Examples:</p>
148
153
 
149
- <pre class="code ruby"><code><span class='comment'># Those two methods are equivalent.
150
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_v?'>v?</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:gt</span> <span class='op'>=&gt;</span> <span class='int'>1</span><span class='rbrace'>}</span><span class='rparen'>)</span>
151
- <span class='comment'># =&gt; true
152
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt; 2 &amp;&amp; &gt; 1</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
153
- <span class='comment'># =&gt; true
154
- </span></code></pre>
154
+ <p><code>ruby
155
+ # Those two methods are equivalent.
156
+ browser.v?({:lt =&gt; "2", :gt =&gt; 1})
157
+ # =&gt; true
158
+ browser.is?("&lt; 2 &amp;&amp; &gt; 1")
159
+ # =&gt; true
160
+ </code></p>
155
161
 
156
162
  <p>The method <code>on</code> check is the current browser in one of the specifed platform. The platform should be passed as <code>Symbol</code>.</p>
157
163
 
158
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span>
159
- <span class='comment'># =&gt; true
160
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='symbol'>:windows</span><span class='comma'>,</span> <span class='symbol'>:ios</span><span class='rbracket'>]</span><span class='rparen'>)</span>
161
- <span class='comment'># =&gt; false
162
- </span></code></pre>
164
+ <p><code>ruby
165
+ browser.on?(:osx)
166
+ # =&gt; true
167
+ browser.on?([:windows, :ios])
168
+ # =&gt; false
169
+ </code></p>
163
170
 
164
171
  <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>
165
172
 
166
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_accepts?'>accepts?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>en</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
167
- <span class='comment'># =&gt; true
168
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_accepts?'>accepts?</span><span class='lparen'>(</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>de</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>es</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
169
- <span class='comment'># =&gt; false
170
- </span></code></pre>
173
+ <p><code>ruby
174
+ browser.accepts?("en")
175
+ # =&gt; true
176
+ browser.accepts?(["de", "es"])
177
+ # =&gt; false
178
+ </code></p>
171
179
 
172
- <p>Every query method exists in two forms: the concatenation one (the method name doesn&#39;t end with a <code>?</code>.</p>
180
+ <p>Every query method exists in two forms: the concatenation one (the method name doesn&#8217;t end with a <code>?</code>.</p>
173
181
 
174
182
  <p>The former return a <code>Query</code> object, which supports the same query method of the browser and thus enables concatenation.</p>
175
183
 
176
- <p>The latter return a boolean object, and it&#39;s equivalent to calling <code>result</code> on the query after concatenation.</p>
184
+ <p>The latter return a boolean object, and it&#8217;s equivalent to calling <code>result</code> on the query after concatenation.</p>
177
185
 
178
186
  <p>Ideally, you should use the <code>?</code> version to end the query and fetch the result.</p>
179
187
 
180
- <pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
181
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is?'>is?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
182
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
183
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span>
184
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='symbol'>:lt</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>2</span><span class='tstring_end'>&quot;</span></span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
185
- </code></pre>
188
+ <p><code>ruby
189
+ # These expressions are equivalent.
190
+ browser.is?(:chrome, {:lt =&gt; "2"}, :osx)
191
+ browser.is(:chrome, {:lt =&gt; "2"}, :osx).result
192
+ browser.is(:chrome).v({:lt =&gt; "2"}).on?(:osx)
193
+ browser.is(:chrome).v({:lt =&gt; "2"}).on(:osx).result
194
+ </code></p>
186
195
 
187
196
  <p>Finally, Brauser support dynamic query operator to write simple queries without using concatenation.</p>
188
197
 
@@ -192,51 +201,54 @@
192
201
 
193
202
  <p>Example:</p>
194
203
 
195
- <pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
196
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt; 2 &amp;&amp; &gt; 1.2</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
197
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is_chrome__v_lt_2_and_gt_1_2__on_osx'>is_chrome__v_lt_2_and_gt_1_2__on_osx</span><span class='period'>.</span><span class='id identifier rubyid_result'>result</span>
204
+ <p>```ruby
205
+ # These expressions are equivalent.
206
+ browser.is(:chrome).v(&#8220;&lt; 2 &amp;&amp; &gt; 1.2&#8221;).on(:osx).result
207
+ browser.is_chrome__v_lt<em>2_and_gt</em>1_2__on_osx.result</p>
198
208
 
199
- <span class='comment'># These expressions are equivalent.
200
- </span><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is'>is</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_v'>v</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt; 2 &amp;&amp; &gt; 1.2</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_on?'>on?</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='rparen'>)</span>
201
- <span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_is_chrome__v_lt_2_and_gt_1_2__on_osx?'>is_chrome__v_lt_2_and_gt_1_2__on_osx?</span>
202
- </code></pre>
209
+ <h1 id="these-expressions-are-equivalent">These expressions are equivalent.</h1>
210
+ <p>browser.is(:chrome).v(&#8220;&lt; 2 &amp;&amp; &gt; 1.2&#8221;).on?(:osx)
211
+ browser.is_chrome__v_lt<em>2_and_gt</em>1_2__on_osx?
212
+ ```</p>
203
213
 
204
- <h3>Adding new browsers</h3>
214
+ <h3 id="adding-new-browsers">Adding new browsers</h3>
205
215
 
206
216
  <p>To add new browsers, simply call <code>register_browser</code>.</p>
207
217
 
208
218
  <p>This methods accepts a single entry or an array of entries in the following format: <code>[name, name_match, version_match, label]</code>:</p>
209
219
 
210
220
  <ul>
211
- <li><code>name</code> is the name of the browser. Should be a <code>Symbol</code>.</li>
212
- <li><code>name_match</code> is a <code>Regexp</code> to match against the user agent to detect the current browser.</li>
213
- <li><code>version_match</code> is a <code>Regexp</code> which last capture group holds the version of the browser.</li>
214
- <li><code>label</code> is the human readable name of the browser.</li>
221
+ <li><code>name</code> is the name of the browser. Should be a <code>Symbol</code>.</li>
222
+ <li><code>name_match</code> is a <code>Regexp</code> to match against the user agent to detect the current browser.</li>
223
+ <li><code>version_match</code> is a <code>Regexp</code> which last capture group holds the version of the browser.</li>
224
+ <li><code>label</code> is the human readable name of the browser.</li>
215
225
  </ul>
216
226
 
217
227
  <p>For example, for Google Chrome the call should be:</p>
218
228
 
219
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_register_browser'>register_browser</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>((chrome)|(chromium))</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(.+Chrom[a-z]+\/)([a-z0-9.]+)</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Google Chrome</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
220
- </code></pre>
229
+ <p><code>ruby
230
+ browser.register_browser(:chrome, /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i, "Google Chrome")
231
+ </code></p>
221
232
 
222
- <h3>Adding new platforms</h3>
233
+ <h3 id="adding-new-platforms">Adding new platforms</h3>
223
234
 
224
235
  <p>To add new platforms, simply call <code>register_platform</code>.</p>
225
236
 
226
237
  <p>This method accepts a single entry or an array of entries in the following format: <code>[name, matcher, label]</code>:</p>
227
238
 
228
239
  <ul>
229
- <li><code>name</code> is the name of the platform. Should be a <code>Symbol</code>.</li>
230
- <li><code>matcher</code> is a <code>Regexp</code> to match against the user agent to detect the current platform.</li>
231
- <li><code>label</code> is the human readable name of the platform.</li>
240
+ <li><code>name</code> is the name of the platform. Should be a <code>Symbol</code>.</li>
241
+ <li><code>matcher</code> is a <code>Regexp</code> to match against the user agent to detect the current platform.</li>
242
+ <li><code>label</code> is the human readable name of the platform.</li>
232
243
  </ul>
233
244
 
234
245
  <p>For example, for Mac OS X the call should be:</p>
235
246
 
236
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_register_platform'>register_platform</span><span class='lparen'>(</span><span class='symbol'>:osx</span><span class='comma'>,</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>mac|macintosh|mac os x</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Apple MacOS X</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
237
- </code></pre>
247
+ <p><code>ruby
248
+ browser.register_platform(:osx, /mac|macintosh|mac os x/i, "Apple MacOS X")
249
+ </code></p>
238
250
 
239
- <h3>Adding new languages</h3>
251
+ <h3 id="adding-new-languages">Adding new languages</h3>
240
252
 
241
253
  <p>To add new languages, simply call <code>register_language</code>.</p>
242
254
 
@@ -244,32 +256,33 @@
244
256
 
245
257
  <p>For example, for Italian the call should be:</p>
246
258
 
247
- <pre class="code ruby"><code><span class='id identifier rubyid_browser'>browser</span><span class='period'>.</span><span class='id identifier rubyid_register_language'>register_language</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>it</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Italian</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
248
- </code></pre>
259
+ <p><code>ruby
260
+ browser.register_language("it", "Italian")
261
+ </code></p>
249
262
 
250
- <h2>Contributing to brauser</h2>
263
+ <h2 id="contributing-to-brauser">Contributing to brauser</h2>
251
264
 
252
265
  <ul>
253
- <li>Check out the latest master to make sure the feature hasn&#39;t been implemented or the bug hasn&#39;t been fixed yet.</li>
254
- <li>Check out the issue tracker to make sure someone already hasn&#39;t requested it and/or contributed it.</li>
255
- <li>Fork the project.</li>
256
- <li>Start a feature/bugfix branch.</li>
257
- <li>Commit and push until you are happy with your contribution.</li>
258
- <li>Make sure to add tests for it. This is important so I don&#39;t break it in a future version unintentionally.</li>
259
- <li>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.</li>
266
+ <li>Check out the latest master to make sure the feature hasn&#8217;t been implemented or the bug hasn&#8217;t been fixed yet.</li>
267
+ <li>Check out the issue tracker to make sure someone already hasn&#8217;t requested it and/or contributed it.</li>
268
+ <li>Fork the project.</li>
269
+ <li>Start a feature/bugfix branch.</li>
270
+ <li>Commit and push until you are happy with your contribution.</li>
271
+ <li>Make sure to add tests for it. This is important so I don&#8217;t break it in a future version unintentionally.</li>
272
+ <li>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.</li>
260
273
  </ul>
261
274
 
262
- <h2>Copyright</h2>
275
+ <h2 id="copyright">Copyright</h2>
263
276
 
264
- <p>Copyright (C) 2013 and above Shogun (<a href="mailto:shogun_panda@me.com">shogun_panda@me.com</a>).</p>
277
+ <p>Copyright (C) 2013 and above Shogun (shogun_panda@me.com).</p>
265
278
 
266
- <p>Licensed under the MIT license, which can be found at <a href="http://www.opensource.org/licenses/mit-license.php">http://www.opensource.org/licenses/mit-license.php</a>.</p>
279
+ <p>Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.</p>
267
280
  </div></div>
268
281
 
269
282
  <div id="footer">
270
- Generated on Sat Feb 2 17:47:18 2013 by
283
+ Generated on Fri Feb 8 08:12:31 2013 by
271
284
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
272
- 0.8.3 (ruby-1.9.3).
285
+ 0.8.4.1 (ruby-1.9.3).
273
286
  </div>
274
287
 
275
288
  </body>