Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: Fosome/garb
base: master
...
head fork: scudco/garb
compare: master
Checking mergeability… Don't worry, you can still create the pull request.
  • 10 commits
  • 28 files changed
  • 0 commit comments
  • 2 contributors
Showing with 48 additions and 61 deletions.
  1. +3 −3 README.md
  2. +1 −2  Rakefile
  3. +1 −1  garb.gemspec
  4. +1 −3 lib/garb.rb
  5. +1 −15 lib/garb/account.rb
  6. +4 −4 lib/garb/report_parameter.rb
  7. +5 −5 lib/garb/reports.rb
  8. +1 −1  lib/garb/reports/bounces.rb
  9. +1 −1  lib/garb/reports/exits.rb
  10. +1 −1  lib/garb/reports/pageviews.rb
  11. +1 −1  lib/garb/reports/unique_pageviews.rb
  12. +2 −2 lib/garb/reports/visits.rb
  13. 0  lib/{ → garb}/support.rb
  14. +7 −3 test/test_helper.rb
  15. +1 −1  test/unit/garb/account_test.rb
  16. +2 −2 test/unit/garb/authentication_request_test.rb
  17. +1 −1  test/unit/garb/data_request_test.rb
  18. +1 −1  test/unit/garb/filter_parameters_test.rb
  19. +2 −2 test/unit/garb/oauth_session_test.rb
  20. +1 −1  test/unit/garb/profile_reports_test.rb
  21. +2 −2 test/unit/garb/profile_test.rb
  22. +2 −2 test/unit/garb/report_parameter_test.rb
  23. +1 −1  test/unit/garb/report_response_test.rb
  24. +2 −2 test/unit/garb/report_test.rb
  25. +1 −1  test/unit/garb/resource_test.rb
  26. +1 −1  test/unit/garb/session_test.rb
  27. +1 −1  test/unit/garb_test.rb
  28. +1 −1  test/unit/symbol_operator_test.rb
