simple-piwik 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -10
- data/VERSION +1 -1
- data/lib/piwik/base.rb +1 -1
- data/lib/piwik/site.rb +16 -3
- data/simple-piwik.gemspec +2 -2
- data/test/simple-piwik_test.rb +15 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -34,13 +34,5 @@ activesupport, rest-client, json
|
|
34
34
|
|
35
35
|
== INSTALL:
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
== Note on Patches/Pull Requests
|
40
|
-
|
41
|
-
* Fork the project.
|
42
|
-
* Make your feature addition or bug fix.
|
43
|
-
* Add tests for it. This is important so I don't break it in a
|
44
|
-
future version unintentionally.
|
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)
|
46
|
-
* Send me a pull request. Bonus points for topic branches.
|
37
|
+
gem install simple-piwik
|
38
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.7
|
data/lib/piwik/base.rb
CHANGED
data/lib/piwik/site.rb
CHANGED
@@ -112,7 +112,8 @@ module Piwik
|
|
112
112
|
give_access_to(:noaccess, login)
|
113
113
|
end
|
114
114
|
alias_method :remove_access_from, :give_no_access_to
|
115
|
-
|
115
|
+
|
116
|
+
|
116
117
|
# Returns a hash with a summary of access information for the current site
|
117
118
|
# (visits, unique visitors, actions / pageviews, maximum actions per visit,
|
118
119
|
# bounces and total time spent in all visits in seconds), filtered by the
|
@@ -175,8 +176,7 @@ module Piwik
|
|
175
176
|
end
|
176
177
|
alias_method :pageviews, :actions
|
177
178
|
|
178
|
-
# Returns a string with the javascript tracking code for the
|
179
|
-
# by it's Id in <tt>site_id</tt>.
|
179
|
+
# Returns a string with the javascript tracking code for the current site.
|
180
180
|
#
|
181
181
|
# Equivalent Piwik API call: SitesManager.getJavascriptTag (idSite)
|
182
182
|
def get_javascript_tag
|
@@ -186,6 +186,19 @@ module Piwik
|
|
186
186
|
result['value']
|
187
187
|
end
|
188
188
|
|
189
|
+
# Returns a big Array of Hashes with all page titles along with standard Actions metrics for each row, for the current site.
|
190
|
+
#
|
191
|
+
# Example result:
|
192
|
+
# => [{"label"=>" Izdelava spletnih strani | Spletnik d.o.o.", "nb_visits"=>36, "nb_uniq_visitors"=>35, "nb_hits"=>41, "sum_time_spent"=>240, "entry_nb_uniq_visitors"=>"33", "entry_nb_visits"=>"36", "entry_nb_actions"=>"92", "entry_sum_visit_length"=>"3422", "entry_bounce_count"=>"20", "exit_nb_uniq_visitors"=>"19", "exit_nb_visits"=>"22", "avg_time_on_page"=>7, "bounce_rate"=>"56%", "exit_rate"=>"61%"}]
|
193
|
+
#
|
194
|
+
# Equivalent Piwik API call: Actions.getPageTitles (idSite, period, date, segment = '', expanded = '', idSubtable = '')
|
195
|
+
def get_page_titles(period=:day, date=Date.today, segment='', expanded='', idSubtable='')
|
196
|
+
raise UnknownSite, "Site not existent in Piwik yet, call 'save' first" if new?
|
197
|
+
result = call('Actions.getPageTitles', :idSite => id, :period => period, :date => date, :segment => segment, :expanded => expanded, :idSubtable => idSubtable)
|
198
|
+
#puts "get_page_titles: #{result}"
|
199
|
+
result
|
200
|
+
end
|
201
|
+
|
189
202
|
private
|
190
203
|
# Loads the attributes in the instance variables.
|
191
204
|
def load_attributes(attributes)
|
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.7"
|
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-18}
|
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 = [
|
data/test/simple-piwik_test.rb
CHANGED
@@ -57,7 +57,7 @@ class PiwikTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def test_get_javascript_tag
|
61
61
|
assert_equal nil, @site.id
|
62
62
|
@site.save
|
63
63
|
assert_not_equal 0, @site.id
|
@@ -68,6 +68,20 @@ class PiwikTest < Test::Unit::TestCase
|
|
68
68
|
assert_equal true, reloaded.destroy
|
69
69
|
end
|
70
70
|
|
71
|
+
def test_get_page_titles
|
72
|
+
assert_equal nil, @site.id
|
73
|
+
@site.save
|
74
|
+
assert_not_equal 0, @site.id
|
75
|
+
assert_not_equal nil, @site.id
|
76
|
+
#TODO: maybe make an actual website visit here, by calling the Piwik tracking REST api, so that Piwik actually records something and the test can become more accurate
|
77
|
+
reloaded = Piwik::Site.load(@site.id)
|
78
|
+
assert_equal reloaded.id, @site.id
|
79
|
+
assert_equal true, reloaded.get_page_titles!=nil
|
80
|
+
assert_equal true, reloaded.get_page_titles.kind_of?(Array)
|
81
|
+
assert_equal true, reloaded.destroy
|
82
|
+
end
|
83
|
+
|
84
|
+
|
71
85
|
def test_can_read_standalone_config
|
72
86
|
File.open(File.join(ENV["HOME"],".piwik"), "w") { p.puts(File.read("./files/config/piwik/yml")) } unless File.join(ENV["HOME"],".piwik")
|
73
87
|
assert_nothing_raised do
|
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.7
|
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-18 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|