rack-google-analytics 0.10.0 → 0.11.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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Lee Hambley
1
+ Copyright (c) 2009-2012 Lee Hambley
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,60 +1,57 @@
1
1
  # Rack google Analytics
2
2
 
3
- Simple Rack middleware to help injecting the google analytics tracking code into the footer of your websites.
3
+ Simple Rack middleware to help injecting the Google Analytics tracking code in your website.
4
4
 
5
- This middleware injects either the synchronous or asynchronous google analytics tracker code into the correct place of any request with `Content-Type` containing `html` (therefore `text/html` and similar).
6
-
7
- Formerly this gem had an environments setting, that has been removed pending refactoring.
5
+ This middleware injects either the synchronous or asynchronous Google Analytics tracking code into the correct place of any request only when the response's `Content-Type` header contains `html` (therefore `text/html` and similar).
8
6
 
9
7
  ## Usage
10
8
 
11
- #### Gemfile:
12
- gem 'rack-google-analytics', :require => 'rack/google-analytics'
9
+ #### Gemfile
10
+
11
+ ```ruby
12
+ gem 'rack-google-analytics'
13
+ ```
13
14
 
14
15
  #### Sinatra
15
- ## app.rb
16
- use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x'
16
+
17
+ ```ruby
18
+ ## app.rb
19
+ use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x'
20
+ ```
17
21
 
18
22
  #### Padrino
19
23
 
20
- ## app/app.rb
21
- use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x'
24
+ ```ruby
25
+ ## app/app.rb
26
+ use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x'
27
+ ```
22
28
 
23
- #### Rails
29
+ #### Rails 2.X
24
30
 
25
- ## environment.rb:
26
- config.gem 'rack-google-analytics', :lib => 'rack/google-analytics'
27
- config.middleware.use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x'
31
+ ```ruby
32
+ ## environment.rb:
33
+ config.gem 'rack-google-analytics', :lib => 'rack/google-analytics'
34
+ config.middleware.use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x'
35
+ ```
28
36
 
29
37
  ### Options
30
38
 
31
- * :async - sets to use asyncronous tracker
32
- * :multiple - sets track for multiple sub domains. (must also set :domain)
33
- * :top_level - sets tracker for multiple top-level domains. (must also set :domain)
39
+ * `:async` - sets to use asynchronous tracker
40
+ * `:multiple` - sets track for multiple subdomains. (must also set :domain)
41
+ * `:top_level` - sets tracker for multiple top-level domains. (must also set :domain)
34
42
 
35
- Note: since 0.2.0 this will use the asynchronous google tracker code, for the traditional behaviour please use:
43
+ Note: since 0.2.0 this will use the asynchronous Google Analytics tracking code, for the traditional behaviour please use:
36
44
 
37
- use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x', :async => false
45
+ ```ruby
46
+ use Rack::GoogleAnalytics, :tracker => 'UA-xxxxxx-x', :async => false
47
+ ```
38
48
 
39
- If you are not sure what's best, go with the defaults, and read here if you should opt-out
49
+ If you are not sure what's best, go with the defaults, and read here if you should opt-out.
40
50
 
41
51
  ## Thread Safety
42
52
 
43
53
  This middleware *should* be thread safe. Although my experience in such areas is limited, having taken the advice of those with more experience; I defer the call to a shallow copy of the environment, if this is of consequence to you please review the implementation.
44
54
 
45
- ## Change Log
46
-
47
- * 0.10.0 Include the Google pagespeed code, and `README` typos fixed.
48
- * 0.9.2 Fixed a bug with lots of missing files from the Gem... how silly!
49
- * 0.9.1 Updated readme to reflect 0.9.0 merge from achiu
50
- * 0.9.0 Include name changed from 'rack-google-analytics' to 'rack/google-analytics' more inline with the norm
51
- * 0.6.0 Class now named Rack::GoogleAnalytics, in 0.5 and earlier this was incorrectly documented as Rack::GoogleTracker
52
- * 0.2.0 Asynchronous code is now the default.
53
-
54
- * 22-07-2010 Major re-write from Arthur Chiu, now correctly writes the Content-Length leader, and comes with tests (High five to @achiu) - this patch also backs-out the changes from @cimm - but they were un-tested (I intend to bring these back as soon as possible; this will probably constitute a 1.0 release when it happens)
55
- * 19-01-2010 Second Release, patch from github.com/ralph - makes the default snippet the async version from google. Use regular synchronous code with: `:async => false`
56
- * 27-12-2009 First Release, extracted from the Capistrano-Website project and packaged with Jeweler.
57
-
58
55
  ## Note on Patches/Pull Requests
59
56
 
60
57
  * Fork the project.
@@ -67,5 +64,5 @@ This middleware *should* be thread safe. Although my experience in such areas is
67
64
 
68
65
  ## Copyright
69
66
 
70
- Copyright (c) 2009-2011 Lee Hambley. See LICENSE for details.
71
- With thanks to Ralph von der Heyden http://github.com/ralph/ and Simon `cimm` Schoeters http://github.com/cimm/ - And the biggest hand to Arthur `achiu` Chiu for the huge work that went into the massive 0.9 re-factor.
67
+ Copyright (c) 2009-2012 Lee Hambley. See LICENSE for details.
68
+ With thanks to [Ralph von der Heyden](https://github.com/ralph) and [Simon Schoeters](https://github.com/cimm) - And the biggest hand to [Arthur Chiu](https://github.com/achiu) for the huge work that went into the massive 0.9 re-factor.
@@ -0,0 +1 @@
1
+ require 'rack/google-analytics'
@@ -4,7 +4,7 @@ require 'erb'
4
4
  module Rack
5
5
 
6
6
  class GoogleAnalytics
7
-
7
+
8
8
  DEFAULT = { :async => true }
9
9
 
10
10
  def initialize(app, options = {})
@@ -15,10 +15,12 @@ module Rack
15
15
  def call(env); dup._call(env); end
16
16
 
17
17
  def _call(env)
18
- @status, @headers, @response = @app.call(env)
19
- return [@status, @headers, @response] unless html?
18
+ @status, @headers, @body = @app.call(env)
19
+ return [@status, @headers, @body] unless html?
20
20
  response = Rack::Response.new([], @status, @headers)
21
- @response.each { |fragment| response.write inject(fragment) }
21
+ @body.each { |fragment| response.write inject(fragment) }
22
+ @body.close if @body.respond_to?(:close)
23
+
22
24
  response.finish
23
25
  end
24
26
 
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class GoogleAnalytics
3
+ VERSION = '0.11.0'
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class GoogleAnalytics
3
+ VERSION = '0.11.0'
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-google-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,88 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-15 00:00:00.000000000Z
13
- dependencies: []
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: test-unit
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.5.1
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.5.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: shoulda
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 2.11.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.11.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rack-test
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.5.4
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.5.4
14
94
  description: Simple Rack middleware for implementing google analytics tracking in
15
95
  your Ruby-Rack based project. Supports synchronous and asynchronous insertion and
16
96
  configurable load options.
@@ -20,9 +100,12 @@ executables: []
20
100
  extensions: []
21
101
  extra_rdoc_files: []
22
102
  files:
103
+ - lib/rack/google-analytics/version.rb
23
104
  - lib/rack/google-analytics.rb
24
105
  - lib/rack/templates/async.erb
25
106
  - lib/rack/templates/sync.erb
107
+ - lib/rack/version.rb
108
+ - lib/rack-google-analytics.rb
26
109
  - README.md
27
110
  - LICENSE
28
111
  homepage: https://github.com/leehambley/rack-google-analytics
@@ -45,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
128
  version: '0'
46
129
  requirements: []
47
130
  rubyforge_project:
48
- rubygems_version: 1.8.10
131
+ rubygems_version: 1.8.23
49
132
  signing_key:
50
133
  specification_version: 3
51
134
  summary: Rack middleware to inject the Google Analytics tracking code into outgoing