simple-piwik 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.7
1
+ 0.5.8
data/lib/piwik/site.rb CHANGED
@@ -192,13 +192,30 @@ module Piwik
192
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
193
  #
194
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='')
195
+ def get_page_titles(params={})
196
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)
197
+ result = call('Actions.getPageTitles', {:idSite => id, :period => :day, :date => Date.today, :segment => '', :expanded => '', :idSubtable => ''}.update(params))
198
198
  #puts "get_page_titles: #{result}"
199
199
  result
200
200
  end
201
201
 
202
+ # Returns a big Array of Hashes with all page urls along with standard Actions metrics for each row, for the current site.
203
+ #
204
+ # Example result:
205
+ # => [{"label"=>"spletnik", "nb_visits"=>69, "nb_hits"=>87, "sum_time_spent"=>4762, "entry_nb_visits"=>40, "entry_nb_actions"=>101, "entry_sum_visit_length"=>6752, "entry_bounce_count"=>26, "exit_nb_visits"=>39, "avg_time_on_page"=>69, "bounce_rate"=>"65%", "exit_rate"=>"57%", "idsubdatatable"=>1}]
206
+ #
207
+ # Example call:
208
+ #
209
+ # Piwik::Site.load(203).get_page_urls(:expanded=>1)
210
+ #
211
+ # Equivalent Piwik API call: Actions.getPageUrls (idSite, period, date, segment = '', expanded = '', idSubtable = '')
212
+ def get_page_urls(params={})
213
+ raise UnknownSite, "Site not existent in Piwik yet, call 'save' first" if new?
214
+ result = call('Actions.getPageUrls', { :idSite => id, :period => :day, :date => Date.today, :segment => '', :expanded => '', :idSubtable => '' }.update(params))
215
+ #puts "get_page_urls: #{result}"
216
+ result
217
+ end
218
+
202
219
  private
203
220
  # Loads the attributes in the instance variables.
204
221
  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.7"
8
+ s.version = "0.5.8"
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-18}
12
+ s.date = %q{2011-08-19}
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 = [
@@ -81,7 +81,19 @@ class PiwikTest < Test::Unit::TestCase
81
81
  assert_equal true, reloaded.destroy
82
82
  end
83
83
 
84
-
84
+ def test_get_page_urls
85
+ assert_equal nil, @site.id
86
+ @site.save
87
+ assert_not_equal 0, @site.id
88
+ assert_not_equal nil, @site.id
89
+ #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
90
+ reloaded = Piwik::Site.load(@site.id)
91
+ assert_equal reloaded.id, @site.id
92
+ assert_equal true, reloaded.get_page_urls!=nil
93
+ assert_equal true, reloaded.get_page_urls.kind_of?(Array)
94
+ assert_equal true, reloaded.destroy
95
+ end
96
+
85
97
  def test_can_read_standalone_config
86
98
  File.open(File.join(ENV["HOME"],".piwik"), "w") { p.puts(File.read("./files/config/piwik/yml")) } unless File.join(ENV["HOME"],".piwik")
87
99
  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.7
5
+ version: 0.5.8
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-18 00:00:00 Z
13
+ date: 2011-08-19 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport