rack-piwik 0.2.2 → 0.3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 673e369b70b4aa20f71fc6127a4fd76df450636d
4
+ data.tar.gz: c9deeef3e42c0a21d4a45cdf1ef59682af8eba08
5
+ SHA512:
6
+ metadata.gz: 8fb34066d795136db51c43fa4cb34fd5e663590341cb1f9856fd7dda68be34557a96fe78dca879e77b8aafcdcfe946e1b3fa40927834c3ab891e6642bd279dd9
7
+ data.tar.gz: be89aae7b6fee3f77984741a5c57b33503394d40d6c21124a50ced1eaacde2ccae6f50b55901ba776548fb8a361b87cf8fb3e7d86b13b1407c7705c34d9b68e9
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -10,18 +10,18 @@ Simple Rack middleware to help injecting the Piwik tracking code into the footer
10
10
 
11
11
  #### Sinatra
12
12
  ## app.rb
13
- use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>'
13
+ use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>', :disable_cookies => true/false
14
14
 
15
15
  #### Padrino
16
16
 
17
17
  ## app/app.rb
18
- use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>'
18
+ use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>', :disable_cookies => true/false
19
19
 
20
20
  #### Rails
21
21
 
22
22
  ## application.rb:
23
23
  config.gem 'rack-piwik', :lib => 'rack/piwik'
24
- config.middleware.use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>'
24
+ config.middleware.use Rack::Piwik, :piwik_url => '<url of your piwik site here>', :piwik_id => '<your piwik id here>', :disable_cookies => true/false
25
25
 
26
26
  ## Thread Safety
27
27
 
@@ -4,11 +4,14 @@ require 'erb'
4
4
  module Rack
5
5
 
6
6
  class Piwik
7
- DEFAULT = {}
7
+ DEFAULT = {
8
+ :disable_cookies => false
9
+ }
8
10
 
9
11
  def initialize(app, options = {})
10
12
  raise ArgumentError, "piwik_url must be present" unless options[:piwik_url] and !options[:piwik_url].empty?
11
13
  raise ArgumentError, "piwik_id must be present" unless options[:piwik_id] and !options[:piwik_id].to_s.empty?
14
+
12
15
  @app, @options = app, DEFAULT.merge(options)
13
16
  end
14
17
 
@@ -9,6 +9,7 @@
9
9
  '/From = ' + String(document.referrer).replace(/\//g,"%2f")]);
10
10
  <% end %>
11
11
 
12
+ <%="_paq.push(['disableCookies']);" if @options[:disable_cookies] %>
12
13
  _paq.push(["trackPageView"]);
13
14
  _paq.push(["enableLinkTracking"]);
14
15
 
@@ -13,6 +13,7 @@ try {
13
13
  '/From = ' + String(document.referrer).replace(/\//g,"%2f"));
14
14
  <% end %>
15
15
 
16
+ <%="_paq.push(['disableCookies']);" if @options[:disable_cookies] %>
16
17
  piwikTracker.trackPageView();
17
18
  piwikTracker.enableLinkTracking();
18
19
  } catch( err ) {}
File without changes
@@ -10,7 +10,7 @@ class TestRackPiwik < Test::Unit::TestCase
10
10
  assert_match 'http://piwik.example.org/', last_response.body
11
11
  assert_match '_paq.push(["setSiteId", "123"]);', last_response.body
12
12
  assert_match %r{</noscript>\n<!-- End Piwik --></body>}, last_response.body
13
- assert_equal 787, last_response.headers['Content-Length'].to_i
13
+ assert_equal 792, last_response.headers['Content-Length'].to_i
14
14
  end
15
15
 
16
16
  should "omit 404 tracking for other responses with other status" do
@@ -29,7 +29,20 @@ class TestRackPiwik < Test::Unit::TestCase
29
29
  assert_no_match %r{Piwik}, last_response.body
30
30
  assert_match %r{head only}, last_response.body
31
31
  end
32
-
32
+
33
+ should "not disable piwik cookies" do
34
+ get "/body_only"
35
+ assert_no_match %r{disableCookies}, last_response.body
36
+ end
37
+ end
38
+
39
+ context "disable cookies is true" do
40
+ setup { mock_app :async => true, :tracker => 'somebody', :piwik_url => 'piwik.example.org', :piwik_id => '123', :disable_cookies => true }
41
+
42
+ should "disable piwik cookies" do
43
+ get "/body_only"
44
+ assert_match %r{\_paq\.push\(\[\'disableCookies\'\]\)\;}, last_response.body
45
+ end
33
46
  end
34
47
 
35
48
  context "with a number as piwik id" do
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-piwik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Maxwell Salzberg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-18 00:00:00.000000000 Z
11
+ date: 2014-06-01 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Simple Rack middleware for implementing Piwik Analytics tracking in your
15
14
  Ruby-Rack based project.
@@ -19,36 +18,36 @@ executables: []
19
18
  extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
21
+ - LICENSE
22
+ - README.md
22
23
  - lib/rack/piwik.rb
23
- - lib/rack/templates/sync.erb
24
24
  - lib/rack/templates/async.erb
25
- - README.md
26
- - LICENSE
27
- - test/test_rack_piwik.rb
25
+ - lib/rack/templates/sync.erb
28
26
  - test/helper.rb
27
+ - test/test_rack_piwik.rb
29
28
  homepage: https://github.com/maxwell/rack-piwik
30
29
  licenses: []
30
+ metadata: {}
31
31
  post_install_message:
32
32
  rdoc_options: []
33
33
  require_paths:
34
34
  - lib
35
35
  required_ruby_version: !ruby/object:Gem::Requirement
36
- none: false
37
36
  requirements:
38
- - - ! '>='
37
+ - - '>='
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  required_rubygems_version: !ruby/object:Gem::Requirement
42
- none: false
43
41
  requirements:
44
- - - ! '>='
42
+ - - '>='
45
43
  - !ruby/object:Gem::Version
46
44
  version: '0'
47
45
  requirements: []
48
46
  rubyforge_project:
49
- rubygems_version: 1.8.24
47
+ rubygems_version: 2.2.2
50
48
  signing_key:
51
- specification_version: 3
49
+ specification_version: 4
52
50
  summary: Rack middleware to inject the Piwik tracking code into outgoing responses.
53
51
  Adapted from rack-google-analytics
54
52
  test_files: []
53
+ has_rdoc: