aua 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,6 +1,12 @@
1
1
  ### dev
2
2
 
3
- [full changelog](http://github.com/yolk/aua/compare/v0.1.1...master)
3
+ [full changelog](http://github.com/yolk/aua/compare/v0.1.2...master)
4
+
5
+ ### 0.1.2 / 2011-01-28
6
+
7
+ [full changelog](http://github.com/yolk/aua/compare/v0.1.1...v0.1.2)
8
+
9
+ * Added support for unknown simple user agent string (e.g. my_app/1.0)
4
10
 
5
11
  ### 0.1.1 / 2011-01-28
6
12
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aua (0.1.0)
4
+ aua (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/lib/aua/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Aua
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/aua.rb CHANGED
@@ -29,13 +29,22 @@ class Aua
29
29
  attr_reader :version, :os_name, :os_version, :parts, :raw, :platform
30
30
 
31
31
  def name
32
- unknown? ? raw : @name
32
+ @name unless unknown?
33
+ if simple?
34
+ app
35
+ else
36
+ raw
37
+ end
33
38
  end
34
39
 
35
40
  def type
36
41
  @type || :Unknown
37
42
  end
38
43
 
44
+ def version
45
+ @version ||= name ? version_of(name) : nil
46
+ end
47
+
39
48
  def products
40
49
  @products ||= parts.map{|p| p[0] }
41
50
  end
@@ -77,16 +86,16 @@ class Aua
77
86
  @os_string ||= comments.first && comments.first[2]
78
87
  end
79
88
 
80
- def version
81
- @version ||= name ? version_of(name) : nil
82
- end
83
-
84
89
  def unknown?
85
90
  type == :Unknown
86
91
  end
87
92
 
93
+ def simple?
94
+ products.size == 1 && versions.size <= 1 && comments == [[]]
95
+ end
96
+
88
97
  def to_s
89
- return "Unknown: #{raw}" if unknown?
98
+ return "Unknown: #{raw}#{" (simple)" if simple?}" if unknown?
90
99
  "#{type} #{name}/#{version} #{os_name}/#{os_version} #{platform}"
91
100
  end
92
101
  end
data/spec/aua_spec.rb CHANGED
@@ -432,7 +432,7 @@ describe Aua do
432
432
  its(:to_s) { should eql("Unknown: ")}
433
433
  end
434
434
 
435
- context "simple user agent string" do
435
+ context "standard user agent string" do
436
436
  subject{ Aua.new("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13") }
437
437
 
438
438
  its(:raw) { should eql("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13")}
@@ -478,4 +478,23 @@ describe Aua do
478
478
  its(:os_version) { should eql(nil) }
479
479
  its(:platform) { should eql(nil) }
480
480
  end
481
+
482
+ context "unknown simple user agent string" do
483
+ subject{ Aua.new("my_mite_app/v1.0") }
484
+
485
+ its(:raw) { should eql("my_mite_app/v1.0")}
486
+ its(:products) { should eql(["my_mite_app"]) }
487
+ its(:versions) { should eql(["v1.0"]) }
488
+ its(:comments) { should eql([[]]) }
489
+
490
+ it{ should be_unknown }
491
+ its(:to_s) { should eql("Unknown: my_mite_app/v1.0 (simple)")}
492
+
493
+ its(:name) { should eql("my_mite_app") }
494
+ its(:type) { should eql(:Unknown) }
495
+ its(:version) { should eql("v1.0") }
496
+ its(:os_name) { should eql(nil) }
497
+ its(:os_version) { should eql(nil) }
498
+ its(:platform) { should eql(nil) }
499
+ end
481
500
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sebastian Munz