double_agent 1.0.0 → 1.1.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/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
- == Release 1.0.0 (November 11, 2012) ==
1
+ == Release 1.1.0 (November 11, 2012) ==
2
+
3
+ * Add DoubleAgent.resource for easy mix-ins into other third-party libraries
4
+
5
+ == Release 1.0.0 (November 10, 2012) ==
2
6
 
3
7
  * Changes to parser API
4
8
  * Add "mobile?" method to detect mobile OS's
@@ -67,6 +67,18 @@ It gives that class's objects all of the above methods and more.
67
67
 
68
68
  See the DoubleAgent::Resource module for more info.
69
69
 
70
+ == Mixing into third-party code
71
+
72
+ If you want to mix DoubleAgent::Resource into some third-party code, you may find this helpful:
73
+
74
+ DoubleAgent.resource SomeHttpLogParser::LogEntry
75
+
76
+ If SomeHttpLogParser::LogEntry doesn't already have a user_agent method, do this:
77
+
78
+ DoubleAgent.resource SomeHttpLogParser::LogEntry do
79
+ # some code to return the user agent string
80
+ end
81
+
70
82
  == Where did stats and logs go?
71
83
 
72
84
  As of version 1.0.0, double_agent underwent a downsizing. Stats were dropped and moved to their own more generic gem called Graphene. More info at https://github.com/jhollinger/graphene. Logs were also dropped; there are several HTTP log parsers for Ruby, including http-log-parser and Beaver.
@@ -15,6 +15,15 @@ module DoubleAgent
15
15
  UserAgent.new(user_agent_string)
16
16
  end
17
17
 
18
+ # Mix DoubleAgent::Resource into klass. If klass doesn't already have a user_agent method,
19
+ # you may pass a block which will be used to define one.
20
+ def self.resource(klass, &user_agent_block)
21
+ klass.class_eval do
22
+ define_method :user_agent, &user_agent_block
23
+ end if user_agent_block
24
+ klass.send :include, DoubleAgent::Resource
25
+ end
26
+
18
27
  # Forwards calls to a UserAgent object
19
28
  def self.method_missing(method, *args, &block)
20
29
  parse(args.first).send(method)
@@ -1,4 +1,4 @@
1
1
  module DoubleAgent
2
2
  # Version number
3
- VERSION = '1.0.0'
3
+ VERSION = '1.1.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
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-11-10 00:00:00.000000000 Z
12
+ date: 2012-11-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Browser User Agent string parser
15
15
  email: jordan@jordanhollinger.com