rugalytics 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Manifest +2 -0
- data/Rakefile +1 -0
- data/bin/rugalytics +5 -0
- data/lib/rugalytics/report.rb +6 -1
- data/lib/rugalytics/server.rb +33 -0
- data/lib/rugalytics.rb +2 -1
- data/rugalytics.gemspec +4 -2
- data/spec/lib/rugalytics/report_spec.rb +31 -18
- metadata +5 -3
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -5,11 +5,13 @@ lib/rugalytics/graph.rb
|
|
5
5
|
lib/rugalytics/item.rb
|
6
6
|
lib/rugalytics/profile.rb
|
7
7
|
lib/rugalytics/report.rb
|
8
|
+
lib/rugalytics/server.rb
|
8
9
|
lib/rugalytics.rb
|
9
10
|
LICENSE
|
10
11
|
Manifest
|
11
12
|
README
|
12
13
|
README.rdoc
|
14
|
+
bin/rugalytics
|
13
15
|
rugalytics.yml.example
|
14
16
|
spec/fixtures/analytics_account_find_all.html
|
15
17
|
spec/fixtures/analytics_profile_find_all.html
|
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
m.rdoc_options << '--inline-source'
|
12
12
|
m.rdoc_pattern = ["README", "CHANGELOG", "LICENSE"]
|
13
13
|
m.dependencies = ["hpricot >=0.6", "activesupport >=2.0.2", "googlebase >=0.2.0", "morph >=0.2.0"]
|
14
|
+
m.executable_pattern = 'bin/rugalytics'
|
14
15
|
end
|
15
16
|
|
16
17
|
rescue LoadError
|
data/bin/rugalytics
ADDED
data/lib/rugalytics/report.rb
CHANGED
@@ -44,10 +44,15 @@ module Rugalytics
|
|
44
44
|
@base_url = "#{@base_url}#{names[1].chomp('/')}" if names.size > 1 && names[1][/^\/.+$/]
|
45
45
|
@name = lines[2].chomp(',')
|
46
46
|
dates = lines[3].include?('","') ? lines[3].split('","') : lines[3].split(',')
|
47
|
+
|
47
48
|
@start_date = Rugalytics.i18n_date_parse(dates[0])
|
48
49
|
@end_date = Rugalytics.i18n_date_parse(dates[1])
|
49
50
|
end
|
50
51
|
|
52
|
+
def date_from_point date_point
|
53
|
+
date_point[/^\d\d\d\d\d\d\d\d,/] || date_point[/^".+",/] || date_point[/^[^,]+,/]
|
54
|
+
end
|
55
|
+
|
51
56
|
def handle_graphs lines
|
52
57
|
index = 5
|
53
58
|
while index < lines.size
|
@@ -61,7 +66,7 @@ module Rugalytics
|
|
61
66
|
index = index.next
|
62
67
|
|
63
68
|
points = []
|
64
|
-
while (date_point = lines[index]) && (date = date_point
|
69
|
+
while (date_point = lines[index]) && (date = date_from_point(date_point))
|
65
70
|
point = date_point.sub(date,'')
|
66
71
|
points << point.tr('",','').to_i
|
67
72
|
index = index.next
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'webrick'
|
3
|
+
include WEBrick
|
4
|
+
|
5
|
+
module Rugalytics
|
6
|
+
|
7
|
+
class Servlet < HTTPServlet::AbstractServlet
|
8
|
+
def do_GET(req, res)
|
9
|
+
res.body = "<HTML>hello, world.</HTML>"
|
10
|
+
res['Content-Type'] = "text/html"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Server
|
15
|
+
def initialize
|
16
|
+
@profile = Rugalytics.default_profile
|
17
|
+
|
18
|
+
server = HTTPServer.new :Port => 8888
|
19
|
+
|
20
|
+
server.mount("/", Rugalytics::Servlet)
|
21
|
+
|
22
|
+
server.mount_proc("/top_content_detail_keywords") {|request, response|
|
23
|
+
url = request.query['url']
|
24
|
+
report = @profile.top_content_detail_keywords_report(:url => url)
|
25
|
+
response.body = [url, report.name, report.items.to_yaml].join("\n")
|
26
|
+
response['Content-Type'] = "text/plain"
|
27
|
+
}
|
28
|
+
|
29
|
+
trap("INT"){ server.shutdown }
|
30
|
+
server.start
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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.1.
|
14
|
+
VERSION = "0.1.3"
|
15
15
|
|
16
16
|
FORMAT_PDF = '0' unless defined? FORMAT_PDF
|
17
17
|
FORMAT_XML = '1' unless defined? FORMAT_XML
|
@@ -100,5 +100,6 @@ require File.dirname(__FILE__) + '/rugalytics/profile'
|
|
100
100
|
require File.dirname(__FILE__) + '/rugalytics/report'
|
101
101
|
require File.dirname(__FILE__) + '/rugalytics/item'
|
102
102
|
require File.dirname(__FILE__) + '/rugalytics/graph'
|
103
|
+
require File.dirname(__FILE__) + '/rugalytics/server'
|
103
104
|
|
104
105
|
# Rugalytics.config_setup(RAILS_ROOT) if defined?(RAILS_ROOT) && RAILS_ROOT
|
data/rugalytics.gemspec
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rugalytics}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Rob McKinnon"]
|
9
9
|
s.date = %q{2008-11-21}
|
10
|
+
s.default_executable = %q{rugalytics}
|
10
11
|
s.description = %q{Rugalytics is a Ruby API for Google Analytics.}
|
11
12
|
s.email = ["rob ~@nospam@~ rubyforge.org"]
|
13
|
+
s.executables = ["rugalytics"]
|
12
14
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README"]
|
13
|
-
s.files = ["CHANGELOG", "lib/rugalytics/account.rb", "lib/rugalytics/connection.rb", "lib/rugalytics/graph.rb", "lib/rugalytics/item.rb", "lib/rugalytics/profile.rb", "lib/rugalytics/report.rb", "lib/rugalytics.rb", "LICENSE", "Manifest", "README", "README.rdoc", "rugalytics.yml.example", "spec/fixtures/analytics_account_find_all.html", "spec/fixtures/analytics_profile_find_all.html", "spec/fixtures/dashboard_report_webgroup.xml", "spec/lib/rugalytics/account_spec.rb", "spec/lib/rugalytics/graph_spec.rb", "spec/lib/rugalytics/item_spec.rb", "spec/lib/rugalytics/profile_spec.rb", "spec/lib/rugalytics/report_spec.rb", "spec/lib/rugalytics_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "rugalytics.gemspec", "Rakefile"]
|
15
|
+
s.files = ["CHANGELOG", "lib/rugalytics/account.rb", "lib/rugalytics/connection.rb", "lib/rugalytics/graph.rb", "lib/rugalytics/item.rb", "lib/rugalytics/profile.rb", "lib/rugalytics/report.rb", "lib/rugalytics/server.rb", "lib/rugalytics.rb", "LICENSE", "Manifest", "README", "README.rdoc", "bin/rugalytics", "rugalytics.yml.example", "spec/fixtures/analytics_account_find_all.html", "spec/fixtures/analytics_profile_find_all.html", "spec/fixtures/dashboard_report_webgroup.xml", "spec/lib/rugalytics/account_spec.rb", "spec/lib/rugalytics/graph_spec.rb", "spec/lib/rugalytics/item_spec.rb", "spec/lib/rugalytics/profile_spec.rb", "spec/lib/rugalytics/report_spec.rb", "spec/lib/rugalytics_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "rugalytics.gemspec", "Rakefile"]
|
14
16
|
s.has_rdoc = true
|
15
17
|
s.homepage = %q{}
|
16
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rugalytics", "--main", "README", "--inline-source"]
|
@@ -167,6 +167,9 @@ describe Report do
|
|
167
167
|
describe "when creating graph points from 'Graph'" do
|
168
168
|
def graph_correct expected_start, expected_end, column_name='Page Views', graph_name=:pageviews_graph
|
169
169
|
@start_end_dates = "#{@start},#{@end}"
|
170
|
+
@point_labels=['20080828', '20080829'] unless @point_labels
|
171
|
+
@label1 = @point_labels[0]
|
172
|
+
@label2 = @point_labels[1]
|
170
173
|
@name = column_name
|
171
174
|
@column_names = "Day,#{@name}"
|
172
175
|
@csv = ['# ----------------------------------------',
|
@@ -179,8 +182,8 @@ describe Report do
|
|
179
182
|
'# Graph',
|
180
183
|
'# ----------------------------------------',
|
181
184
|
@column_names,
|
182
|
-
|
183
|
-
|
185
|
+
%Q|#{@label1},"5,360"|,
|
186
|
+
%Q|#{@label2},575|,
|
184
187
|
'# ----------------------------------------']
|
185
188
|
graph = mock('graph')
|
186
189
|
|
@@ -192,34 +195,44 @@ describe Report do
|
|
192
195
|
end
|
193
196
|
|
194
197
|
describe 'with source date format "Month Day, Year"' do
|
195
|
-
|
198
|
+
before do
|
196
199
|
@start = %Q|"August 28, 2008"|
|
197
200
|
@end = %Q|"August 29, 2008"|
|
201
|
+
end
|
202
|
+
it 'should create graph with data under "Graph"' do
|
198
203
|
graph_correct Date.new(2008,8,28), Date.new(2008,8,29)
|
199
204
|
end
|
205
|
+
describe 'with graph point date format "Month Day, Year"' do
|
206
|
+
it 'should create graph with data under "Graph"' do
|
207
|
+
@point_labels = [@start,@end]
|
208
|
+
graph_correct Date.new(2008,8,28), Date.new(2008,8,29)
|
209
|
+
end
|
210
|
+
end
|
200
211
|
end
|
201
212
|
|
202
213
|
describe "with source date format 'Day Month Year'" do
|
203
|
-
|
214
|
+
before do
|
204
215
|
@start = %Q|28 August 2008|
|
205
216
|
@end = %Q|29 August 2008|
|
217
|
+
end
|
218
|
+
it 'should create graph with data under "Graph"' do
|
206
219
|
graph_correct Date.parse(@start), Date.parse(@end)
|
207
220
|
end
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
@end = %Q|29 August 2008|
|
214
|
-
graph_correct Date.parse(@start), Date.parse(@end), 'Pages/Visit', :pages_per_visit_graph
|
221
|
+
describe 'with graph point date format "Day Month Year"' do
|
222
|
+
it 'should create graph with data under "Graph"' do
|
223
|
+
@point_labels = [@start, @end]
|
224
|
+
graph_correct Date.parse(@start), Date.parse(@end)
|
225
|
+
end
|
215
226
|
end
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
227
|
+
describe "with forward slash in column name" do
|
228
|
+
it 'should create graph with forward slash replaced by _per_ in column name' do
|
229
|
+
graph_correct Date.parse(@start), Date.parse(@end), 'Pages/Visit', :pages_per_visit_graph
|
230
|
+
end
|
231
|
+
end
|
232
|
+
describe "with dot in column name" do
|
233
|
+
it 'should create graph with dot removed in column name' do
|
234
|
+
graph_correct Date.parse(@start), Date.parse(@end), 'Avg. Time on Site', :avg_time_on_site_graph
|
235
|
+
end
|
223
236
|
end
|
224
237
|
end
|
225
238
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob McKinnon
|
@@ -65,8 +65,8 @@ dependencies:
|
|
65
65
|
description: Rugalytics is a Ruby API for Google Analytics.
|
66
66
|
email:
|
67
67
|
- rob ~@nospam@~ rubyforge.org
|
68
|
-
executables:
|
69
|
-
|
68
|
+
executables:
|
69
|
+
- rugalytics
|
70
70
|
extensions: []
|
71
71
|
|
72
72
|
extra_rdoc_files:
|
@@ -81,11 +81,13 @@ files:
|
|
81
81
|
- lib/rugalytics/item.rb
|
82
82
|
- lib/rugalytics/profile.rb
|
83
83
|
- lib/rugalytics/report.rb
|
84
|
+
- lib/rugalytics/server.rb
|
84
85
|
- lib/rugalytics.rb
|
85
86
|
- LICENSE
|
86
87
|
- Manifest
|
87
88
|
- README
|
88
89
|
- README.rdoc
|
90
|
+
- bin/rugalytics
|
89
91
|
- rugalytics.yml.example
|
90
92
|
- spec/fixtures/analytics_account_find_all.html
|
91
93
|
- spec/fixtures/analytics_profile_find_all.html
|