quartermaster 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ === 1.0.2 / 2008-05-08
2
+
3
+ * 1 major enhancement
4
+ * Muffed handling of request's that have *no* user agent (request.user_agent is nil). Fixed!
5
+
6
+ === 1.0.1 / 2008-05-08
7
+
8
+ * 1 major enhancement
9
+ * Muffed handling of unknown browsers. Fixed!
10
+
1
11
  === 1.0.0 / 2008-05-06
2
12
 
3
13
  * 1 major enhancement
data/lib/quartermaster.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Quartermaster
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
 
4
4
  module Helper
5
5
  # Uses the output of +browser_from_user_agent+ to figure out what stylesheets to look for and then uses +stylesheet_link_tag+
@@ -24,7 +24,7 @@ module Quartermaster
24
24
 
25
25
  # Returns an array containing the base browser name and a version-specific name (except for Konqueror) for the given +user_agent+ which defaults to Rails' +request.user_agent+
26
26
  def browser_from_user_agent( user_agent = request.user_agent )
27
- @browser_from_user_agent ||= case user_agent.downcase
27
+ @browser_from_user_agent ||= case user_agent.to_s.downcase
28
28
  when /opera[ \/](\d)/ then "opera opera#{$1}" # Have to check for opera before msie
29
29
  when /msie (\d)/ then "ie ie#{$1}" # F U ie5.5 - todo: Support minor versions
30
30
  when /firefox\/(\d)/ then "firefox firefox#{$1}"
@@ -32,15 +32,17 @@ module Quartermaster
32
32
  when /rv:([^)]+)\) gecko/ then "gecko gecko#{$1}"
33
33
  when /applewebkit\/(\d)/ then "webkit webkit#{$1}"
34
34
  when /konqueror/ then 'konqueror'
35
- end.to_s.split(' ')
35
+ else ''
36
+ end.split(' ')
36
37
  end
37
38
 
38
39
  # Returns a short version of the OS name for the given +user_agent+ which defaults to Rails' +request.user_agent+
39
40
  def os_from_user_agent( user_agent = request.user_agent )
40
- @os_from_user_agent ||= case user_agent.downcase
41
+ @os_from_user_agent ||= case user_agent.to_s.downcase
41
42
  when /win/ then 'win'
42
43
  when /mac/ then 'mac'
43
44
  when /(linux|x11)/ then 'linux'
45
+ else ''
44
46
  end
45
47
  end
46
48
  end
@@ -165,6 +165,33 @@ describe 'Quartermaster' do
165
165
  @qm.stub!(:request).and_return(@request)
166
166
  end
167
167
 
168
+ it "should return an empty string for os" do
169
+ @qm.os_from_user_agent.should == ''
170
+ end
171
+
172
+ it "should return an empty array for browser" do
173
+ @qm.browser_from_user_agent.should == []
174
+ end
175
+
176
+ it "should return an empty string for the CSS classes" do
177
+ @qm.user_agent_for_css.should == ''
178
+ end
179
+ end
180
+
181
+ describe "when request has no user agent" do
182
+ before(:each) do
183
+ @request = mock('Request', :user_agent => nil)
184
+ @qm.stub!(:request).and_return(@request)
185
+ end
186
+
187
+ it "should return an empty string for os" do
188
+ @qm.os_from_user_agent.should == ''
189
+ end
190
+
191
+ it "should return an empty array for browser" do
192
+ @qm.browser_from_user_agent.should == []
193
+ end
194
+
168
195
  it "should return an empty string for the CSS classes" do
169
196
  @qm.user_agent_for_css.should == ''
170
197
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quartermaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Myron
metadata.gz.sig CHANGED
Binary file