brauser 1.0.1 → 1.0.5
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/README.md +180 -1
- data/doc/Brauser.html +1 -1
- data/doc/Brauser/Browser.html +4 -4
- data/doc/Brauser/Hooks.html +1 -1
- data/doc/Brauser/Hooks/RubyOnRails.html +1 -1
- data/doc/Brauser/Query.html +1 -1
- data/doc/Brauser/Version.html +2 -2
- data/doc/_index.html +1 -1
- data/doc/file.README.html +172 -2
- data/doc/index.html +172 -2
- data/doc/top-level-namespace.html +1 -1
- data/lib/brauser/browser.rb +3 -3
- data/lib/brauser/version.rb +1 -1
- metadata +123 -132
data/README.md
CHANGED
@@ -9,7 +9,186 @@ http://github.com/ShogunPanda/brauser
|
|
9
9
|
|
10
10
|
## Description
|
11
11
|
|
12
|
-
|
12
|
+
Brauser is a framework agnostic helper that helps you in targeting your applications against most diffused browsers.
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
Brauser comes with a Ruby on Rails hooks (more framework to follow), so for Rails you have just to add this to your Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem "brauser"
|
20
|
+
```
|
21
|
+
|
22
|
+
Once done that, every controller in your application will have a `browser` method (also extended to views/layout via `helper_method`).
|
23
|
+
|
24
|
+
If you don't use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
browser = Brauser::Browser.new(USER_AGENT_HEADER, ACCEPT_LANGUAGE_HEADER)
|
28
|
+
```
|
29
|
+
|
30
|
+
where the first argument is the HTTP header `User-Agent`, and the second is the HTTP header `Accept-Language`.
|
31
|
+
|
32
|
+
For the rest of this document, let's assume you use Chrome 1.2.3 on Mac OS X.
|
33
|
+
|
34
|
+
### Getting browser information
|
35
|
+
|
36
|
+
Once you instantiate the browser, you can query the browser about `name`, `version` and `platform`. You can also get readable name and platforms via `readable_name` and `platform_name`.
|
37
|
+
|
38
|
+
The version is returned as a `String`, and you can use `Brauser::Browser.compare_versions` to compare against another version.
|
39
|
+
|
40
|
+
The name and the platform are returned as `Symbol` and can be in the range of names and engines registered via `register_browser`, `register_default_browsers`, `register_platform` and `register_default_platforms`.
|
41
|
+
|
42
|
+
Also, you can get global information using `browser.to_s` or `browser.classes`. This will return an array or a string already formatted to be used in your views to scope your CSS.
|
43
|
+
|
44
|
+
For example, if you do this in a ERB view:
|
45
|
+
|
46
|
+
```html
|
47
|
+
<body class="<%= browser.classes %>">
|
48
|
+
...
|
49
|
+
```
|
50
|
+
|
51
|
+
The view will get compiled to this:
|
52
|
+
|
53
|
+
```html
|
54
|
+
<body class="chrome version-1 version-1_2 version-1_2_3 platform-osx">
|
55
|
+
...
|
56
|
+
```
|
57
|
+
|
58
|
+
And thus scoping your CSS will be trivial.
|
59
|
+
|
60
|
+
### Querying the browser
|
61
|
+
|
62
|
+
Brauser supports querying about name (method `is`), version (method `v`), platform (method `on`) and language (method `accepts`).
|
63
|
+
|
64
|
+
The `is` method queries about a browser name (or a list of names) and optionally by version and platform:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
# We talk about the ending ? later.
|
68
|
+
browser.is?(:chrome)
|
69
|
+
# => true
|
70
|
+
browser.is?([:msie, :firefox])
|
71
|
+
# => false
|
72
|
+
browser.is?(:chrome, {:lt => "2"}, :osx)
|
73
|
+
# => true
|
74
|
+
browser.is?(:chrome, ">= 3", :windows)
|
75
|
+
# => false
|
76
|
+
```
|
77
|
+
|
78
|
+
The method `is` is the only which supports direct internal propagation to version and platform.
|
79
|
+
|
80
|
+
The `v` method queries about the browser version. You can specify the comparison with an hash or a little expression.
|
81
|
+
|
82
|
+
In the case of hash, the syntax is `{:operator => value}`, where `:operator` is one of `[:lt, :lte, :eq, :gte, :gt]` and value can be a Float or a String.
|
83
|
+
|
84
|
+
In the case of expression, the syntax is `OPERATOR VALUE && ..`, where `OPERATOR` is one of `["<", "<=", "=", "==", ">=", ">"]` and value specifies the version.
|
85
|
+
|
86
|
+
Examples:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
# Those two methods are equivalent.
|
90
|
+
browser.v?({:lt => "2", :gt => 1})
|
91
|
+
# => true
|
92
|
+
browser.is?("< 2 && > 1")
|
93
|
+
# => true
|
94
|
+
```
|
95
|
+
|
96
|
+
The method `on` check is the current browser in one of the specifed platform. The platform should be passed as `Symbol`.
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
browser.on?(:osx)
|
100
|
+
# => true
|
101
|
+
browser.on?([:windows, :ios])
|
102
|
+
# => false
|
103
|
+
```
|
104
|
+
|
105
|
+
At the end, the method `accepts` checks if the browser accepts one of the specified languages. Languages should be passed as language codes in `String`.
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
browser.accepts?("en")
|
109
|
+
# => true
|
110
|
+
browser.accepts?(["de", "es"])
|
111
|
+
# => false
|
112
|
+
```
|
113
|
+
|
114
|
+
Every query method exists in two forms: the concatenation one (the method name doesn't end with a `?`.
|
115
|
+
|
116
|
+
The former return a `Query` object, which supports the same query method of the browser and thus enables concatenation.
|
117
|
+
|
118
|
+
The latter return a boolean object, and it's equivalent to calling `result` on the query after concatenation.
|
119
|
+
|
120
|
+
Ideally, you should use the `?` version to end the query and fetch the result.
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
# These expressions are equivalent.
|
124
|
+
browser.is?(:chrome, {:lt => "2"}, :osx)
|
125
|
+
browser.is(:chrome, {:lt => "2"}, :osx).result
|
126
|
+
browser.is(:chrome).v({:lt => "2"}).on?(:osx)
|
127
|
+
browser.is(:chrome).v({:lt => "2"}).on(:osx).result
|
128
|
+
```
|
129
|
+
|
130
|
+
Finally, Brauser support dynamic query operator to write simple queries without using concatenation.
|
131
|
+
|
132
|
+
You construct the method just using operator specified above, separating method name and method arguments with a `_` and different methods with a `__`.
|
133
|
+
|
134
|
+
For the version, use the expression form but use symbol operators and replace `.` with `_` and `&&` with `and`.
|
135
|
+
|
136
|
+
Example:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
# These expressions are equivalent.
|
140
|
+
browser.is(:chrome).v("< 2 && > 1.2").on(:osx).result
|
141
|
+
browser.is_chrome__v_lt_2_and_gt_1_2__on_osx.result
|
142
|
+
|
143
|
+
# These expressions are equivalent.
|
144
|
+
browser.is(:chrome).v("< 2 && > 1.2").on?(:osx)
|
145
|
+
browser.is_chrome__v_lt_2_and_gt_1_2__on_osx?
|
146
|
+
```
|
147
|
+
|
148
|
+
### Adding new browsers
|
149
|
+
|
150
|
+
To add new browsers, simply call `register_browser`.
|
151
|
+
|
152
|
+
This methods accepts a single entry or an array of entries in the following format: `[name, name_match, version_match, label]`:
|
153
|
+
|
154
|
+
* `name` is the name of the browser. Should be a `Symbol`.
|
155
|
+
* `name_match` is a `Regexp` to match against the user agent to detect the current browser.
|
156
|
+
* `version_match` is a `Regexp` which last capture group holds the version of the browser.
|
157
|
+
* `label` is the human readable name of the browser.
|
158
|
+
|
159
|
+
For example, for Google Chrome the call should be:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
browser.register_browser(:chrome, /((chrome)|(chromium))/i, /(.+Chrom[a-z]+\/)([a-z0-9.]+)/i, "Google Chrome")
|
163
|
+
```
|
164
|
+
|
165
|
+
### Adding new platforms
|
166
|
+
|
167
|
+
To add new platforms, simply call `register_platform`.
|
168
|
+
|
169
|
+
This method accepts a single entry or an array of entries in the following format: `[name, matcher, label]`:
|
170
|
+
|
171
|
+
* `name` is the name of the platform. Should be a `Symbol`.
|
172
|
+
* `matcher` is a `Regexp` to match against the user agent to detect the current platform.
|
173
|
+
* `label` is the human readable name of the platform.
|
174
|
+
|
175
|
+
For example, for Mac OS X the call should be:
|
176
|
+
|
177
|
+
```ruby
|
178
|
+
browser.register_platform(:osx, /mac|macintosh|mac os x/i, "Apple MacOS X")
|
179
|
+
```
|
180
|
+
|
181
|
+
### Adding new languages
|
182
|
+
|
183
|
+
To add new languages, simply call `register_language`.
|
184
|
+
|
185
|
+
This method accepts a single pair of code and label or an hash where keys are language code and values are labels.
|
186
|
+
|
187
|
+
For example, for Italian the call should be:
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
browser.register_language("it", "Italian")
|
191
|
+
```
|
13
192
|
|
14
193
|
## Contributing to brauser
|
15
194
|
|
data/doc/Brauser.html
CHANGED
@@ -120,7 +120,7 @@
|
|
120
120
|
</div>
|
121
121
|
|
122
122
|
<div id="footer">
|
123
|
-
Generated on
|
123
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
124
124
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
125
125
|
0.8.2.1 (ruby-1.9.2).
|
126
126
|
</div>
|
data/doc/Brauser/Browser.html
CHANGED
@@ -2985,7 +2985,7 @@
|
|
2985
2985
|
|
2986
2986
|
<span class='kw'>def</span> <span class='id identifier rubyid_accepts'>accepts</span><span class='lparen'>(</span><span class='id identifier rubyid_langs'>langs</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
2987
2987
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse_accept_language'>parse_accept_language</span><span class='lparen'>(</span><span class='ivar'>@accept_language</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='ivar'>@languages</span>
|
2988
|
-
<span class='op'>::</span><span class='const'>Brauser</span><span class='op'>::</span><span class='const'>Query</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='ivar'>@languages</span> <span class='op'>&</span> <span class='id identifier rubyid_langs'>langs</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span><span class='rparen'>)</span>
|
2988
|
+
<span class='op'>::</span><span class='const'>Brauser</span><span class='op'>::</span><span class='const'>Query</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='lparen'>(</span><span class='ivar'>@languages</span> <span class='op'>&</span> <span class='id identifier rubyid_langs'>langs</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_l'>l</span><span class='op'>|</span> <span class='id identifier rubyid_l'>l</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span> <span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span><span class='rparen'>)</span>
|
2989
2989
|
<span class='kw'>end</span></pre>
|
2990
2990
|
</td>
|
2991
2991
|
</tr>
|
@@ -3408,7 +3408,7 @@
|
|
3408
3408
|
<span class='id identifier rubyid_platforms'>platforms</span> <span class='op'>=</span> <span class='id identifier rubyid_platforms'>platforms</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span>
|
3409
3409
|
|
3410
3410
|
<span class='comment'># Adjust names
|
3411
|
-
</span> <span class='id identifier rubyid_names'>names</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span>
|
3411
|
+
</span> <span class='id identifier rubyid_names'>names</span> <span class='op'>=</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_n'>n</span><span class='op'>|</span> <span class='id identifier rubyid_n'>n</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span>
|
3412
3412
|
<span class='id identifier rubyid_names'>names</span> <span class='op'><<</span> <span class='lbracket'>[</span><span class='symbol'>:msie</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='symbol'>:ie</span><span class='rparen'>)</span>
|
3413
3413
|
<span class='id identifier rubyid_names'>names</span> <span class='op'><<</span> <span class='lbracket'>[</span><span class='symbol'>:chromium</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='symbol'>:chrome</span><span class='rparen'>)</span>
|
3414
3414
|
|
@@ -3631,7 +3631,7 @@
|
|
3631
3631
|
|
3632
3632
|
<span class='kw'>def</span> <span class='id identifier rubyid_on'>on</span><span class='lparen'>(</span><span class='id identifier rubyid_platforms'>platforms</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
3633
3633
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_parse_agent'>parse_agent</span><span class='lparen'>(</span><span class='ivar'>@agent</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='ivar'>@platform</span>
|
3634
|
-
<span class='op'>::</span><span class='const'>Brauser</span><span class='op'>::</span><span class='const'>Query</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_platforms'>platforms</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='id identifier rubyid_platforms'>platforms</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@platform</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
3634
|
+
<span class='op'>::</span><span class='const'>Brauser</span><span class='op'>::</span><span class='const'>Query</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_platforms'>platforms</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span> <span class='op'>||</span> <span class='id identifier rubyid_platforms'>platforms</span><span class='period'>.</span><span class='id identifier rubyid_ensure_array'>ensure_array</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='period'>.</span><span class='id identifier rubyid_collect'>collect</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='ivar'>@platform</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
3635
3635
|
<span class='kw'>end</span></pre>
|
3636
3636
|
</td>
|
3637
3637
|
</tr>
|
@@ -4383,7 +4383,7 @@
|
|
4383
4383
|
</div>
|
4384
4384
|
|
4385
4385
|
<div id="footer">
|
4386
|
-
Generated on
|
4386
|
+
Generated on Tue Aug 28 09:55:47 2012 by
|
4387
4387
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
4388
4388
|
0.8.2.1 (ruby-1.9.2).
|
4389
4389
|
</div>
|
data/doc/Brauser/Hooks.html
CHANGED
@@ -116,7 +116,7 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on
|
119
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
121
|
0.8.2.1 (ruby-1.9.2).
|
122
122
|
</div>
|
@@ -323,7 +323,7 @@
|
|
323
323
|
</div>
|
324
324
|
|
325
325
|
<div id="footer">
|
326
|
-
Generated on
|
326
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
327
327
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
328
328
|
0.8.2.1 (ruby-1.9.2).
|
329
329
|
</div>
|
data/doc/Brauser/Query.html
CHANGED
@@ -1306,7 +1306,7 @@
|
|
1306
1306
|
</div>
|
1307
1307
|
|
1308
1308
|
<div id="footer">
|
1309
|
-
Generated on
|
1309
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
1310
1310
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1311
1311
|
0.8.2.1 (ruby-1.9.2).
|
1312
1312
|
</div>
|
data/doc/Brauser/Version.html
CHANGED
@@ -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'>5</span></pre></dd>
|
153
153
|
|
154
154
|
<dt id="STRING-constant" class="">STRING =
|
155
155
|
<div class="docstring">
|
@@ -180,7 +180,7 @@
|
|
180
180
|
</div>
|
181
181
|
|
182
182
|
<div id="footer">
|
183
|
-
Generated on
|
183
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
185
|
0.8.2.1 (ruby-1.9.2).
|
186
186
|
</div>
|
data/doc/_index.html
CHANGED
@@ -168,7 +168,7 @@
|
|
168
168
|
</div>
|
169
169
|
|
170
170
|
<div id="footer">
|
171
|
-
Generated on
|
171
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
172
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
173
173
|
0.8.2.1 (ruby-1.9.2).
|
174
174
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -72,7 +72,177 @@
|
|
72
72
|
|
73
73
|
<h2>Description</h2>
|
74
74
|
|
75
|
-
<p
|
75
|
+
<p>Brauser is a framework agnostic helper that helps you in targeting your applications against most diffused browsers.</p>
|
76
|
+
|
77
|
+
<h3>Installation</h3>
|
78
|
+
|
79
|
+
<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>
|
80
|
+
|
81
|
+
<pre class="code ruby"><code><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>brauser</span><span class='tstring_end'>"</span></span>
|
82
|
+
</code></pre>
|
83
|
+
|
84
|
+
<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>
|
85
|
+
|
86
|
+
<p>If you don't use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:</p>
|
87
|
+
|
88
|
+
<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>
|
89
|
+
</code></pre>
|
90
|
+
|
91
|
+
<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>
|
92
|
+
|
93
|
+
<p>For the rest of this document, let's assume you use Chrome 1.2.3 on Mac OS X.</p>
|
94
|
+
|
95
|
+
<h3>Getting browser information</h3>
|
96
|
+
|
97
|
+
<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>
|
98
|
+
|
99
|
+
<p>The version is returned as a <code>String</code>, and you can use <code>Brauser::Browser.compare_versions</code> to compare against another version.</p>
|
100
|
+
|
101
|
+
<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>register_browser</code>, <code>register_default_browsers</code>, <code>register_platform</code> and <code>register_default_platforms</code>.</p>
|
102
|
+
|
103
|
+
<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>
|
104
|
+
|
105
|
+
<p>For example, if you do this in a ERB view:</p>
|
106
|
+
|
107
|
+
<pre class="code html"><code><body class="<%= browser.classes %>">
|
108
|
+
...
|
109
|
+
</code></pre>
|
110
|
+
|
111
|
+
<p>The view will get compiled to this:</p>
|
112
|
+
|
113
|
+
<pre class="code html"><code><body class="chrome version-1 version-1_2 version-1_2_3 platform-osx">
|
114
|
+
...
|
115
|
+
</code></pre>
|
116
|
+
|
117
|
+
<p>And thus scoping your CSS will be trivial.</p>
|
118
|
+
|
119
|
+
<h3>Querying the browser</h3>
|
120
|
+
|
121
|
+
<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>
|
122
|
+
|
123
|
+
<p>The <code>is</code> method queries about a browser name (or a list of names) and optionally by version and platform:</p>
|
124
|
+
|
125
|
+
<pre class="code ruby"><code><span class='comment'># We talk about the ending ? later.
|
126
|
+
</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>
|
127
|
+
<span class='comment'># => true
|
128
|
+
</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>
|
129
|
+
<span class='comment'># => false
|
130
|
+
</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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
|
131
|
+
<span class='comment'># => true
|
132
|
+
</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'>"</span><span class='tstring_content'>>= 3</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:windows</span><span class='rparen'>)</span>
|
133
|
+
<span class='comment'># => false
|
134
|
+
</span></code></pre>
|
135
|
+
|
136
|
+
<p>The method <code>is</code> is the only which supports direct internal propagation to version and platform.</p>
|
137
|
+
|
138
|
+
<p>The <code>v</code> method queries about the browser version. You can specify the comparison with an hash or a little expression.</p>
|
139
|
+
|
140
|
+
<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>
|
141
|
+
|
142
|
+
<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>
|
143
|
+
|
144
|
+
<p>Examples:</p>
|
145
|
+
|
146
|
+
<pre class="code ruby"><code><span class='comment'># Those two methods are equivalent.
|
147
|
+
</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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:gt</span> <span class='op'>=></span> <span class='int'>1</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
148
|
+
<span class='comment'># => true
|
149
|
+
</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'>"</span><span class='tstring_content'>< 2 && > 1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
150
|
+
<span class='comment'># => true
|
151
|
+
</span></code></pre>
|
152
|
+
|
153
|
+
<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>
|
154
|
+
|
155
|
+
<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>
|
156
|
+
<span class='comment'># => true
|
157
|
+
</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>
|
158
|
+
<span class='comment'># => false
|
159
|
+
</span></code></pre>
|
160
|
+
|
161
|
+
<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>
|
162
|
+
|
163
|
+
<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'>"</span><span class='tstring_content'>en</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
164
|
+
<span class='comment'># => true
|
165
|
+
</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'>"</span><span class='tstring_content'>de</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>es</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
166
|
+
<span class='comment'># => false
|
167
|
+
</span></code></pre>
|
168
|
+
|
169
|
+
<p>Every query method exists in two forms: the concatenation one (the method name doesn't end with a <code>?</code>.</p>
|
170
|
+
|
171
|
+
<p>The former return a <code>Query</code> object, which supports the same query method of the browser and thus enables concatenation.</p>
|
172
|
+
|
173
|
+
<p>The latter return a boolean object, and it's equivalent to calling <code>result</code> on the query after concatenation.</p>
|
174
|
+
|
175
|
+
<p>Ideally, you should use the <code>?</code> version to end the query and fetch the result.</p>
|
176
|
+
|
177
|
+
<pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
|
178
|
+
</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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
|
179
|
+
<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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</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>
|
180
|
+
<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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</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>
|
181
|
+
<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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</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>
|
182
|
+
</code></pre>
|
183
|
+
|
184
|
+
<p>Finally, Brauser support dynamic query operator to write simple queries without using concatenation.</p>
|
185
|
+
|
186
|
+
<p>You construct the method just using operator specified above, separating method name and method arguments with a <code>_</code> and different methods with a <code>__</code>.</p>
|
187
|
+
|
188
|
+
<p>For the version, use the expression form but use symbol operators and replace <code>.</code> with <code>_</code> and <code>&&</code> with <code>and</code>.</p>
|
189
|
+
|
190
|
+
<p>Example:</p>
|
191
|
+
|
192
|
+
<pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
|
193
|
+
</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'>"</span><span class='tstring_content'>< 2 && > 1.2</span><span class='tstring_end'>"</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>
|
194
|
+
<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>
|
195
|
+
|
196
|
+
<span class='comment'># These expressions are equivalent.
|
197
|
+
</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'>"</span><span class='tstring_content'>< 2 && > 1.2</span><span class='tstring_end'>"</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>
|
198
|
+
<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>
|
199
|
+
</code></pre>
|
200
|
+
|
201
|
+
<h3>Adding new browsers</h3>
|
202
|
+
|
203
|
+
<p>To add new browsers, simply call <code>register_browser</code>.</p>
|
204
|
+
|
205
|
+
<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>
|
206
|
+
|
207
|
+
<ul>
|
208
|
+
<li><code>name</code> is the name of the browser. Should be a <code>Symbol</code>.</li>
|
209
|
+
<li><code>name_match</code> is a <code>Regexp</code> to match against the user agent to detect the current browser.</li>
|
210
|
+
<li><code>version_match</code> is a <code>Regexp</code> which last capture group holds the version of the browser.</li>
|
211
|
+
<li><code>label</code> is the human readable name of the browser.</li>
|
212
|
+
</ul>
|
213
|
+
|
214
|
+
<p>For example, for Google Chrome the call should be:</p>
|
215
|
+
|
216
|
+
<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'>"</span><span class='tstring_content'>Google Chrome</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
217
|
+
</code></pre>
|
218
|
+
|
219
|
+
<h3>Adding new platforms</h3>
|
220
|
+
|
221
|
+
<p>To add new platforms, simply call <code>register_platform</code>.</p>
|
222
|
+
|
223
|
+
<p>This method accepts a single entry or an array of entries in the following format: <code>[name, matcher, label]</code>:</p>
|
224
|
+
|
225
|
+
<ul>
|
226
|
+
<li><code>name</code> is the name of the platform. Should be a <code>Symbol</code>.</li>
|
227
|
+
<li><code>matcher</code> is a <code>Regexp</code> to match against the user agent to detect the current platform.</li>
|
228
|
+
<li><code>label</code> is the human readable name of the platform.</li>
|
229
|
+
</ul>
|
230
|
+
|
231
|
+
<p>For example, for Mac OS X the call should be:</p>
|
232
|
+
|
233
|
+
<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'>"</span><span class='tstring_content'>Apple MacOS X</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
234
|
+
</code></pre>
|
235
|
+
|
236
|
+
<h3>Adding new languages</h3>
|
237
|
+
|
238
|
+
<p>To add new languages, simply call <code>register_language</code>.</p>
|
239
|
+
|
240
|
+
<p>This method accepts a single pair of code and label or an hash where keys are language code and values are labels.</p>
|
241
|
+
|
242
|
+
<p>For example, for Italian the call should be:</p>
|
243
|
+
|
244
|
+
<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'>"</span><span class='tstring_content'>it</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Italian</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
245
|
+
</code></pre>
|
76
246
|
|
77
247
|
<h2>Contributing to brauser</h2>
|
78
248
|
|
@@ -93,7 +263,7 @@ Licensed under the MIT license, which can be found at <a href="http://www.openso
|
|
93
263
|
</div></div>
|
94
264
|
|
95
265
|
<div id="footer">
|
96
|
-
Generated on
|
266
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
97
267
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
98
268
|
0.8.2.1 (ruby-1.9.2).
|
99
269
|
</div>
|
data/doc/index.html
CHANGED
@@ -72,7 +72,177 @@
|
|
72
72
|
|
73
73
|
<h2>Description</h2>
|
74
74
|
|
75
|
-
<p
|
75
|
+
<p>Brauser is a framework agnostic helper that helps you in targeting your applications against most diffused browsers.</p>
|
76
|
+
|
77
|
+
<h3>Installation</h3>
|
78
|
+
|
79
|
+
<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>
|
80
|
+
|
81
|
+
<pre class="code ruby"><code><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>brauser</span><span class='tstring_end'>"</span></span>
|
82
|
+
</code></pre>
|
83
|
+
|
84
|
+
<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>
|
85
|
+
|
86
|
+
<p>If you don't use Rails, you can instantiate a new browser by including the gem in your code and by doing something like this:</p>
|
87
|
+
|
88
|
+
<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>
|
89
|
+
</code></pre>
|
90
|
+
|
91
|
+
<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>
|
92
|
+
|
93
|
+
<p>For the rest of this document, let's assume you use Chrome 1.2.3 on Mac OS X.</p>
|
94
|
+
|
95
|
+
<h3>Getting browser information</h3>
|
96
|
+
|
97
|
+
<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>
|
98
|
+
|
99
|
+
<p>The version is returned as a <code>String</code>, and you can use <code>Brauser::Browser.compare_versions</code> to compare against another version.</p>
|
100
|
+
|
101
|
+
<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>register_browser</code>, <code>register_default_browsers</code>, <code>register_platform</code> and <code>register_default_platforms</code>.</p>
|
102
|
+
|
103
|
+
<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>
|
104
|
+
|
105
|
+
<p>For example, if you do this in a ERB view:</p>
|
106
|
+
|
107
|
+
<pre class="code html"><code><body class="<%= browser.classes %>">
|
108
|
+
...
|
109
|
+
</code></pre>
|
110
|
+
|
111
|
+
<p>The view will get compiled to this:</p>
|
112
|
+
|
113
|
+
<pre class="code html"><code><body class="chrome version-1 version-1_2 version-1_2_3 platform-osx">
|
114
|
+
...
|
115
|
+
</code></pre>
|
116
|
+
|
117
|
+
<p>And thus scoping your CSS will be trivial.</p>
|
118
|
+
|
119
|
+
<h3>Querying the browser</h3>
|
120
|
+
|
121
|
+
<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>
|
122
|
+
|
123
|
+
<p>The <code>is</code> method queries about a browser name (or a list of names) and optionally by version and platform:</p>
|
124
|
+
|
125
|
+
<pre class="code ruby"><code><span class='comment'># We talk about the ending ? later.
|
126
|
+
</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>
|
127
|
+
<span class='comment'># => true
|
128
|
+
</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>
|
129
|
+
<span class='comment'># => false
|
130
|
+
</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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
|
131
|
+
<span class='comment'># => true
|
132
|
+
</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'>"</span><span class='tstring_content'>>= 3</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:windows</span><span class='rparen'>)</span>
|
133
|
+
<span class='comment'># => false
|
134
|
+
</span></code></pre>
|
135
|
+
|
136
|
+
<p>The method <code>is</code> is the only which supports direct internal propagation to version and platform.</p>
|
137
|
+
|
138
|
+
<p>The <code>v</code> method queries about the browser version. You can specify the comparison with an hash or a little expression.</p>
|
139
|
+
|
140
|
+
<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>
|
141
|
+
|
142
|
+
<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>
|
143
|
+
|
144
|
+
<p>Examples:</p>
|
145
|
+
|
146
|
+
<pre class="code ruby"><code><span class='comment'># Those two methods are equivalent.
|
147
|
+
</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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='symbol'>:gt</span> <span class='op'>=></span> <span class='int'>1</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
148
|
+
<span class='comment'># => true
|
149
|
+
</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'>"</span><span class='tstring_content'>< 2 && > 1</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
150
|
+
<span class='comment'># => true
|
151
|
+
</span></code></pre>
|
152
|
+
|
153
|
+
<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>
|
154
|
+
|
155
|
+
<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>
|
156
|
+
<span class='comment'># => true
|
157
|
+
</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>
|
158
|
+
<span class='comment'># => false
|
159
|
+
</span></code></pre>
|
160
|
+
|
161
|
+
<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>
|
162
|
+
|
163
|
+
<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'>"</span><span class='tstring_content'>en</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
164
|
+
<span class='comment'># => true
|
165
|
+
</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'>"</span><span class='tstring_content'>de</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>es</span><span class='tstring_end'>"</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
166
|
+
<span class='comment'># => false
|
167
|
+
</span></code></pre>
|
168
|
+
|
169
|
+
<p>Every query method exists in two forms: the concatenation one (the method name doesn't end with a <code>?</code>.</p>
|
170
|
+
|
171
|
+
<p>The former return a <code>Query</code> object, which supports the same query method of the browser and thus enables concatenation.</p>
|
172
|
+
|
173
|
+
<p>The latter return a boolean object, and it's equivalent to calling <code>result</code> on the query after concatenation.</p>
|
174
|
+
|
175
|
+
<p>Ideally, you should use the <code>?</code> version to end the query and fetch the result.</p>
|
176
|
+
|
177
|
+
<pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
|
178
|
+
</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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</span></span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:osx</span><span class='rparen'>)</span>
|
179
|
+
<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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</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>
|
180
|
+
<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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</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>
|
181
|
+
<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'>=></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>2</span><span class='tstring_end'>"</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>
|
182
|
+
</code></pre>
|
183
|
+
|
184
|
+
<p>Finally, Brauser support dynamic query operator to write simple queries without using concatenation.</p>
|
185
|
+
|
186
|
+
<p>You construct the method just using operator specified above, separating method name and method arguments with a <code>_</code> and different methods with a <code>__</code>.</p>
|
187
|
+
|
188
|
+
<p>For the version, use the expression form but use symbol operators and replace <code>.</code> with <code>_</code> and <code>&&</code> with <code>and</code>.</p>
|
189
|
+
|
190
|
+
<p>Example:</p>
|
191
|
+
|
192
|
+
<pre class="code ruby"><code><span class='comment'># These expressions are equivalent.
|
193
|
+
</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'>"</span><span class='tstring_content'>< 2 && > 1.2</span><span class='tstring_end'>"</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>
|
194
|
+
<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>
|
195
|
+
|
196
|
+
<span class='comment'># These expressions are equivalent.
|
197
|
+
</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'>"</span><span class='tstring_content'>< 2 && > 1.2</span><span class='tstring_end'>"</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>
|
198
|
+
<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>
|
199
|
+
</code></pre>
|
200
|
+
|
201
|
+
<h3>Adding new browsers</h3>
|
202
|
+
|
203
|
+
<p>To add new browsers, simply call <code>register_browser</code>.</p>
|
204
|
+
|
205
|
+
<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>
|
206
|
+
|
207
|
+
<ul>
|
208
|
+
<li><code>name</code> is the name of the browser. Should be a <code>Symbol</code>.</li>
|
209
|
+
<li><code>name_match</code> is a <code>Regexp</code> to match against the user agent to detect the current browser.</li>
|
210
|
+
<li><code>version_match</code> is a <code>Regexp</code> which last capture group holds the version of the browser.</li>
|
211
|
+
<li><code>label</code> is the human readable name of the browser.</li>
|
212
|
+
</ul>
|
213
|
+
|
214
|
+
<p>For example, for Google Chrome the call should be:</p>
|
215
|
+
|
216
|
+
<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'>"</span><span class='tstring_content'>Google Chrome</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
217
|
+
</code></pre>
|
218
|
+
|
219
|
+
<h3>Adding new platforms</h3>
|
220
|
+
|
221
|
+
<p>To add new platforms, simply call <code>register_platform</code>.</p>
|
222
|
+
|
223
|
+
<p>This method accepts a single entry or an array of entries in the following format: <code>[name, matcher, label]</code>:</p>
|
224
|
+
|
225
|
+
<ul>
|
226
|
+
<li><code>name</code> is the name of the platform. Should be a <code>Symbol</code>.</li>
|
227
|
+
<li><code>matcher</code> is a <code>Regexp</code> to match against the user agent to detect the current platform.</li>
|
228
|
+
<li><code>label</code> is the human readable name of the platform.</li>
|
229
|
+
</ul>
|
230
|
+
|
231
|
+
<p>For example, for Mac OS X the call should be:</p>
|
232
|
+
|
233
|
+
<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'>"</span><span class='tstring_content'>Apple MacOS X</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
234
|
+
</code></pre>
|
235
|
+
|
236
|
+
<h3>Adding new languages</h3>
|
237
|
+
|
238
|
+
<p>To add new languages, simply call <code>register_language</code>.</p>
|
239
|
+
|
240
|
+
<p>This method accepts a single pair of code and label or an hash where keys are language code and values are labels.</p>
|
241
|
+
|
242
|
+
<p>For example, for Italian the call should be:</p>
|
243
|
+
|
244
|
+
<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'>"</span><span class='tstring_content'>it</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Italian</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
245
|
+
</code></pre>
|
76
246
|
|
77
247
|
<h2>Contributing to brauser</h2>
|
78
248
|
|
@@ -93,7 +263,7 @@ Licensed under the MIT license, which can be found at <a href="http://www.openso
|
|
93
263
|
</div></div>
|
94
264
|
|
95
265
|
<div id="footer">
|
96
|
-
Generated on
|
266
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
97
267
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
98
268
|
0.8.2.1 (ruby-1.9.2).
|
99
269
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Tue Aug 28 09:55:46 2012 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.2.1 (ruby-1.9.2).
|
109
109
|
</div>
|
data/lib/brauser/browser.rb
CHANGED
@@ -555,7 +555,7 @@ module Brauser
|
|
555
555
|
platforms = platforms.ensure_array
|
556
556
|
|
557
557
|
# Adjust names
|
558
|
-
names = names.ensure_array
|
558
|
+
names = names.ensure_array.uniq.compact.collect {|n| n.ensure_string.to_sym }
|
559
559
|
names << [:msie] if names.include?(:ie)
|
560
560
|
names << [:chromium] if names.include?(:chrome)
|
561
561
|
|
@@ -647,7 +647,7 @@ module Brauser
|
|
647
647
|
# @return [Query] A query which can evaluated for concatenation or result.
|
648
648
|
def on(platforms = [])
|
649
649
|
self.parse_agent(@agent) if !@platform
|
650
|
-
::Brauser::Query.new(self, platforms.blank? || platforms.ensure_array.collect {|p| p.ensure_string.to_sym }.include?(@platform))
|
650
|
+
::Brauser::Query.new(self, platforms.blank? || platforms.ensure_array.uniq.compact.collect {|p| p.ensure_string.to_sym }.include?(@platform))
|
651
651
|
end
|
652
652
|
|
653
653
|
# Check if the browser is on a specific platform.
|
@@ -664,7 +664,7 @@ module Brauser
|
|
664
664
|
# @return [Query] A query which can evaluated for concatenation or result.
|
665
665
|
def accepts(langs = [])
|
666
666
|
self.parse_accept_language(@accept_language) if !@languages
|
667
|
-
::Brauser::Query.new(self, (@languages & langs.ensure_array).present?)
|
667
|
+
::Brauser::Query.new(self, (@languages & langs.ensure_array.uniq.compact.collect {|l| l.to_s }).present?)
|
668
668
|
end
|
669
669
|
|
670
670
|
# Check if the browser accepts the specified languages.
|
data/lib/brauser/version.rb
CHANGED
metadata
CHANGED
@@ -1,157 +1,151 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: brauser
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Shogun
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-08-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: lazier
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
22
17
|
none: false
|
23
|
-
requirements:
|
18
|
+
requirements:
|
24
19
|
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 0
|
30
|
-
version: "1.0"
|
31
|
-
prerelease: false
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
32
22
|
type: :runtime
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
37
33
|
none: false
|
38
|
-
requirements:
|
34
|
+
requirements:
|
39
35
|
- - ~>
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
hash: 35
|
42
|
-
segments:
|
43
|
-
- 2
|
44
|
-
- 11
|
45
|
-
- 0
|
36
|
+
- !ruby/object:Gem::Version
|
46
37
|
version: 2.11.0
|
47
|
-
prerelease: false
|
48
38
|
type: :development
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.11.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
53
49
|
none: false
|
54
|
-
requirements:
|
50
|
+
requirements:
|
55
51
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
hash: 59
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
- 9
|
61
|
-
- 0
|
52
|
+
- !ruby/object:Gem::Version
|
62
53
|
version: 0.9.0
|
63
|
-
prerelease: false
|
64
54
|
type: :development
|
65
|
-
|
66
|
-
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
57
|
none: false
|
70
|
-
requirements:
|
58
|
+
requirements:
|
71
59
|
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: simplecov
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
78
69
|
version: 0.6.0
|
79
|
-
prerelease: false
|
80
70
|
type: :development
|
81
|
-
name: simplecov
|
82
|
-
requirement: *id004
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
hash: 3
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
93
71
|
prerelease: false
|
94
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.6.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
95
79
|
name: pry
|
96
|
-
requirement:
|
97
|
-
|
98
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
89
|
none: false
|
100
|
-
requirements:
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: yard
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
101
99
|
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
hash: 63
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
- 8
|
107
|
-
- 0
|
100
|
+
- !ruby/object:Gem::Version
|
108
101
|
version: 0.8.0
|
109
|
-
prerelease: false
|
110
102
|
type: :development
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.8.0
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: redcarpet
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
115
113
|
none: false
|
116
|
-
requirements:
|
114
|
+
requirements:
|
117
115
|
- - ~>
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
hash: 11
|
120
|
-
segments:
|
121
|
-
- 2
|
122
|
-
- 1
|
123
|
-
- 0
|
116
|
+
- !ruby/object:Gem::Version
|
124
117
|
version: 2.1.0
|
125
|
-
prerelease: false
|
126
118
|
type: :development
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 2.1.0
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: github-markup
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
131
129
|
none: false
|
132
|
-
requirements:
|
130
|
+
requirements:
|
133
131
|
- - ~>
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
hash: 3
|
136
|
-
segments:
|
137
|
-
- 0
|
138
|
-
- 7
|
139
|
-
- 0
|
132
|
+
- !ruby/object:Gem::Version
|
140
133
|
version: 0.7.0
|
141
|
-
prerelease: false
|
142
134
|
type: :development
|
143
|
-
|
144
|
-
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.7.0
|
145
142
|
description: A framework agnostic browser detection and querying helper.
|
146
|
-
email:
|
143
|
+
email:
|
147
144
|
- shogun_panda@me.com
|
148
145
|
executables: []
|
149
|
-
|
150
146
|
extensions: []
|
151
|
-
|
152
147
|
extra_rdoc_files: []
|
153
|
-
|
154
|
-
files:
|
148
|
+
files:
|
155
149
|
- .gitignore
|
156
150
|
- .travis.yml
|
157
151
|
- .yardopts
|
@@ -193,38 +187,35 @@ files:
|
|
193
187
|
- spec/spec_helper.rb
|
194
188
|
homepage: http://github.com/ShogunPanda/brauser
|
195
189
|
licenses: []
|
196
|
-
|
197
190
|
post_install_message:
|
198
191
|
rdoc_options: []
|
199
|
-
|
200
|
-
require_paths:
|
192
|
+
require_paths:
|
201
193
|
- lib
|
202
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
203
195
|
none: false
|
204
|
-
requirements:
|
205
|
-
- -
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
|
208
|
-
segments:
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
segments:
|
209
201
|
- 0
|
210
|
-
|
211
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
|
+
hash: 4366897324243754710
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
204
|
none: false
|
213
|
-
requirements:
|
214
|
-
- -
|
215
|
-
- !ruby/object:Gem::Version
|
216
|
-
|
217
|
-
segments:
|
205
|
+
requirements:
|
206
|
+
- - ! '>='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
segments:
|
218
210
|
- 0
|
219
|
-
|
211
|
+
hash: 4366897324243754710
|
220
212
|
requirements: []
|
221
|
-
|
222
213
|
rubyforge_project: brauser
|
223
214
|
rubygems_version: 1.8.24
|
224
215
|
signing_key:
|
225
216
|
specification_version: 3
|
226
217
|
summary: A framework agnostic browser detection and querying helper.
|
227
|
-
test_files:
|
218
|
+
test_files:
|
228
219
|
- spec/brauser/browser_spec.rb
|
229
220
|
- spec/brauser/hooks_spec.rb
|
230
221
|
- spec/brauser/query_spec.rb
|