rugalytics 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.1.0. fixed bug due to change in google's graph csv; removed deprecated load_report method
2
+
1
3
  v0.0.9. allowed setting of :url and :page_title options for drilldown and content reports; merged masolino's changes
2
4
 
3
5
  v0.0.8. moved i18n date parse method to Rugalytics module
data/README CHANGED
@@ -3,7 +3,9 @@ Rugalytics is a Ruby API for Google Analytics.
3
3
  = Warning - API under development
4
4
 
5
5
  The Rugalytics API is in early development so it may change slightly over time.
6
- It should be in working order, so please give it a test spin!
6
+ It should be in working order, so please give it a test spin! Sometimes
7
+ Google changes it's CSV export format, which can break Rugalytics. It's usually
8
+ fixed within a week of such occurrences.
7
9
 
8
10
  The source code is hosted at github. Feel free to fork the code if you have
9
11
  something to contribute:
data/README.rdoc CHANGED
@@ -3,7 +3,9 @@ Rugalytics is a Ruby API for Google Analytics.
3
3
  = Warning - API under development
4
4
 
5
5
  The Rugalytics API is in early development so it may change slightly over time.
6
- It should be in working order, so please give it a test spin!
6
+ It should be in working order, so please give it a test spin! Sometimes
7
+ Google changes it's CSV export format, which can break Rugalytics. It's usually
8
+ fixed within a week of such occurrences.
7
9
 
8
10
  The source code is hosted at github. Feel free to fork the code if you have
9
11
  something to contribute:
@@ -3,11 +3,11 @@ module Rugalytics
3
3
 
4
4
  attr_reader :name, :points, :points_by_day, :from, :to
5
5
 
6
- def initialize name, graph_period, points, report_start, report_end
6
+ def initialize name, points, report_start, report_end
7
7
  @name = name
8
8
  @from = report_start
9
9
  @to = report_end
10
- @points_by_day = create_points_by_day points, graph_period, report_start, report_end
10
+ @points_by_day = create_points_by_day points, report_start, report_end
11
11
  @points = points_by_day.collect{|by_day| by_day[1]}
12
12
  end
13
13
 
@@ -17,16 +17,15 @@ module Rugalytics
17
17
 
18
18
  private
19
19
 
20
- def create_points_by_day points, graph_period, report_start, report_end
21
- with_dates_from_period(graph_period, []) do |date, index, list|
20
+ def create_points_by_day points, report_start, report_end
21
+ with_dates_from_period(report_start, report_end, []) do |date, index, list|
22
22
  list << [date, points[index] ] if date >= report_start && date <= report_end
23
23
  end
24
24
  end
25
25
 
26
- def with_dates_from_period period, list
27
- dates = period.split('-')
28
- from = Rugalytics.i18n_date_parse(dates[0].strip)
29
- to = Rugalytics.i18n_date_parse(dates[1].strip)
26
+ def with_dates_from_period report_start, report_end, list
27
+ from = report_start
28
+ to = report_end
30
29
 
31
30
  index = 0
32
31
  from.upto(to) do |date|
@@ -36,15 +36,6 @@ module Rugalytics
36
36
  end
37
37
  end
38
38
 
39
- def load_report(name, options={})
40
- if options=={}
41
- ActiveSupport::Deprecation.warn "Profile#load_report('#{name}') has been deprecated, use Profile##{name.tableize}_report instead"
42
- else
43
- ActiveSupport::Deprecation.warn "Profile#load_report('#{name}',options) has been deprecated, use Profile##{name.tableize}_report(options) instead"
44
- end
45
- create_report(name, options={})
46
- end
47
-
48
39
  def get_report_csv(options={})
49
40
  options = set_default_options(options)
50
41
  params = convert_options_to_uri_params(options)
@@ -36,11 +36,6 @@ module Rugalytics
36
36
  end
37
37
  end
38
38
 
39
- def report_name
40
- ActiveSupport::Deprecation.warn "Report#report_name has been deprecated, use Report#name instead"
41
- name
42
- end
43
-
44
39
  private
45
40
 
46
41
  def set_attributes lines
@@ -61,18 +56,18 @@ module Rugalytics
61
56
  return if index == lines.size
62
57
  end
63
58
  index = index + 2
64
- graph_period = lines[index]
65
- index = index.next
66
- name = lines[index]
59
+ column_names = lines[index]
60
+ name = column_names.split(',').last
67
61
  index = index.next
68
62
 
69
63
  points = []
70
- while (point = lines[index]) && point.strip.size > 0
64
+ while (date_point = lines[index]) && (date = date_point[/^\d\d\d\d\d\d\d\d,/])
65
+ point = date_point.sub(date,'')
71
66
  points << point.tr('",','').to_i
72
67
  index = index.next
73
68
  end
74
69
 
75
- graph = Graph.new name, graph_period, points, start_date, end_date
70
+ graph = Graph.new name, points, start_date, end_date
76
71
  morph("#{name.sub(/page views/i,'pageviews')} graph", graph)
77
72
  end
78
73
  end
data/lib/rugalytics.rb CHANGED
@@ -11,7 +11,7 @@ require 'yaml'
11
11
 
12
12
  # See README for usage documentation.
13
13
  module Rugalytics
14
- VERSION = "0.0.9"
14
+ VERSION = "0.1.0"
15
15
 
16
16
  FORMAT_PDF = '0' unless defined? FORMAT_PDF
17
17
  FORMAT_XML = '1' unless defined? FORMAT_XML
