simple-piwik 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +34 -4
- data/VERSION +1 -1
- data/lib/piwik/base.rb +17 -16
- data/lib/piwik/trackable.rb +1 -0
- data/simple-piwik.gemspec +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,6 +1,38 @@
|
|
1
1
|
= simple-piwik
|
2
2
|
|
3
|
-
|
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:
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'piwik'
|
17
|
+
site = Piwik::Site.load(1, 'http://your.piwi.install', 'some_auth_key')
|
18
|
+
=> #<Piwik::Site:0xb74bf994 @name="Example.com", @config={:auth_token=>"some_auth_key", :piwik_url=>"http://your.piwi.install"}, @id=1, @main_url="http://www.example.com", @created_at=Tue Jul 15 18:55:40 -0300 2008>
|
19
|
+
site.pageviews(:month, Date.today)
|
20
|
+
=> 88
|
21
|
+
|
22
|
+
user = Piwik::User.load(1, 'http://your.piwi.install', 'some_auth_key')
|
23
|
+
=> #<Piwik::User:0xb66bf544 @login="Example.com", @config={:auth_token=>"some_auth_key", :piwik_url=>"http://your.piwi.install"}, @id=1, @main_url="http://www.example.com", @created_at=Tue Jul 15 18:55:40 -0300 2008>
|
24
|
+
|
25
|
+
Piwik website (http://piwik.org)
|
26
|
+
|
27
|
+
Piwik API reference (http://dev.piwik.org/trac/wiki/API/Reference)
|
28
|
+
|
29
|
+
== REQUIREMENTS:
|
30
|
+
|
31
|
+
activesupport, rest-client, json
|
32
|
+
|
33
|
+
== INSTALL:
|
34
|
+
|
35
|
+
sudo gem install simple-piwik --source=http://gemcutter.org
|
4
36
|
|
5
37
|
== Note on Patches/Pull Requests
|
6
38
|
|
@@ -8,9 +40,7 @@ Description goes here.
|
|
8
40
|
* Make your feature addition or bug fix.
|
9
41
|
* Add tests for it. This is important so I don't break it in a
|
10
42
|
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but
|
13
|
-
bump version in a commit by itself I can ignore when I pull)
|
43
|
+
* 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)
|
14
44
|
* Send me a pull request. Bonus points for topic branches.
|
15
45
|
|
16
46
|
== Copyright
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/lib/piwik/base.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'rubygems'
|
2
2
|
#require 'cgi'
|
3
3
|
require 'active_support/all'
|
4
4
|
require 'json/ext'
|
@@ -23,16 +23,15 @@ piwik_url:
|
|
23
23
|
auth_token:
|
24
24
|
EOF
|
25
25
|
|
26
|
-
def self.on_rails?
|
27
|
-
(defined?(::Rails) && ::Rails.respond_to?(:root)) || (defined?(RAILS_ROOT) && RAILS_ROOT!=nil)
|
28
|
-
end
|
29
|
-
|
30
26
|
def self.config_file
|
31
|
-
if defined?(
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
if defined?(Rails.root) && Rails.root!=nil
|
28
|
+
# puts "config_file from Rails.root: #{Rails.root.to_s}"
|
29
|
+
Rails.root.join('config', 'piwik.yml')
|
30
|
+
# elsif defined?(RAILS_ROOT) && RAILS_ROOT!=nil
|
31
|
+
# puts "config_file from RAILS_ROOT: #{RAILS_ROOT}"
|
32
|
+
# File.join(RAILS_ROOT, 'config', 'piwik.yml')
|
35
33
|
else
|
34
|
+
# puts "config_file from ~/.piwik"
|
36
35
|
File.join( ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] || ".", '.piwik' )
|
37
36
|
end
|
38
37
|
end
|
@@ -80,14 +79,16 @@ EOF
|
|
80
79
|
def self.load_config_from_file
|
81
80
|
config = {}
|
82
81
|
config_file = self.config_file
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
if config_file
|
83
|
+
temp_config = if File.exists?(config_file)
|
84
|
+
YAML::load(open(config_file))
|
85
|
+
else
|
86
|
+
open(config_file,'w') { |f| f.puts @@template }
|
87
|
+
YAML::load(@@template)
|
88
|
+
end
|
89
|
+
temp_config.each { |k,v| config[k.to_sym] = v } if temp_config
|
90
|
+
raise MissingConfiguration, "Please edit #{config_file} to include piwik url and auth_key" if config[:piwik_url] == nil || config[:auth_token] == nil
|
88
91
|
end
|
89
|
-
temp_config.each { |k,v| config[k.to_sym] = v } if temp_config
|
90
|
-
raise MissingConfiguration, "Please edit #{config_file} to include piwik url and auth_key" if config[:piwik_url] == nil || config[:auth_token] == nil
|
91
92
|
config
|
92
93
|
end
|
93
94
|
end
|
data/lib/piwik/trackable.rb
CHANGED
@@ -57,6 +57,7 @@ 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
|
60
61
|
@@url = Piwik::Base.load_config_from_file[:piwik_url]
|
61
62
|
cattr_accessor :url
|
62
63
|
|
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.1"
|
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-04}
|
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.1
|
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-04 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|