View
6 README.md
@@ -36,7 +36,7 @@ Accounts
Profiles
--------
- > Garb::Account.first.profiles
+ > Garb::Account.all.first.profiles
> Garb::Profile.first('UA-XXXX-XX')
@@ -58,7 +58,7 @@ Define a Report Class
end
# alternative:
- # filters :page_path.eql => 10
+ # filters :page_path.eql => 'season'
end
Get the Results
@@ -132,7 +132,7 @@ Build a One-Off Report
and
# or with a hash
- # report.filters :page_path.contains => 'season', :exits.gt => 100
+ # report.filters :page_path.contains => 'season', :exits.gt => 10
report.results
View
3  Rakefile
@@ -1,8 +1,7 @@
-require 'rubygems'
require 'rake/gempackagetask'
require 'rake/testtask'
-require 'lib/garb/version'
+require File.expand_path('../lib/garb/version', __FILE__)
task :default => :test
View
2  garb.gemspec
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
s.authors = ["Tony Pitale"]
s.date = %q{2010-02-16}
s.email = %q{tony.pitale@viget.com}
- s.files = ["README.md", "Rakefile", "lib/garb", "lib/garb/account.rb", "lib/garb/authentication_request.rb", "lib/garb/data_request.rb", "lib/garb/filter_parameters.rb", "lib/garb/profile.rb", "lib/garb/profile_reports.rb", "lib/garb/report.rb", "lib/garb/report_parameter.rb", "lib/garb/report_response.rb", "lib/garb/reports", "lib/garb/reports/bounces.rb", "lib/garb/reports/exits.rb", "lib/garb/reports/pageviews.rb", "lib/garb/reports/unique_pageviews.rb", "lib/garb/reports/visits.rb", "lib/garb/reports.rb", "lib/garb/resource.rb", "lib/garb/session.rb", "lib/garb/version.rb", "lib/garb.rb", "lib/support.rb", "test/fixtures", "test/fixtures/cacert.pem", "test/fixtures/profile_feed.xml", "test/fixtures/report_feed.xml", "test/test_helper.rb", "test/unit", "test/unit/garb", "test/unit/garb/account_test.rb", "test/unit/garb/authentication_request_test.rb", "test/unit/garb/data_request_test.rb", "test/unit/garb/filter_parameters_test.rb", "test/unit/garb/oauth_session_test.rb", "test/unit/garb/profile_reports_test.rb", "test/unit/garb/profile_test.rb", "test/unit/garb/report_parameter_test.rb", "test/unit/garb/report_response_test.rb", "test/unit/garb/report_test.rb", "test/unit/garb/resource_test.rb", "test/unit/garb/session_test.rb", "test/unit/garb_test.rb", "test/unit/symbol_operator_test.rb"]
+ s.files = ["README.md", "Rakefile", "lib/garb", "lib/garb/account.rb", "lib/garb/authentication_request.rb", "lib/garb/data_request.rb", "lib/garb/filter_parameters.rb", "lib/garb/profile.rb", "lib/garb/profile_reports.rb", "lib/garb/report.rb", "lib/garb/report_parameter.rb", "lib/garb/report_response.rb", "lib/garb/reports", "lib/garb/reports/bounces.rb", "lib/garb/reports/exits.rb", "lib/garb/reports/pageviews.rb", "lib/garb/reports/unique_pageviews.rb", "lib/garb/reports/visits.rb", "lib/garb/reports.rb", "lib/garb/resource.rb", "lib/garb/session.rb", "lib/garb/version.rb", "lib/garb.rb", "lib/garb/support.rb", "test/fixtures", "test/fixtures/cacert.pem", "test/fixtures/profile_feed.xml", "test/fixtures/report_feed.xml", "test/test_helper.rb", "test/unit", "test/unit/garb", "test/unit/garb/account_test.rb", "test/unit/garb/authentication_request_test.rb", "test/unit/garb/data_request_test.rb", "test/unit/garb/filter_parameters_test.rb", "test/unit/garb/oauth_session_test.rb", "test/unit/garb/profile_reports_test.rb", "test/unit/garb/profile_test.rb", "test/unit/garb/report_parameter_test.rb", "test/unit/garb/report_response_test.rb", "test/unit/garb/report_test.rb", "test/unit/garb/resource_test.rb", "test/unit/garb/session_test.rb", "test/unit/garb_test.rb", "test/unit/symbol_operator_test.rb"]
s.has_rdoc = false
s.homepage = %q{http://github.com/vigetlabs/garb}
s.require_paths = ["lib"]
View
4 lib/garb.rb
@@ -1,5 +1,3 @@
-$:.unshift File.expand_path(File.dirname(__FILE__))
-
require 'net/http'
require 'net/https'
@@ -21,7 +19,7 @@
require 'garb/resource'
require 'garb/report'
-require 'support'
+require 'garb/support'
module Garb
GA = "http://schemas.google.com/analytics/2008"
View
16 lib/garb/account.rb
@@ -9,21 +9,7 @@ def initialize(profiles)
end
def self.all(session = Session)
- # Profile.all.group_to_array{|p| p.account_id}.map{|profiles| new(profiles)}
-
- profile_groups = Profile.all(session).inject({}) do |hash, profile|
- key = profile.account_id
-
- if hash.has_key?(key)
- hash[key] << profile
- else
- hash[key] = [profile]
- end
-
- hash
- end
-
- profile_groups.map {|k,v| v}.map {|profiles| new(profiles)}
+ Profile.all(session).group_by(&:account_id).map { |id, profiles| new profiles }
end
end
end
View
8 lib/garb/report_parameter.rb
@@ -2,21 +2,21 @@ module Garb
class ReportParameter
attr_reader :elements
-
+
def initialize(name)
@name = name
@elements = []
end
-
+
def name
@name.to_s
end
-
+
def <<(element)
(@elements += [element].flatten).compact!
self
end
-
+
def to_params
value = self.elements.map{|param| Garb.to_google_analytics(param)}.join(',')
value.empty? ? {} : {self.name => value}
View
10 lib/garb/reports.rb
@@ -1,5 +1,5 @@
-require 'reports/exits'
-require 'reports/visits'
-require 'reports/bounces'
-require 'reports/pageviews'
-require 'reports/unique_pageviews'
+require 'garb/reports/exits'
+require 'garb/reports/visits'
+require 'garb/reports/bounces'
+require 'garb/reports/pageviews'
+require 'garb/reports/unique_pageviews'
View
2  lib/garb/reports/bounces.rb
@@ -1,5 +1,5 @@
class Bounces
extend Garb::Resource
- metric :bounces
+ metrics :bounces
end
View
2  lib/garb/reports/exits.rb
@@ -1,5 +1,5 @@
class Exits
extend Garb::Resource
- metric :exits
+ metrics :exits
end
View
2  lib/garb/reports/pageviews.rb
@@ -1,5 +1,5 @@
class Pageviews
extend Garb::Resource
- metric :pageviews
+ metrics :pageviews
end
View
2  lib/garb/reports/unique_pageviews.rb
@@ -1,5 +1,5 @@
class UniquePageviews
extend Garb::Resource
- metric :unique_pageviews
+ metrics :unique_pageviews
end
View
4 lib/garb/reports/visits.rb
@@ -1,5 +1,5 @@
class Visits
extend Garb::Resource
- metric :visits
-end
+ metrics :visits
+end
View
0  lib/support.rb → lib/garb/support.rb
File renamed without changes
View
10 test/test_helper.rb
@@ -2,17 +2,21 @@
require 'rubygems'
require 'minitest/unit'
+gem 'tpitale-shoulda'
+gem 'jferris-mocha'
require 'shoulda'
require 'mocha'
+require 'activesupport'
-require File.dirname(__FILE__) + '/../lib/garb'
+$:.unshift File.expand_path('../../lib', __FILE__)
+require 'garb'
class MiniTest::Unit::TestCase
def read_fixture(filename)
File.read(File.dirname(__FILE__) + "/fixtures/#{filename}")
end
-
+
end
-MiniTest::Unit.autorun
+MiniTest::Unit.autorun
View
2  test/unit/garb/account_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class AccountTest < MiniTest::Unit::TestCase
View
4 test/unit/garb/authentication_request_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
CA_CERT_FILE = File.join(File.dirname(__FILE__), '..', '/cacert.pem')
@@ -118,4 +118,4 @@ class AuthenticationRequestTest < MiniTest::Unit::TestCase
end
-end
+end
View
2  test/unit/garb/data_request_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class DataRequestTest < MiniTest::Unit::TestCase
View
2  test/unit/garb/filter_parameters_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class FilterParametersTest < MiniTest::Unit::TestCase
View
4 test/unit/garb/oauth_session_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class OAuthSessionTest < MiniTest::Unit::TestCase
@@ -8,4 +8,4 @@ class OAuthSessionTest < MiniTest::Unit::TestCase
end
end
end
-end
+end
View
2  test/unit/garb/profile_reports_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
View
4 test/unit/garb/profile_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class ProfileTest < MiniTest::Unit::TestCase
@@ -84,4 +84,4 @@ class ProfileTest < MiniTest::Unit::TestCase
end
end
-end
+end
View
4 test/unit/garb/report_parameter_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class ReportParameterTest < MiniTest::Unit::TestCase
@@ -40,4 +40,4 @@ class ReportParameterTest < MiniTest::Unit::TestCase
end
end
-end
+end
View
2  test/unit/garb/report_response_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class ReportResponseTest < MiniTest::Unit::TestCase
View
4 test/unit/garb/report_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
# Also tests Garb::Resource, which is the basis for Garb::Report
@@ -88,4 +88,4 @@ class ReportTest < MiniTest::Unit::TestCase
end
end
-end
+end
View
2  test/unit/garb/resource_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
class TestReport
extend Garb::Resource
View
2  test/unit/garb/session_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class SessionTest < MiniTest::Unit::TestCase
View
2  test/unit/garb_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '/test_helper')
+require 'test_helper'
class GarbTest < MiniTest::Unit::TestCase
context "The Garb module" do
View
2  test/unit/symbol_operator_test.rb
@@ -1,4 +1,4 @@
-require File.join(File.dirname(__FILE__), '..', '/test_helper')
+require 'test_helper'
class SymbolOperatorTest < MiniTest::Unit::TestCase
context "An instance of a SymbolOperator" do

No commit comments for this range

Something went wrong with that request. Please try again.