data/rugalytics.gemspec CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Rugalytics-0.0.9
2
+ # Gem::Specification for Rugalytics-0.1.0
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: rugalytics
7
7
  version: !ruby/object:Gem::Version
8
- version: 0.0.9
8
+ version: 0.1.0
9
9
  platform: ruby
10
10
  authors:
11
11
  - Rob McKinnon
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-08-08 00:00:00 +01:00
15
+ date: 2008-08-30 00:00:00 +01:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -3,7 +3,7 @@ include Rugalytics
3
3
 
4
4
  shared_examples_for "graph created correctly" do
5
5
  def graph_correct_for report_start, report_end, expected_points
6
- graph = Graph.new 'Page Views', @period, @points, report_start, report_end
6
+ graph = Graph.new 'Page Views', @points, report_start, report_end
7
7
  graph.from.should == report_start
8
8
  graph.to.should == report_end
9
9
  graph.points.should == expected_points
@@ -14,14 +14,6 @@ shared_examples_for "graph created correctly" do
14
14
  graph_correct_for Date.parse('2008-05-01'), Date.parse('2008-05-03'), @points
15
15
  end
16
16
 
17
- it "should set appropriate point on graph when report start and end is the same date" do
18
- graph_correct_for Date.parse('2008-05-01'), Date.parse('2008-05-01'), [@points[0]]
19
- end
20
-
21
- it "should set appropriate points on graph when report start and end is a subset of the graph period" do
22
- graph_correct_for Date.parse('2008-05-02'), Date.parse('2008-05-03'), [@points[1],@points[2]]
23
- end
24
-
25
17
  it 'should set points by day' do
26
18
  from = Date.parse('1 May 2008')
27
19
  to = Date.parse('3 May 2008')
@@ -40,7 +32,6 @@ describe Graph do
40
32
 
41
33
  describe 'when creating with dates formatted Day Month Year' do
42
34
  before :all do
43
- @period = '1 May 2008 - 3 May 2008'
44
35
  @points = [5360, 3330, 4330]
45
36
  end
46
37
 
@@ -49,7 +40,6 @@ describe Graph do
49
40
 
50
41
  describe 'when creating with dates formatted "Month Day, Year"' do
51
42
  before :all do
52
- @period = %Q|"May 1, 2008 - May 3, 2008"|
53
43
  @points = [5360, 3330, 4330]
54
44
  end
55
45
 
@@ -20,7 +20,6 @@ describe Report do
20
20
  end
21
21
 
22
22
  it "should set report name from third line of text" do
23
- @report.report_name.should == 'Top Content'
24
23
  @report.name.should == 'Top Content'
25
24
  end
26
25
 
@@ -45,7 +44,6 @@ describe Report do
45
44
  @report.base_url.should == 'your_site.com/portfolios/health'
46
45
  end
47
46
  it 'should set report name including path' do
48
- @report.report_name.should == 'Content Drilldown,/portfolios/health/'
49
47
  @report.name.should == 'Content Drilldown,/portfolios/health/'
50
48
  end
51
49
  end
@@ -170,6 +168,7 @@ describe Report do
170
168
  def graph_correct expected_start, expected_end
171
169
  @start_end_dates = "#{@start},#{@end}"
172
170
  @name = %Q|Page Views|
171
+ @column_names = "Day,#{@name}"
173
172
  @csv = ['# ----------------------------------------',
174
173
  'your_site.com',
175
174
  'Top Content,',
@@ -179,12 +178,13 @@ describe Report do
179
178
  '# ----------------------------------------',
180
179
  '# Graph',
181
180
  '# ----------------------------------------',
182
- @period,
183
- @name,
184
- '"5,360"',
185
- '433']
181
+ @column_names,
182
+ '20080828,"5,360"',
183
+ '20080829,575',
184
+ '# ----------------------------------------']
186
185
  graph = mock('graph')
187
- Graph.should_receive(:new).with(@name, @period, [5360, 433], expected_start, expected_end).and_return graph
186
+
187
+ Graph.should_receive(:new).with(@name, [5360, 575], expected_start, expected_end).and_return graph
188
188
 
189
189
  report = Report.new(@csv.join("\n"))
190
190
  report.pageviews_graph.should == graph
@@ -193,18 +193,16 @@ describe Report do
193
193
 
194
194
  describe 'with source date format "Month Day, Year"' do
195
195
  it 'should create graph with data under "Graph"' do
196
- @start = %Q|"July 5, 2008"|
197
- @end = %Q|"August 4, 2008"|
198
- @period = %Q|"July 5, 2008 - August 4, 2008"|
199
- graph_correct Date.new(2008,7,5), Date.new(2008,8,4)
196
+ @start = %Q|"August 28, 2008"|
197
+ @end = %Q|"August 29, 2008"|
198
+ graph_correct Date.new(2008,8,28), Date.new(2008,8,29)
200
199
  end
201
200
  end
202
201
 
203
202
  describe "with source date format 'Day Month Year'" do
204
203
  it 'should create graph with data under "Graph"' do
205
- @start = %Q|26 May 2008|
206
- @end = %Q|31 May 2008|
207
- @period = %Q|1 May 2008 - 31 May 2008|
204
+ @start = %Q|28 August 2008|
205
+ @end = %Q|29 August 2008|
208
206
  graph_correct Date.parse(@start), Date.parse(@end)
209
207
  end
210
208
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugalytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob McKinnon
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-08 00:00:00 +01:00
12
+ date: 2008-08-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency