double_agent 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == Release 0.1.2 (June 30, 2011)
2
+
3
+ * Bugfix to #browser_sum and #os_sym returning nil on an empty or nil user agent. Should return :unkown.
4
+
1
5
  == Release 0.1.1 (May 10, 2011)
2
6
 
3
7
  * #log_entries takes :match and :ignore regexp options
data/data/browsers.yml CHANGED
@@ -61,5 +61,5 @@
61
61
 
62
62
  - :name: Unknown
63
63
  :sym: :unknown
64
- :regex: .+
65
- :version: .+
64
+ :regex: .*
65
+ :version: .*
data/data/oses.yml CHANGED
@@ -69,4 +69,4 @@
69
69
 
70
70
  - :name: Unknown
71
71
  :sym: :unknown
72
- :regex: .+
72
+ :regex: .*
@@ -161,7 +161,7 @@ module DoubleAgent
161
161
  # Parses and evals BROWSER_DATA into a case statement inside of the browser_sym method.
162
162
  def self.load_browsers!
163
163
  BROWSERS.clear
164
- str = "case user_agent\n"
164
+ str = "case user_agent.to_s\n"
165
165
  BROWSER_DATA.each do |data|
166
166
  BROWSERS[data[:sym]] = BrowserParser.new(data)
167
167
  str << " when %r{#{data[:regex]}}i then :#{data[:sym]}\n"
@@ -174,7 +174,7 @@ module DoubleAgent
174
174
  # Parses and evals OS_DATA into a case statement inside of the os_sym method.
175
175
  def self.load_oses!
176
176
  OSES.clear
177
- str = "case user_agent\n"
177
+ str = "case user_agent.to_s\n"
178
178
  OS_DATA.each do |data|
179
179
  OSES[data[:sym]] = OSParser.new(data)
180
180
  str << " when %r{#{data[:regex]}}i then :#{data[:sym]}\n"
data/spec/core_spec.rb CHANGED
@@ -21,6 +21,12 @@ describe DoubleAgent do
21
21
  it 'returns :unknown for browser_sym' do
22
22
  DoubleAgent.browser_sym('froofroo').should == :unknown
23
23
  end
24
+ it 'returns :unknown for an empty browser_sym' do
25
+ DoubleAgent.browser_sym('').should == :unknown
26
+ end
27
+ it 'returns :unknown for a nil browser_sym' do
28
+ DoubleAgent.browser_sym(nil).should == :unknown
29
+ end
24
30
 
25
31
  #browser_family
26
32
  it 'returns Firefox for browser family' do
@@ -31,16 +37,34 @@ describe DoubleAgent do
31
37
  it 'returns :firefox for browser_family_sym' do
32
38
  DoubleAgent.browser_family_sym(@ua_string).should == :firefox
33
39
  end
40
+ it 'returns :unknown for an empty browser_family_sym' do
41
+ DoubleAgent.browser_family_sym('').should == :unknown
42
+ end
43
+ it 'returns :unknown for a nil browser_family_sym' do
44
+ DoubleAgent.browser_family_sym(nil).should == :unknown
45
+ end
34
46
 
35
47
  #browser_icon
36
48
  it 'returns :firefox for browser_sym' do
37
49
  DoubleAgent.browser_icon(@ua_string).should == :firefox
38
50
  end
51
+ it 'returns :unkown for an empty browser_sym' do
52
+ DoubleAgent.browser_icon('').should == :unknown
53
+ end
54
+ it 'returns :unkown for a nil browser_sym' do
55
+ DoubleAgent.browser_icon(nil).should == :unknown
56
+ end
39
57
 
40
58
  #browser_family_icon
41
59
  it 'returns :firefox for browser_family_sym' do
42
60
  DoubleAgent.browser_family_icon(@ua_string).should == :firefox
43
61
  end
