rugalytics 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rugalytics.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+ require 'uri'
4
+ require 'ostruct'
5
+ require 'rubygems'
6
+ require 'hpricot'
7
+ require 'activesupport'
8
+ require 'google/base'
9
+ require 'morph'
10
+
11
+ # See README for usage documentation.
12
+ module Rugalytics
13
+ VERSION = "0.0.1"
14
+
15
+ FORMAT_PDF = '0' unless defined? FORMAT_PDF
16
+ FORMAT_XML = '1' unless defined? FORMAT_XML
17
+ FORMAT_CSV = '2' unless defined? FORMAT_CSV
18
+ FORMAT_TAB = '3' unless defined? FORMAT_TAB
19
+
20
+ VALID_REPORTS = %w[ Dashboard ] unless defined? VALID_REPORTS
21
+
22
+ module MorphLessMethodMissing
23
+ def self.included(base)
24
+ base.extend Morph::ClassMethods
25
+ base.send(:include, Morph::InstanceMethods)
26
+ end
27
+ end
28
+
29
+ class InvalidCredentials < Exception
30
+ end
31
+
32
+ def self.login username, password
33
+ Google::Base.establish_connection(username, password)
34
+ end
35
+
36
+ def self.find_profile account_id_or_name, profile_id_or_name=nil
37
+ begin
38
+ Profile.find account_id_or_name, profile_id_or_name
39
+ rescue NameError => e
40
+ raise 'No connection - call Rugalytics.login(<username>,<password>)'
41
+ end
42
+ end
43
+ end
44
+
45
+ require File.dirname(__FILE__) + '/rugalytics/connection'
46
+ require File.dirname(__FILE__) + '/rugalytics/account'
47
+ require File.dirname(__FILE__) + '/rugalytics/profile'
48
+ require File.dirname(__FILE__) + '/rugalytics/report'
49
+ require File.dirname(__FILE__) + '/rugalytics/item'
50
+ require File.dirname(__FILE__) + '/rugalytics/graph'
@@ -0,0 +1,57 @@
1
+
2
+ # Gem::Specification for Rugalytics-0.0.1
3
+ # Originally generated by Echoe
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{rugalytics}
7
+ s.version = "0.0.1"
8
+
9
+ s.specification_version = 2 if s.respond_to? :specification_version=
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Rob McKinnon"]
13
+ s.date = %q{2008-06-06}
14
+ s.description = %q{Rugalytics is a Ruby API for Google Analytics.}
15
+ s.email = ["rob ~@nospam@~ rubyforge.org"]
16
+ s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README"]
17
+ s.files = ["CHANGELOG", "lib/rugalytics/account.rb", "lib/rugalytics/analytics.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", "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"]
18
+ s.has_rdoc = true
19
+ s.homepage = %q{}
20
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rugalytics", "--main", "README", "--inline-source"]
21
+ s.require_paths = ["lib"]
22
+ s.rubyforge_project = %q{rugalytics}
23
+ s.rubygems_version = %q{1.1.0}
24
+ s.summary = %q{Rugalytics is a Ruby API for Google Analytics.}
25
+
26
+ s.add_dependency(%q<hpricot>, [">= 0.6"])
27
+ s.add_dependency(%q<activesupport>, [">= 2.0.2"])
28
+ s.add_dependency(%q<googlebase>, [">= 0.2.0"])
29
+ s.add_dependency(%q<morph>, [">= 0.1.5"])
30
+ end
31
+
32
+
33
+ # # Original Rakefile source (requires the Echoe gem):
34
+ #
35
+ # require 'rubygems'; require 'spec'; require 'lib/rugalytics'
36
+ #
37
+ # begin
38
+ # require 'echoe'
39
+ #
40
+ # Echoe.new("rugalytics", Rugalytics::VERSION) do |m|
41
+ # m.author = ["Rob McKinnon"]
42
+ # m.email = ["rob ~@nospam@~ rubyforge.org"]
43
+ # m.description = File.readlines("README").first
44
+ # m.rubyforge_name = "rugalytics"
45
+ # m.rdoc_options << '--inline-source'
46
+ # m.rdoc_pattern = ["README", "CHANGELOG", "LICENSE"]
47
+ # m.dependencies = ["hpricot >=0.6", "activesupport >=2.0.2", "googlebase >=0.2.0", "morph >=0.1.5"]
48
+ # end
49
+ #
50
+ # rescue LoadError
51
+ # puts "You need to install the echoe gem to perform meta operations on this gem"
52
+ # end
53
+ #
54
+ # desc "Open an irb session preloaded with this library"
55
+ # task :console do
56
+ # sh "irb -rubygems -r ./lib/rugalytics.rb"
57
+ # end
@@ -0,0 +1,296 @@
1
+ <html>
2
+ <head>
3
+ <title>Google Analytics</title>
4
+ <meta http-equiv="Expires" content="now" />
5
+ <meta http-equiv="pragma" content="no-cache" />
6
+ <meta http-equiv="cache-control" content="no-cache" />
7
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
+ <script src="https://ssl.google-analytics.com/ga.js" type="text/javascript">
9
+ </script>
10
+ <script type="text/javascript">
11
+ var pageTracker = _gat._getTracker("UA-10005-1");
12
+ pageTracker._setCookiePath("/analytics/");
13
+ pageTracker._initData();
14
+ pageTracker._trackPageview();
15
+ </script>
16
+
17
+ <script src="ujs/ugen.js"></script>
18
+ <script src="ujs/admin.js"></script>
19
+
20
+ <body bgcolor="#FFFFFF" id="ur_body">
21
+
22
+
23
+ <link rel="stylesheet" type="text/css" href="ucss/ugen.css" />
24
+ <link rel="stylesheet" type="text/css" href="ucss/ureport.css" />
25
+ <table cellpadding="0" width="100%" cellspacing="0" border="0">
26
+ <tr valign="middle">
27
+ <td width="1%" class="uh_logo"><a href="http://www.google.com/analytics/"><img src="images/logo.gif" align="left" alt="Google" border="0" /></a></td>
28
+ <td>
29
+ <table cellpadding="0" width="100%" cellspacing="0" border="0">
30
+ <tr valign="top">
31
+ <td nowrap="nowrap" valign="middle"></td>
32
+ <td align="right" nowrap="nowrap">
33
+ <table cellpadding="0" cellspacing="0" border="0">
34
+ <tr>
35
+ <td align="right" valign="top" class="uh_prefs">
36
+ <span class="uh_user">webgroup@nd.edu </span> <span class="uh_psep">|</span>
37
+
38
+
39
+ <a href="admin?vid=1303&scid=1254221&rid=190283" class="uh_link">My Account&nbsp;</a> <span class="uh_psep">|</span>
40
+
41
+ <a href="http://www.google.com/support/googleanalytics/?hl=en_US" target="GoogleHelp" class="uh_link">Help</a> <span class="uh_psep">|</span>
42
+ <a href="http://www.google.com/support/googleanalytics/bin/request.py?hl=en_US" target="GoogleHelp" class="uh_link">Contact us</a> <span class="uh_psep">|</span>
43
+ <a href="https://www.google.com/accounts/Logout?hl=en-US&continue=http://www.google.com/analytics/home/%3Fet%3Dreset%26hl%3Den-US" class="uh_link">Sign Out</a>
44
+ </td>
45
+ </tr>
46
+ </table>
47
+ </td>
48
+ </tr>
49
+ </table>
50
+ <br/>
51
+ </td>
52
+ </tr>
53
+ </table>
54
+
55
+
56
+
57
+
58
+
59
+
60
+ <div class="topnav_section topnav_tl">
61
+ <div class="topnav_bl">
62
+ <div class="topnav_tr">
63
+ <div class="topnav_br">
64
+ <table cellpadding="0" width="100%" cellspacing="0" border="0">
65
+ <tr>
66
+ <form name="select_profile" autocomplete="off">
67
+ <td nowrap="nowrap" class="topnav_settings">
68
+
69
+
70
+
71
+
72
+
73
+
74
+ <A href="admin?scid=1254221" class="topnav_active">Analytics Home</a>
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+ <span class="topnav_sep"> | </span>
86
+
87
+ <span class="topnav_item">
88
+
89
+
90
+
91
+ <A href="javascript: goToProfile(1);" class="topnav_inactive">
92
+
93
+ View Reports:</a></span>
94
+ <select class="topnav_select" name="profile_list" onchange="goToProfile(1)">
95
+ <option value="0">Click to select Website Profile</option>
96
+
97
+ <option value="2420755" >blog.your_site.com</option>
98
+
99
+ </select>
100
+
101
+
102
+
103
+ </td>
104
+ </form>
105
+ <form name="select_account" autocomplete="off">
106
+ <td align="right" class="topnav_options">
107
+
108
+
109
+
110
+ <span class="topnav_heading">My Analytics Accounts: </span>
111
+ <select class="topnav_select2" name="account_list" onchange="goToAccount()">
112
+
113
+ <option value="1254221" >your_site.com</option>
114
+
115
+ <option value="344381" >webgroup.nd.edu</option>
116
+
117
+ <option value=""> ------------------------------- </option>
118
+ <option value="0"> Create New Account...</option>
119
+ </select>
120
+
121
+
122
+
123
+
124
+
125
+ </td>
126
+
127
+ </form>
128
+
129
+
130
+ </tr>
131
+ </table>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+
137
+
138
+
139
+ <!-- Start Main Body -->
140
+ <div class="page_body">
141
+
142
+
143
+
144
+
145
+ <div class="page_title">Analytics Home</div>
146
+ <br />
147
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
148
+ <tr>
149
+ <td valign="top" class="page_content">
150
+ <!-- Start Content -->
151
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" class="list_table">
152
+ <tr class="list_title">
153
+ <td class="list_title">Website Profiles</td>
154
+ </tr>
155
+
156
+ <tr>
157
+ <td class="list_control">
158
+
159
+ <!-- Start Controls -->
160
+ <table cellpadding="0" cellspacing="0" border="0" width="100%">
161
+ <tr>
162
+ <td align="center" nowrap="nowrap">
163
+ <span class="list_cstrong">
164
+
165
+ <img src="images/setprev.gif" border="0"> Prev
166
+
167
+ </span>
168
+
169
+ &nbsp; 1 - 1 / 1&nbsp;
170
+
171
+ <span class="list_cstrong">
172
+
173
+ Next <img src="images/setnext.gif" border="0">
174
+
175
+ </span>
176
+ </td>
177
+
178
+ <td align="center" class="list_control_cell">
179
+ <form name="length">
180
+ <table cellpadding="0" cellspacing="0" border="0">
181
+ <tr>
182
+ <td align="left" class="list_control_cell2" nowrap="nowrap">
183
+ Show
184
+ <select name="number" onChange="setLengthAdmin(self); return false;" >
185
+ <option value="5" > 5
186
+ <option value="10" selected="selected"> 10
187
+ <option value="20" > 20
188
+ <option value="35" > 35
189
+ <option value="50" > 50
190
+ <option value="100" >100
191
+ </select>&nbsp;
192
+ </td>
193
+ </form>
194
+
195
+ <form name="search" onsubmit="setQuery(); return false;">
196
+ <td class="list_control_cell2" nowrap="nowrap">
197
+ Search
198
+ <input type="text" name="uquery" value="" size="10"><input type="hidden" name="ftype" value="" /> &nbsp;
199
+ </td>
200
+ <td>
201
+ <a href="javascript:fToggle(0,'',1,1,4)">
202
+ <img src="images/fin_active.gif" name="fin" width="21" height="19" border="0"></a>
203
+ </td>
204
+ <td>
205
+ <a href="javascript:fToggle(1,'',1,1,4);">
206
+ <img src="images/fout_inactive.gif" name="fout" width="21" height="19" border="0"></a>
207
+ </td>
208
+ </tr>
209
+ </table>
210
+ </form>
211
+ </td>
212
+ </tr>
213
+ </table>
214
+
215
+
216
+ </td>
217
+ </tr>
218
+ <tr>
219
+ <td bgcolor="#FFFFFF">
220
+ <img src="images/tspace.gif" height="5" width="100">
221
+
222
+ <table border="0" cellspacing="0" cellpadding="0" width="100%">
223
+ <tr class="list_ctitle">
224
+ <td width="5%" class="list_ctitle">&nbsp;</td>
225
+ <td width="45%" class="list_ctitle" nowrap="nowrap">Name</td>
226
+ <td width="25%" class="list_ctitle" align="center" nowrap="nowrap">Settings</td>
227
+ <td width="25%" class="list_ctitle" nowrap="nowrap">Status</td>
228
+ </tr>
229
+
230
+ <tr class="ug_row1">
231
+ <td nowrap="nowrap" class="list_cell">1.</td>
232
+ <td class="list_cell">blog.your_site.com</td>
233
+ <td class="list_cell" align="center">
234
+ <a href="/analytics/reporting/dashboard?id=2420755&scid=1254221" class="normal">View Reports</a> <br />
235
+ </td>
236
+ <td class="list_cell" nowrap="nowrap">
237
+
238
+
239
+
240
+ <img src="images/check.gif"> Receiving Data
241
+
242
+
243
+ <br />
244
+
245
+ <img src="images/warning.gif">
246
+ Conversion Goals (0)
247
+ </td>
248
+ </tr>
249
+
250
+
251
+ </table>
252
+ </td>
253
+ </tr>
254
+ </table>
255
+
256
+ </td>
257
+
258
+ <td class="dotted_border">&nbsp;</td>
259
+
260
+ <!-- Start Questions -->
261
+ <td valign="top" width="200" class="page_question">
262
+ <div class="help_title">Helpful Links</div>
263
+ <ul>
264
+ <!--
265
+ <li class="question_list"><a href="" onclick="return helpPopup(27394, 'en-US', '');" class="normal">How do I view reports?</a></li>
266
+ -->
267
+ <li class="question_list"><a href="" onclick="return helpPopup(69588, 'en-US', '');" class="normal">What's new with Google Analytics?</a></li>
268
+ <li class="question_list"><a href="" onclick="return helpPopup(57053, 'en-US', '');" class="normal">I'm not seeing any data in my reports.</a></li>
269
+ <li class="question_list"><a href="" onclick="return helpPopup(55595, 'en-US', '');" class="normal">What is a website profile, and what can I do with it?</a></li>
270
+ </ul>
271
+
272
+ </td>
273
+ <!-- End Questions -->
274
+
275
+ </tr>
276
+ </table>
277
+ </div>
278
+
279
+ <!-- End Main Body -->
280
+
281
+ <br /><br />
282
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
283
+ <tr>
284
+ <td align="center" class="uf_copy">
285
+ <span class="copy">&copy; 2007 Google</span> |
286
+ <a href="http://www.google.com/analytics/" target="GoogleHome" class="normal">Analytics Home</a> |
287
+ <a href="http://www.google.com/analytics/tos.html" target="GoogleHome" class="normal">Terms of Service</a> |
288
+ <a href="http://www.google.com/intl/en/privacy.html" target="GoogleHome" class="normal">Privacy Policy</a> |
289
+ <a href="http://www.google.com/support/googleanalytics/bin/request.py?hl=en_US" target="GoogleHelp" class="normal">Contact us</a> |
290
+ <a href="http://analytics.blogspot.com/" target="GoogleBlog" class="normal">Analytics Blog&nbsp;(in English)</a>
291
+ </td>
292
+ </tr>
293
+ </table>
294
+
295
+ </body>
296
+ </html>