simple-piwik 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +2 -18
- data/README.rdoc +19 -21
- data/VERSION +1 -1
- data/lib/piwik/base.rb +2 -2
- data/lib/piwik/trackable.rb +5 -5
- data/simple-piwik.gemspec +2 -2
- metadata +2 -2
data/LICENSE
CHANGED
@@ -1,20 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
No-Copyright (c)
|
2
2
|
|
3
|
-
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
3
|
+
You have all the Copyright. This code is yours.
|
10
4
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
= simple-piwik
|
2
2
|
|
3
|
-
A client for the Piwik API.
|
4
|
-
|
5
|
-
* http://github.com/mihael/simple-piwik
|
6
|
-
|
7
|
-
== DESCRIPTION:
|
8
|
-
|
9
|
-
Provides simple access to the Piwik API.
|
10
|
-
|
11
|
-
== FEATURES NO PROBLEMS
|
12
|
-
|
13
|
-
== SYNOPSIS:
|
3
|
+
A client for the Piwik API compatible with Rails 3.x
|
14
4
|
|
15
5
|
require 'rubygems'
|
16
6
|
require 'piwik'
|
17
|
-
|
18
|
-
|
7
|
+
Piwik.auth_token = "i need to configure simple-piwik with my auth_token here"
|
8
|
+
Piwik.piwik_url = "http://piwik.mypiwikdomain.org"
|
9
|
+
site = Piwik::Site.load(1)
|
10
|
+
=> #<Piwik::Site:0xb36ax935 @name="Examples.com", @config={:auth_token=>"my_auth_key", :piwik_url=>"http://piwik.mypiwikdomain.org"}, @id=1, @main_url="http://www.examples.com", @created_at=Thu Oct 20 22:55:42 +0100 2023>
|
19
11
|
site.pageviews(:month, Date.today)
|
20
|
-
=>
|
12
|
+
=> 3002378
|
13
|
+
user = Piwik::User.load(1, 'http://piwik.mypiwikdomain.org', 'my_auth_key')
|
14
|
+
=> #<Piwik::User:0xa108ac955 @login="Examples.com", @config={:auth_token=>"my_auth_key", :piwik_url=>"http://piwik.mypiwikdomain.org"}, @id=1, @main_url="http://www.examples.com", @created_at=Thu Oct 20 22:55:43 -0100 2023>
|
15
|
+
|
16
|
+
Configuring with initializer config/initializers/simple-piwik.rb :
|
21
17
|
|
22
|
-
|
23
|
-
|
18
|
+
if Rails.env.production?
|
19
|
+
Piwik.piwik_url = "http://piwik.mypiwikdomain.org"
|
20
|
+
Piwik.auth_token = "2ad590308b1efa590a9a43ad86d3ac1s"
|
21
|
+
elsif Rails.env.development?
|
22
|
+
#this is currently set to the same as production
|
23
|
+
Piwik.piwik_url = "http://piwik.mypiwikdomain.org"
|
24
|
+
Piwik.auth_token = "2ad590308b1efa590a9a43ad86d3ac1s"
|
25
|
+
end
|
24
26
|
|
25
|
-
Piwik website (http://piwik.org)
|
27
|
+
Piwik website (http://piwik.org)
|
26
28
|
|
27
29
|
Piwik API reference (http://dev.piwik.org/trac/wiki/API/Reference)
|
28
30
|
|
@@ -42,7 +44,3 @@ activesupport, rest-client, json
|
|
42
44
|
future version unintentionally.
|
43
45
|
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
44
46
|
* Send me a pull request. Bonus points for topic branches.
|
45
|
-
|
46
|
-
== Copyright
|
47
|
-
|
48
|
-
Copyright (c) 2011 mihael. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/lib/piwik/base.rb
CHANGED
@@ -67,7 +67,7 @@ EOF
|
|
67
67
|
# <tt>Piwik::ApiError</tt> exception with the error message returned by Piwik
|
68
68
|
# in case it receives an error.
|
69
69
|
def self.call(method, params={}, piwik_url=nil, auth_token=nil)
|
70
|
-
raise MissingConfiguration, "Please edit
|
70
|
+
raise MissingConfiguration, "Please edit #{config_file} to include your piwik url and auth_token or configure Piwik.piwik_url and Piwik.auth_token before use" if piwik_url.nil? || auth_token.nil?
|
71
71
|
url = "#{piwik_url}/?module=API&format=json&method=#{method}"
|
72
72
|
url << "&token_auth=#{auth_token}" unless auth_token.nil?
|
73
73
|
params.each { |k, v| url << "&#{k}=#{CGI.escape(v.to_s)}" }
|
@@ -98,7 +98,7 @@ EOF
|
|
98
98
|
end
|
99
99
|
temp_config.each { |k,v| config[k.to_sym] = v } if temp_config
|
100
100
|
end
|
101
|
-
raise MissingConfiguration, "Please edit #{config_file} to include piwik url and
|
101
|
+
raise MissingConfiguration, "Please edit #{config_file} to include piwik url and auth_token or configure Piwik.piwik_url and Piwik.auth_token before use" if config[:piwik_url] == nil || config[:auth_token] == nil
|
102
102
|
#cache settings
|
103
103
|
Piwik.piwik_url = config[:piwik_url]
|
104
104
|
Piwik.auth_token = config[:auth_token]
|
data/lib/piwik/trackable.rb
CHANGED
@@ -57,23 +57,23 @@ module Piwik
|
|
57
57
|
@@use_async = false
|
58
58
|
cattr_accessor :use_async
|
59
59
|
|
60
|
-
#at point of starting up a rails project Rails.root points to nil, and this config loading breakes a rails app
|
61
|
-
@@url = Piwik::Base.load_config[:piwik_url]
|
62
|
-
cattr_accessor :url
|
63
|
-
|
64
60
|
@@environments = ["production","development"]
|
65
61
|
cattr_accessor :environments
|
66
62
|
|
67
63
|
@@formats = [:html, :all]
|
68
64
|
cattr_accessor :formats
|
69
65
|
|
66
|
+
def self.url
|
67
|
+
Piwik.piwik_url
|
68
|
+
end
|
69
|
+
|
70
70
|
=begin rdoc
|
71
71
|
Checks whether the model can be tracked using piwik by checking for a piwik_id and domain fields.
|
72
72
|
This is a pretty specific use case, a more generic application tracking solution is available here:
|
73
73
|
https://github.com/Achillefs/piwik_analytics/ (this file is actually swiped from that plugin)
|
74
74
|
=end
|
75
75
|
def self.enabled?(format)
|
76
|
-
raise Piwik::MissingConfiguration if url.blank?
|
76
|
+
raise Piwik::MissingConfiguration if self.url.blank?
|
77
77
|
environments.include?(Rails.env) && formats.include?(format.to_sym)
|
78
78
|
end
|
79
79
|
end
|
data/simple-piwik.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{simple-piwik}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{mihael}]
|
12
|
-
s.date = %q{2011-08-
|
12
|
+
s.date = %q{2011-08-12}
|
13
13
|
s.description = %q{Provides simple access to the Piwik API.}
|
14
14
|
s.email = %q{mihael.ploh@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: simple-piwik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- mihael
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|