which_browser 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +35 -4
- data/lib/which_browser.rb +1 -0
- data/lib/which_browser/version.rb +1 -1
- data/test/dummy/app.rb +21 -13
- data/which_browser.gemspec +2 -0
- metadata +12 -1
data/README.md
CHANGED
@@ -1,22 +1,53 @@
|
|
1
1
|
Which Browser
|
2
|
-
|
2
|
+
=============
|
3
3
|
|
4
|
-
Which Browser adds a few helper methods to a rack request so you can write cleaner logic
|
4
|
+
Which Browser adds a few helper methods to a rack request so you can write cleaner browser-related logic.
|
5
5
|
|
6
6
|
For example, the age old battle against IE 5 & 6 can be handled like so:
|
7
7
|
|
8
|
-
stylesheet_link_tag "ie" if request.
|
8
|
+
stylesheet_link_tag "ie" if request.ie_lt7?
|
9
|
+
|
10
|
+
And for a nice browser warning:
|
11
|
+
|
12
|
+
- if request.ie6?
|
13
|
+
IE6 makes the internet suck.
|
14
|
+
- elsif request.ie5?
|
15
|
+
You've got to be kidding me.
|
16
|
+
|
17
|
+
|
18
|
+
Or in your rails controller, decide which layout:
|
19
|
+
|
20
|
+
render :layout => request.mobile_safari? ? 'mobile' : 'application'
|
21
|
+
|
9
22
|
|
10
23
|
|
11
24
|
Here's some other popular helpers:
|
12
25
|
|
13
26
|
request.ie?
|
14
27
|
request.ie6?
|
28
|
+
request.ie_lt6?
|
29
|
+
request.ie_gte7?
|
30
|
+
|
15
31
|
request.ipad?
|
16
32
|
request.ipod?
|
17
33
|
request.iphone?
|
18
34
|
request.mobile_safari?
|
19
|
-
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
Testing
|
39
|
+
-------
|
40
|
+
|
41
|
+
Shouda tests can be run with:
|
42
|
+
|
43
|
+
git clone git://github.com/citrus/which_browser.git
|
44
|
+
rake
|
45
|
+
|
46
|
+
There is also a ramaze app in test/dummy for a demo, development and real-life testing. Install ramaze (`gem install ramaze`) if you don't have it, then run:
|
47
|
+
|
48
|
+
ruby test/dummy/app.rb
|
49
|
+
|
50
|
+
Now open your browser to [http://localhost:7000](http://localhost:7000)
|
20
51
|
|
21
52
|
|
22
53
|
License
|
data/lib/which_browser.rb
CHANGED
data/test/dummy/app.rb
CHANGED
@@ -5,20 +5,28 @@ require File.expand_path("../../../lib/which_browser", __FILE__)
|
|
5
5
|
|
6
6
|
class MainController < Ramaze::Controller
|
7
7
|
def index
|
8
|
-
{
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
# add other methods you'd like to see to the list:
|
10
|
+
[
|
11
|
+
:user_agent,
|
12
|
+
:ie?,
|
13
|
+
:ie6?,
|
14
|
+
:ie_lt6?,
|
15
|
+
:ie_lte7?,
|
16
|
+
:ie_gte6?,
|
17
|
+
:safari?,
|
18
|
+
:safari_version,
|
19
|
+
:ff?,
|
20
|
+
:ff_version,
|
21
|
+
:opera?,
|
22
|
+
:chrome?,
|
23
|
+
:chrome?,
|
24
|
+
:pc?,
|
25
|
+
:mac?,
|
26
|
+
:linux?
|
27
|
+
].collect{ |method|
|
28
|
+
v = request.send(method)
|
29
|
+
%(#{method} <span style="color: #{v == false ? 'red' : 'green' }; font-weight: #{v == false ? 'normal' : 'bold'}">#{v}</span>)
|
22
30
|
}.join("<br/>")
|
23
31
|
end
|
24
32
|
end
|
data/which_browser.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: which_browser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spencer Steffen
|
@@ -35,6 +35,17 @@ dependencies:
|
|
35
35
|
version: 2.11.3
|
36
36
|
type: :development
|
37
37
|
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: ramaze
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2011.01.30
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
38
49
|
description: Which Browser adds a few helper methods to a rack request.
|
39
50
|
email:
|
40
51
|
- spencer@citrusme.com
|