garb 0.8.2 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/garb.rb CHANGED
@@ -7,6 +7,7 @@ require 'crack'
7
7
 
8
8
  begin
9
9
  require 'active_support/inflector'
10
+ require 'active_support/deprecation'
10
11
  rescue LoadError
11
12
  require 'active_support'
12
13
  end
data/lib/garb/model.rb CHANGED
@@ -3,6 +3,10 @@ module Garb
3
3
  MONTH = 2592000
4
4
  URL = "https://www.google.com/analytics/feeds/data"
5
5
 
6
+ def self.extended(base)
7
+ ProfileReports.add_report_method(base)
8
+ end
9
+
6
10
  def metrics(*fields)
7
11
  @metrics ||= ReportParameter.new(:metrics)
8
12
  @metrics << fields
@@ -26,6 +30,8 @@ module Garb
26
30
 
27
31
  param_set = [
28
32
  default_params,
33
+ metrics.to_params,
34
+ dimensions.to_params,
29
35
  parse_filters(options).to_params,
30
36
  parse_segment(options),
31
37
  parse_sort(options).to_params,
data/lib/garb/profile.rb CHANGED
@@ -21,11 +21,12 @@ module Garb
21
21
  end
22
22
 
23
23
  def self.all(session = Session)
24
+ ActiveSupport::Deprecation.warn("Garb::Profile.all is deprecated in favor of Garb::Management::Profile.all")
24
25
  AccountFeedRequest.new(session).entries.map {|entry| new(entry, session)}
25
26
  end
26
27
 
27
- # ActiveSupport::Deprecation.warn
28
28
  def self.first(id, session = Session)
29
+ ActiveSupport::Deprecation.warn("Garb::Profile.first is deprecated in favor of Garb::Management::WebProperty")
29
30
  all(session).detect {|profile| profile.id == id || profile.web_property_id == id }
30
31
  end
31
32
  end
@@ -3,7 +3,8 @@ module Garb
3
3
  def self.add_report_method(klass)
4
4
  # demodulize leaves potential to redefine
5
5
  # these methods given different namespaces
6
- method_name = klass.to_s.demodulize.underscore
6
+ method_name = klass.name.demodulize.underscore
7
+ return unless method_name.length > 0
7
8
 
8
9
  class_eval <<-CODE
9
10
  def #{method_name}(opts = {}, &block)
data/lib/garb/report.rb CHANGED
@@ -6,7 +6,7 @@ module Garb
6
6
  URL = "https://www.google.com/analytics/feeds/data"
7
7
 
8
8
  def initialize(profile, opts={})
9
- # ActiveSupport::Deprecation.warn("The use of report will be removed in favor of extend Garb::Scheme")
9
+ ActiveSupport::Deprecation.warn("The use of Report will be removed in favor of 'extend Garb::Model'")
10
10
 
11
11
  @profile = profile
12
12
 
data/lib/garb/resource.rb CHANGED
@@ -9,6 +9,8 @@ module Garb
9
9
  # to enable profile.exits(options_hash, &block)
10
10
  # returns Exits.results(self, options_hash, &block)
11
11
  # every class defined which extends Resource will add to the module
12
+
13
+ # ActiveSupport::Deprecation.warn
12
14
  ProfileReports.add_report_method(base)
13
15
  end
14
16
 
data/lib/garb/version.rb CHANGED
@@ -3,7 +3,7 @@ module Garb
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 8
6
- TINY = 2
6
+ TINY = 3
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -60,12 +60,17 @@ module Garb
60
60
  DataRequest.stubs(:new).returns(stub(:send_request => @response))
61
61
  ReportResponse.stubs(:new).returns(stub(:results => ['result']))
62
62
 
63
+ @test_model.stubs(:metrics).returns(stub(:to_params => {'metrics' => 'ga:visits'}))
64
+ @test_model.stubs(:dimensions).returns(stub(:to_params => {'dimensions' => 'ga:pagePath'}))
65
+
63
66
  now = Time.now
64
67
  Time.stubs(:new).returns(now)
65
68
 
66
69
  @params = {'ids' => Garb.to_ga(@profile.id),
67
70
  'start-date' => (now - Model::MONTH).strftime('%Y-%m-%d'),
68
- 'end-date' => now.strftime('%Y-%m-%d')}
71
+ 'end-date' => now.strftime('%Y-%m-%d'),
72
+ 'metrics' => 'ga:visits',
73
+ 'dimensions' => 'ga:pagePath'}
69
74
  end
70
75
 
71
76
  should "get all results" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 2
10
- version: 0.8.2
9
+ - 3
10
+ version: 0.8.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Pitale