agent_orange 0.1.4 → 0.1.5

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/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  .bundle
2
2
  Gemfile.lock
3
3
  pkg/*
4
+ .yardoc
5
+ doc
data/README.rdoc CHANGED
@@ -116,7 +116,7 @@ If you're going to use it with Rails then add the gem to your Gemfile.
116
116
 
117
117
  == General Class Definition
118
118
 
119
- This is not up to date or a reflection of the actual class structure. This will be updated eventually.
119
+ This is not up to date or a reflection of the actual class structure. This will be updated eventually. See http://rubydoc.info/gems/agent_orange/frames for more detailed docs.
120
120
 
121
121
  AgentOrange::UserAgent
122
122
  device
@@ -165,6 +165,7 @@ A warm thank you to all contributors to the project, who have put effort and tim
165
165
  * Alexander Rozumiy (@brain-geek) - Rspec testing for 1.9, updated travis-ci config, updated useragents to test against.
166
166
  * Joe Lencioni (@lencioni) - Improved bot detection.
167
167
  * Todd Huss (@thuss) of Two Bit Labs (@twobitlabs) - Google Mobile crawler detection as mobile and bot.
168
+ * Aidan Feldman (@afeld) - Initial YARD documentation, and minor fix.
168
169
 
169
170
  == License
170
171
 
@@ -3,7 +3,15 @@ require 'agent_orange/version'
3
3
 
4
4
  module AgentOrange
5
5
  class Browser < Base
6
- attr_accessor :type, :name, :version
6
+ # @return [Symbol] one of the keys from {BROWSERS}
7
+ attr_accessor :type
8
+
9
+ # @return [String] one of the values from {BROWSERS}
10
+ attr_accessor :name
11
+
12
+ # @return [AgentOrange::Version]
13
+ attr_accessor :version
14
+
7
15
  attr_accessor :security
8
16
 
9
17
  BROWSERS = {
@@ -63,6 +71,7 @@ module AgentOrange
63
71
  AgentOrange.debug "", 2
64
72
  end
65
73
 
74
+ # @return {String}
66
75
  def to_s
67
76
  [self.name, self.version].compact.join(' ')
68
77
  end
@@ -6,9 +6,25 @@ require 'agent_orange/version'
6
6
 
7
7
  module AgentOrange
8
8
  class Device < Base
9
- attr_accessor :type, :name, :version, :bot
9
+ # @return [Symbol] one of the keys from {DEVICES}
10
+ attr_accessor :type
11
+
12
+ # @return [String]
13
+ attr_accessor :name
14
+
15
+ # @return [AgentOrange::Version]
16
+ attr_accessor :version
17
+
18
+ # @return [Boolean]
19
+ attr_accessor :bot
20
+
21
+ # @return [AgentOrange::Platform]
10
22
  attr_accessor :platform
23
+
24
+ # @return [AgentOrange::OperatingSystem]
11
25
  attr_accessor :operating_system
26
+
27
+ # @return [AgentOrange::Engine]
12
28
  attr_accessor :engine
13
29
 
14
30
  DEVICES = {
@@ -59,6 +75,7 @@ module AgentOrange
59
75
  AgentOrange.debug "", 2
60
76
  end
61
77
 
78
+ # @return [Boolean]
62
79
  def is_computer?(name=nil)
63
80
  if name
64
81
  case name
@@ -72,6 +89,7 @@ module AgentOrange
72
89
  end
73
90
  end
74
91
 
92
+ # @return [Boolean]
75
93
  def is_mobile?(name=nil)
76
94
  if !name.nil? && !self.platform.name.nil?
77
95
  case name
@@ -85,6 +103,7 @@ module AgentOrange
85
103
  end
86
104
  end
87
105
 
106
+ # @return [Boolean]
88
107
  def is_bot?(name=nil)
89
108
  if name
90
109
  case name
@@ -98,6 +117,7 @@ module AgentOrange
98
117
  end
99
118
  end
100
119
 
120
+ # @return [String]
101
121
  def to_s
102
122
  [self.name, self.version].compact.join(' ')
103
123
  end
@@ -5,7 +5,16 @@ require 'pp'
5
5
 
6
6
  module AgentOrange
7
7
  class Engine < Base
8
- attr_accessor :type, :name, :version
8
+ # @return [Symbol] one of the keys from {ENGINES}
9
+ attr_accessor :type
10
+
11
+ # @return [String] one of the values from {ENGINES}
12
+ attr_accessor :name
13
+
14
+ # @return [AgentOrange::Version]
15
+ attr_accessor :version
16
+
17
+ # @return [AgentOrange::Browser]
9
18
  attr_accessor :browser
10
19
 
11
20
  ENGINES = {
@@ -58,6 +67,7 @@ module AgentOrange
58
67
  AgentOrange.debug "", 2
59
68
  end
60
69
 
70
+ # @return [String]
61
71
  def to_s
62
72
  [self.name, self.version].compact.join(' ') || "Unknown"
63
73
  end
@@ -2,7 +2,14 @@ require 'agent_orange/base'
2
2
 
3
3
  module AgentOrange
4
4
  class OperatingSystem < Base
5
- attr_accessor :type, :name, :version
5
+ # @return [Symbol] one of the keys from {OPERATING_SYSTEMS}
6
+ attr_accessor :type
7
+
8
+ # @return [String] one of the values from {OPERATING_SYSTEM_NAMES}
9
+ attr_accessor :name
10
+
11
+ # @return [AgentOrange::Version]
12
+ attr_accessor :version
6
13
 
7
14
  OPERATING_SYSTEMS = {
8
15
  :android => 'android',
@@ -62,6 +69,7 @@ module AgentOrange
62
69
  AgentOrange.debug "", 2
63
70
  end
64
71
 
72
+ # @return [String]
65
73
  def to_s
66
74
  [self.name, self.version].compact.join(' ')
67
75
  end
@@ -2,7 +2,14 @@ require 'agent_orange/base'
2
2
 
3
3
  module AgentOrange
4
4
  class Platform < Base
5
- attr_accessor :type, :name, :version
5
+ # @return [Symbol] one of the keys from {PLATFORMS}
6
+ attr_accessor :type
7
+
8
+ # @return [String] one of the values from {PLATFORM_NAMES}
9
+ attr_accessor :name
10
+
11
+ # @return [AgentOrange::Version]
12
+ attr_accessor :version
6
13
 
7
14
  PLATFORMS = {
8
15
  :android => 'android',
@@ -17,6 +24,7 @@ module AgentOrange
17
24
  :mac => 'Macintosh',
18
25
  :pc => 'PC'
19
26
  }
27
+
20
28
  PLATFORM_VERSIONS = {
21
29
  :ipad => 'ipad',
22
30
  :iphone => 'iphone',
@@ -5,10 +5,15 @@ module AgentOrange
5
5
  DEBUG_LEVEL = 1
6
6
 
7
7
  class UserAgent
8
+ # @return [String]
8
9
  attr_accessor :user_agent_string
10
+
9
11
  attr_accessor :user_language
12
+
13
+ # @return [AgentOrange::Device]
10
14
  attr_accessor :device
11
15
 
16
+ # @param [String] user_agent_string
12
17
  def initialize(user_agent_string)
13
18
  self.parse(user_agent_string)
14
19
  end
@@ -26,18 +31,22 @@ module AgentOrange
26
31
  self.summary
27
32
  end
28
33
 
34
+ # @return [Boolean]
29
35
  def is_computer?(type=nil)
30
36
  self.device.is_computer?(type)
31
37
  end
32
38
 
39
+ # @return [Boolean]
33
40
  def is_mobile?(type=nil)
34
41
  self.device.is_mobile?(type)
35
42
  end
36
43
 
44
+ # @return [Boolean]
37
45
  def is_bot?(type=nil)
38
46
  self.device.is_bot?(type)
39
47
  end
40
48
 
49
+ # @return [String]
41
50
  def to_s
42
51
  [self.device,
43
52
  self.device.platform,
@@ -47,6 +56,7 @@ module AgentOrange
47
56
  ].compact.join(", ")
48
57
  end
49
58
 
59
+ # @return [String]
50
60
  def to_human_string
51
61
  if self.device && self.device.engine && self.device.engine.browser
52
62
  "User has a #{self.device} running #{self.device.engine.browser} (which is based on #{self.device.engine})."
@@ -1,8 +1,18 @@
1
1
  module AgentOrange
2
- VERSION = "0.1.4" # This is for the gem and does not conflict with the rest of the functionality
2
+ VERSION = "0.1.5" # This is for the gem and does not conflict with the rest of the functionality
3
3
 
4
4
  class Version
5
- attr_accessor :major, :minor, :patch_level, :build_number
5
+ # @return [String, nil]
6
+ attr_accessor :major
7
+
8
+ # @return [String, nil]
9
+ attr_accessor :minor
10
+
11
+ # @return [String, nil]
12
+ attr_accessor :patch_level
13
+
14
+ # @return [String, nil]
15
+ attr_accessor :build_number
6
16
 
7
17
  def initialize(version_string)
8
18
  version_string = sanitize_version_string(version_string)
@@ -20,6 +30,7 @@ module AgentOrange
20
30
  self.build_number = pieces[3] if pieces_count >= 4
21
31
  end
22
32
 
33
+ # @return [String]
23
34
  def to_s
24
35
  [self.major, self.minor, self.patch_level, self.build_number].compact.join('.')
25
36
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agent_orange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-02 00:00:00.000000000 Z
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  segments:
106
106
  - 0
107
- hash: 3447996973066074909
107
+ hash: 3187188624662308564
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  none: false
110
110
  requirements:
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  segments:
115
115
  - 0
116
- hash: 3447996973066074909
116
+ hash: 3187188624662308564
117
117
  requirements: []
118
118
  rubyforge_project: agent_orange
119
119
  rubygems_version: 1.8.24