spob_browser_detector 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 C. Jason Harrelson (midas)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,106 @@
1
+ = browser_detector
2
+
3
+ http://github.com/midas/browser_detector
4
+
5
+
6
+ == DESCRIPTION
7
+
8
+ Determines the name and version of the browser currently making a request.
9
+
10
+ The browser detector uses the HTTP user agent string to determine which browser is making the current request. The detector
11
+ can determine the name, version, major version, minor version, build version and revision version of the current browser.
12
+
13
+ If using Rails, there are several view helpers available that use the BrowserDetector: g_browser_name(), g_browser_version(),
14
+ g_browser_full_name() and g_browser_is?().
15
+
16
+
17
+ == FEATURES
18
+
19
+ * Detector class that can determine the browser name and version given a user agent string.
20
+ * List of known user agents.
21
+ * List of example user agent strings for each known user agent.
22
+
23
+
24
+ == INSTALL
25
+
26
+ gem sources -a http://gemcutter.org
27
+ sudo gem install
28
+
29
+
30
+ == INSTALL FOR RAILS
31
+
32
+ Add to environment file:
33
+
34
+ config.gem "browser_detector", :version => '1.0.0', :source => 'http://gemcutter.org'
35
+
36
+
37
+ == USAGE
38
+
39
+ The following examples will assume Firefox 3.5.3 on OS/X is being used. The user agent string for Firefox 3.5.3 on OS/X is:
40
+
41
+ Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
42
+
43
+ === Detector Class
44
+
45
+ @detector = BrowserDetector::Detector.new( request.env['HTTP_USER_AGENT'] )
46
+ puts @detector.browser_name # firefox
47
+ puts @detector.browser_version # 3.5.3
48
+ puts @detector.full_name # Firefox 3.5.3
49
+ puts @detector.browser_is? :name => :firefox, :version => '3.5.3' # true
50
+ puts @detector.browser_is? :name => :firefox, :major_version => 3, :minor_version => '5', build_version => '3' # true
51
+
52
+ === Within Rails Views
53
+
54
+ g_browser_name
55
+
56
+ <% if g_browser_name == 'firefox' %>
57
+ ...
58
+
59
+ g_browser_version
60
+
61
+ <% if g_browser_version == '3.5.3' %>
62
+ ...
63
+
64
+ g_browser_full_name
65
+
66
+ <%= g_browser_full_name # Outputs: Firefox 3.5.3 %>
67
+
68
+ g_browser_is?
69
+
70
+ <% if g_browser_is?( :name => 'firefox', :version => '3.5.3' ) %>
71
+ ...
72
+
73
+ <% if g_browser_is?( :name => 'firefox', :major_version => '3' ) %>
74
+ ...
75
+
76
+ <% if g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3 ) %>
77
+ ...
78
+
79
+ <% if g_browser_is?( :name => :firefox, :major_version => 3, :minor_version => 5, :build_version => 3, :revision_version => 0 ) %>
80
+ ...
81
+
82
+
83
+ == LICENSE
84
+
85
+ (The MIT License)
86
+
87
+ Copyright (c) 2009 C. Jason Harrelson (midas)
88
+
89
+ Permission is hereby granted, free of charge, to any person obtaining
90
+ a copy of this software and associated documentation files (the
91
+ 'Software'), to deal in the Software without restriction, including
92
+ without limitation the rights to use, copy, modify, merge, publish,
93
+ distribute, sublicense, and/or sell copies of the Software, and to
94
+ permit persons to whom the Software is furnished to do so, subject to
95
+ the following conditions:
96
+
97
+ The above copyright notice and this permission notice shall be
98
+ included in all copies or substantial portions of the Software.
99
+
100
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
101
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
102
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
103
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
104
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
105
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
106
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.