62
+ it 'returns :unkown for an empty browser_family_sym' do
63
+ DoubleAgent.browser_family_icon('').should == :unknown
64
+ end
65
+ it 'returns :unkown for a nil browser_family_sym' do
66
+ DoubleAgent.browser_family_icon(nil).should == :unknown
67
+ end
44
68
 
45
69
  #os
46
70
  it 'returns Ubuntua for OS' do
@@ -49,6 +73,9 @@ describe DoubleAgent do
49
73
  it 'returns Unknowna for OS' do
50
74
  DoubleAgent.os('froofroo').should == 'Unknown'
51
75
  end
76
+ it 'returns Unknowna for OS' do
77
+ DoubleAgent.os('').should == 'Unknown'
78
+ end
52
79
 
53
80
  #os_sym
54
81
  it 'returns :ubuntu for os_sym' do
@@ -57,6 +84,12 @@ describe DoubleAgent do
57
84
  it 'returns :unknown for os_sym' do
58
85
  DoubleAgent.os_sym('froofroo').should == :unknown
59
86
  end
87
+ it 'returns :unknown for an empty os_sym' do
88
+ DoubleAgent.os_sym('').should == :unknown
89
+ end
90
+ it 'returns :unknown for a nil os_sym' do
91
+ DoubleAgent.os_sym(nil).should == :unknown
92
+ end
60
93
 
61
94
  #os_family
62
95
  it 'returns GNU/Linux OS family' do
metadata CHANGED
@@ -1,8 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_agent
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 2
9
+ version: 0.1.2
6
10
  platform: ruby
7
11
  authors:
8
12
  - Jordan Hollinger
@@ -10,7 +14,8 @@ autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
16
 
13
- date: 2011-05-10 00:00:00 Z
17
+ date: 2011-06-30 00:00:00 -04:00
18
+ default_executable:
14
19
  dependencies: []
15
20
 
16
21
  description: Browser User Agent string parser with resource, stats, and a log reader
@@ -23,24 +28,25 @@ extra_rdoc_files:
23
28
  - README.rdoc
24
29
  - CHANGELOG
25
30
  files:
31
+ - lib/double_agent.rb
26
32
  - lib/double_agent/all.rb
33
+ - lib/double_agent/logs.rb
27
34
  - lib/double_agent/core.rb
28
35
  - lib/double_agent/resources.rb
29
- - lib/double_agent/logs.rb
30
36
  - lib/double_agent/stats.rb
31
- - lib/double_agent.rb
32
- - data/oses.yml
33
37
  - data/browsers.yml
34
- - spec/resources_spec.rb
35
- - spec/core_spec.rb
38
+ - data/oses.yml
36
39
  - spec/spec_helper.rb
37
- - spec/parser_spec.rb
38
- - spec/data/httpd.access.log
40
+ - spec/core_spec.rb
39
41
  - spec/data/httpd.access.log.1.gz
42
+ - spec/data/httpd.access.log
40
43
  - spec/stats_spec.rb
44
+ - spec/resources_spec.rb
45
+ - spec/parser_spec.rb
41
46
  - README.rdoc
42
47
  - LICENSE
43
48
  - CHANGELOG
49
+ has_rdoc: true
44
50
  homepage: http://github.com/jhollinger/double_agent
45
51
  licenses: []
46
52
 
@@ -54,17 +60,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
60
  requirements:
55
61
  - - ">="
56
62
  - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
57
65
  version: "0"
58
66
  required_rubygems_version: !ruby/object:Gem::Requirement
59
67
  none: false
60
68
  requirements:
61
69
  - - ">="
62
70
  - !ruby/object:Gem::Version
71
+ segments:
72
+ - 0
63
73
  version: "0"
64
74
  requirements: []
65
75
 
66
76
  rubyforge_project:
67
- rubygems_version: 1.7.2
77
+ rubygems_version: 1.3.7
68
78
  signing_key:
69
79
  specification_version: 3
70
80
  summary: Browser User Agent string parser