<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
-Copyright 2008 Rob McKinnon
-Copyright 2007 John Nunemaker
+Copyright (c) 2008 Rob McKinnon
+Copyright (c) 2007 John Nunemaker
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the &quot;Software&quot;), to deal</diff>
      <filename>LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -11,6 +11,8 @@ Feel free however to hack at it and send me patches.
 
 Login with your Google Analytics user name and password:
 
+ require 'rugalytics'
+
  Rugalytics.login 'username', 'password'
 
 
@@ -26,6 +28,12 @@ If account name and profile name are the same:
  profile = Rugalytics.find_profile('your_site.com')
 
 
+== Get Profile Summary Statistics
+
+ profile.pageviews
+ =&gt; 16060
+
+
 == Load Reports
 
  report = profile.load_report 'TrafficSources'
@@ -58,4 +66,23 @@ If account name and profile name are the same:
  =&gt; 100
 
  report.items.first.network_location
- =&gt; &quot;telecom xtra&quot;
\ No newline at end of file
+ =&gt; &quot;telecom xtra&quot;
+
+
+
+&gt;&gt; require 'statwhore'
+=&gt; true
+&gt;&gt; Google::Base.establish_connection('username@gmail.com', 'tehs3cr3t')
+=&gt; #&lt;Google::Base:0x199ae84 @password=&quot;tehs3cr3t&quot;, @email=&quot;username@gmail.com&quot;, @sid=&quot;areallylonghashofkeysthatyoucantsee&quot;&gt;
+&gt;&gt; Statwhore::Google::Analytics::Account.find_all
+=&gt; [#&lt;Statwhore::Google::Analytics::Account:0x1943300 @account_id=85301, @name=&quot;addictedtonew.com&quot;&gt;, #&lt;Statwhore::Google::Analytics::Account:0x1943058 @account_id=344381, @name=&quot;webgroup.nd.edu&quot;&gt;]
+&gt;&gt; Statwhore::Google::Analytics::Profile.find_all(85301)
+=&gt; [#&lt;Statwhore::Google::Analytics::Profile:0x12a0304 @account_id=85301, @name=&quot;addictedtonew.com&quot;, @profile_id=47912&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x129edd8 @account_id=85301, @name=&quot;googlebase.rubyforge.org&quot;, @profile_id=5867643&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x129e70c @account_id=85301, @name=&quot;googlereader.rubyforge.org&quot;, @profile_id=5868472&gt;,  #&lt;Statwhore::Google::Analytics::Profile:0x129cde4 @account_id=85301, @name=&quot;lorem.rubyforge.org&quot;, @profile_id=3027809&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x129a080 @account_id=85301, @name=&quot;mirrored.rubyforge.org&quot;, @profile_id=5211778&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x12999c8 @account_id=85301, @name=&quot;railstips.org&quot;, @profile_id=1897579&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x12995b8 @account_id=85301, @name=&quot;scrobbler.rubyforge.org&quot;, @profile_id=3293580&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x12991bc @account_id=85301, @name=&quot;snitch.rubyforge.org&quot;, @profile_id=2800544&gt;, #&lt;Statwhore::Google::Analytics::Profile:0x12989c4 @account_id=85301, @name=&quot;twitter.rubyforge.org&quot;, @profile_id=2865122&gt;]
+&gt;&gt; profile = Statwhore::Google::Analytics::Profile.find(85301, 1897579)
+=&gt; #&lt;Statwhore::Google::Analytics::Profile:0x1c3af18 @account_id=85301, @name=&quot;railstips.org&quot;, @profile_id=1897579&gt;
+&gt;&gt; profile.pageviews
+=&gt; 1743
+&gt;&gt; profile.pageviews(:from =&gt; Time.mktime(2008, 3, 1), :to =&gt; Time.mktime(2008, 3, 10))
+=&gt; 2416
+&gt;&gt; profile.visits(:from =&gt; Time.mktime(2008, 3, 1), :to =&gt; Time.mktime(2008, 3, 10))
+=&gt; 1862
\ No newline at end of file</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@ require 'rubygems'
 require 'hpricot'
 require 'activesupport'
 require 'google/base'
+require 'morph'
 
 module Rugalytics
   VERSION = &quot;0.0.1&quot;
@@ -17,6 +18,13 @@ module Rugalytics
 
   VALID_REPORTS = %w[ Dashboard ] unless defined? VALID_REPORTS
 
+  module MorphLessMethodMissing
+    def self.included(base)
+      base.extend Morph::ClassMethods
+      base.send(:include, Morph::InstanceMethods)
+    end
+  end
+
   class InvalidCredentials &lt; Exception
   end
 </diff>
      <filename>lib/rugalytics.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,3 @@
-
 module Rugalytics
   class Account &lt; ::Google::Base
 </diff>
      <filename>lib/rugalytics/account.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'net/https'
+
 module Rugalytics
   class Connection
     def initialize(base_url, args = {})</diff>
      <filename>lib/rugalytics/connection.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,22 +1,25 @@
 module Rugalytics
-
   class Graph
 
-    attr_reader :name, :points
+    attr_reader :name, :points, :from, :to
 
     def initialize name, period, points
       @name = name
       @period = period
+      dates = @period.split('-')
+      unless dates.empty?
+        @from = Date.parse(dates[0].strip)
+        @to = Date.parse(dates[1].strip)
+      end
       @points = points
     end
 
-    def start_date
-      @period.split('-')[0].strip
+    def sum_of_points
+      points.sum
     end
 
-    def end_date
-      @period.split('-')[1].strip
+    def points_by_day
+      date = Date.parse(start_date)
     end
   end
-
 end
\ No newline at end of file</diff>
      <filename>lib/rugalytics/graph.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,3 @@
-require 'morph'
-
 module Rugalytics
 
   class Item</diff>
      <filename>lib/rugalytics/item.rb</filename>
    </modified>
    <modified>
      <diff>@@ -61,7 +61,7 @@ module Rugalytics
     end
 
     def pageviews(options={})
-      get_item_summary_by_message(options.merge(:message =&gt; 'pageviews'))
+      load_report('Pageviews').page_views_total
     end
 
     def pageviews_by_day(options={})</diff>
      <filename>lib/rugalytics/profile.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,34 @@
-require 'morph'
-
 module Rugalytics
 
   class Report
-    include Morph
+
+    include MorphLessMethodMissing
 
     attr_reader :base_url, :report_name, :start_date, :end_date
 
-    def initialize csv
+    def initialize csv=''
+      return if csv.empty?
       lines = csv.split(&quot;\n&quot;)
       set_attributes lines
       handle_graphs lines
       handle_tables lines
     end
 
+    def method_missing symbol, *args
+
+      if is_writer = symbol.to_s[/=$/]
+        morph_method_missing(symbol, *args)
+
+      elsif graph_name = symbol.to_s[/(.*)_total/,1]
+        graph = &quot;#{graph_name}_graph&quot;.to_sym
+
+        respond_to?(graph) ? send(graph).sum_of_points : super
+
+      else
+        super
+      end
+    end
+
     private
 
     def set_attributes lines</diff>
      <filename>lib/rugalytics/report.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,20 +1,30 @@
 require File.dirname(__FILE__) + '/../../spec_helper.rb'
 
-describe Rugalytics::Graph, 'when creating' do
+describe Rugalytics::Graph do
 
-  before :all do
-    @period = '1 May 2008 - 2 May 2008'
-    @name = 'Page Views'
-    @points = [5360, 4330]
-  end
+  describe 'when creating' do
+
+    before :all do
+      @period = '1 May 2008 - 3 May 2008'
+      @name = 'Page Views'
+      @points = [5360, 3330, 4330]
+    end
 
-  it &quot;it should create fields for attributes and values&quot; do
-    graph = Rugalytics::Graph.new @name, @period, @points
+    it &quot;should create fields for attributes and values&quot; do
+      graph = Rugalytics::Graph.new @name, @period, @points
 
-    graph.start_date.should == '1 May 2008'
-    graph.end_date.should == '2 May 2008'
+      graph.from.should == Date.parse('2008-05-01')
+      graph.to.should == Date.parse('2008-05-03')
+
+      graph.points.should == @points
+    end
 
-    graph.points.should == @points
   end
 
+  describe 'when counting total of points' do
+    it 'should sum points in graph' do
+      graph = Rugalytics::Graph.new '','',[5360, 3330, 4330]
+      graph.sum_of_points.should == 5360 + 3330 + 4330
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/lib/rugalytics/graph_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -34,6 +34,14 @@ describe Rugalytics::Profile do
     end
   end
 
+  describe 'finding pageviews' do
+    it 'should return total from load Pageviews report' do
+      profile = Rugalytics::Profile.new :profile_id=&gt;123
+      profile.should_receive(:load_report).with('Pageviews').and_return mock('report',:page_views_total=&gt;100)
+      profile.pageviews.should == 100
+    end
+  end
+
   it &quot;should be able to find all profiles for an account&quot; do
     html = fixture('analytics_profile_find_all.html')
     Rugalytics::Profile.should_receive(:get).and_return(html)
@@ -41,13 +49,6 @@ describe Rugalytics::Profile do
     accounts.collect(&amp;:name).should ==  [&quot;blog.your_site.com&quot;]
   end
 
-  it &quot;should be able to get pageviews&quot; do
-    profile = Rugalytics::Profile.new(:account_id =&gt; 344381, :profile_id =&gt; 543890)
-    xml = fixture('dashboard_report_webgroup.xml')
-    Rugalytics::Profile.should_receive(:get).and_return(xml)
-    profile.pageviews.should == 283
-  end
-
   it &quot;should be able to get pageviews by day&quot; do
     profile = Rugalytics::Profile.new(:account_id =&gt; 344381, :profile_id =&gt; 543890)
     xml = fixture('dashboard_report_webgroup.xml')</diff>
      <filename>spec/lib/rugalytics/profile_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -128,4 +128,13 @@ Top Content,
       end
     end
   end
+
+  describe 'when retrieving total using method not defined on class' do
+    it 'should return total from graph named in method name' do
+      report = Rugalytics::Report.new
+      report.should_receive(:respond_to?).with(:page_views_graph).and_return true
+      report.should_receive(:page_views_graph).and_return mock('graph', :sum_of_points=&gt;100)
+      report.method_missing(:page_views_total).should == 100
+    end
+  end
 end
\ No newline at end of file</diff>
      <filename>spec/lib/rugalytics/report_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bc4f6ab10860f616544c39ec2d66e5b63a160d01</id>
    </parent>
  </parents>
  <author>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </author>
  <url>http://github.com/robmckinnon/rugalytics/commit/c2feaa152f52e5fa96d4d877a05cc877f6c581be</url>
  <id>c2feaa152f52e5fa96d4d877a05cc877f6c581be</id>
  <committed-date>2008-06-04T15:41:21-07:00</committed-date>
  <authored-date>2008-06-04T15:41:21-07:00</authored-date>
  <message>reimplemented pageviews on profile - one line + dynamic madness: load_report(Pageviews).page_views_total</message>
  <tree>db556b59581df7f0e56256ba8b38d477bf3f8c8d</tree>
  <committer>
    <name>robmckinnon</name>
    <email>rob@theyworkforyou.co.nz</email>
  </committer>
</commit>
