garb 0.8.5 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/README.md +27 -87
  2. data/lib/garb.rb +2 -0
  3. data/lib/garb/account.rb +1 -0
  4. data/lib/garb/account_feed_request.rb +2 -2
  5. data/lib/garb/destination.rb +3 -5
  6. data/lib/garb/management/account.rb +7 -4
  7. data/lib/garb/management/feed.rb +1 -1
  8. data/lib/garb/management/goal.rb +36 -12
  9. data/lib/garb/management/profile.rb +3 -4
  10. data/lib/garb/management/segment.rb +27 -0
  11. data/lib/garb/management/web_property.rb +4 -0
  12. data/lib/garb/resource.rb +1 -1
  13. data/lib/garb/version.rb +2 -2
  14. data/test/test_helper.rb +9 -1
  15. data/test/unit/garb/account_feed_request_test.rb +34 -1
  16. data/test/unit/garb/coverage/assets/0.3.9/app.js +66 -0
  17. data/test/unit/garb/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
  18. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
  19. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
  20. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
  21. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
  22. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
  23. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
  24. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
  25. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
  26. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
  27. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
  28. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
  29. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
  30. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
  31. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
  32. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
  33. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
  34. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
  35. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
  36. data/test/unit/garb/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
  37. data/test/unit/garb/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +363 -0
  38. data/test/unit/garb/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  39. data/test/unit/garb/coverage/assets/0.3.9/favicon.png +0 -0
  40. data/test/unit/garb/coverage/assets/0.3.9/jquery-1.4.2.min.js +155 -0
  41. data/test/unit/garb/coverage/assets/0.3.9/jquery.dataTables.min.js +152 -0
  42. data/test/unit/garb/coverage/assets/0.3.9/jquery.timeago.js +141 -0
  43. data/test/unit/garb/coverage/assets/0.3.9/jquery.url.js +174 -0
  44. data/test/unit/garb/coverage/assets/0.3.9/loading.gif +0 -0
  45. data/test/unit/garb/coverage/assets/0.3.9/magnify.png +0 -0
  46. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  47. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  48. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  49. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  50. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  51. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  52. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  53. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  54. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
  55. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  56. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
  57. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
  58. data/test/unit/garb/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  59. data/test/unit/garb/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  60. data/test/unit/garb/coverage/assets/0.3.9/stylesheet.css +341 -0
  61. data/test/unit/garb/coverage/index.html +100 -0
  62. data/test/unit/garb/coverage/resultset.yml +5 -0
  63. data/test/unit/garb/management/account_test.rb +17 -1
  64. data/test/unit/garb/management/coverage/assets/0.3.9/app.js +66 -0
  65. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/blank.gif +0 -0
  66. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_close.png +0 -0
  67. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_loading.png +0 -0
  68. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_nav_left.png +0 -0
  69. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_nav_right.png +0 -0
  70. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_e.png +0 -0
  71. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_n.png +0 -0
  72. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_ne.png +0 -0
  73. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_nw.png +0 -0
  74. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_s.png +0 -0
  75. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_se.png +0 -0
  76. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_sw.png +0 -0
  77. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_shadow_w.png +0 -0
  78. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_left.png +0 -0
  79. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_main.png +0 -0
  80. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_over.png +0 -0
  81. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancy_title_right.png +0 -0
  82. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox-x.png +0 -0
  83. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox-y.png +0 -0
  84. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/fancybox.png +0 -0
  85. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.css +363 -0
  86. data/test/unit/garb/management/coverage/assets/0.3.9/fancybox/jquery.fancybox-1.3.1.pack.js +44 -0
  87. data/test/unit/garb/management/coverage/assets/0.3.9/favicon.png +0 -0
  88. data/test/unit/garb/management/coverage/assets/0.3.9/jquery-1.4.2.min.js +155 -0
  89. data/test/unit/garb/management/coverage/assets/0.3.9/jquery.dataTables.min.js +152 -0
  90. data/test/unit/garb/management/coverage/assets/0.3.9/jquery.timeago.js +141 -0
  91. data/test/unit/garb/management/coverage/assets/0.3.9/jquery.url.js +174 -0
  92. data/test/unit/garb/management/coverage/assets/0.3.9/loading.gif +0 -0
  93. data/test/unit/garb/management/coverage/assets/0.3.9/magnify.png +0 -0
  94. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  95. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  96. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  97. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  98. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  99. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  100. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  101. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  102. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_222222_256x240.png +0 -0
  103. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  104. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_454545_256x240.png +0 -0
  105. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_888888_256x240.png +0 -0
  106. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  107. data/test/unit/garb/management/coverage/assets/0.3.9/smoothness/jquery-ui-1.8.4.custom.css +295 -0
  108. data/test/unit/garb/management/coverage/assets/0.3.9/stylesheet.css +341 -0
  109. data/test/unit/garb/management/coverage/index.html +100 -0
  110. data/test/unit/garb/management/coverage/resultset.yml +5 -0
  111. data/test/unit/garb/management/feed_test.rb +39 -0
  112. data/test/unit/garb/management/goal_test.rb +81 -0
  113. data/test/unit/garb/management/profile_test.rb +26 -4
  114. data/test/unit/garb/management/segment_test.rb +47 -0
  115. data/test/unit/garb/management/web_property_test.rb +6 -0
  116. metadata +199 -4
data/README.md CHANGED
@@ -6,12 +6,14 @@ Garb
6
6
  Important Changes
7
7
  =================
8
8
 
9
- I've started to work on a new module for reporting. You can see that work
10
- in lib/garb/model.rb. This will be the API to replace both Garb::Resource
11
- and Garb::Report. However, it isn't complete yet, so I would advise against
12
- using it right now. Resource and Report will be deprecated around 0.9.0 and
13
- I'd like to remove them for 1.0.0. I will start this process after I've
14
- updated the documentation and I feel that Garb::Model is in a solid place.
9
+ With The release of version 0.9.0 I have officially deprecated Garb::Report, Garb::Resource,
10
+ Garb::Profile, and Garb::Account. Garb::Report and Garb::Resource should be replaced by Garb::Model.
11
+ Garb::Profile and Garb::Account are supplanted by their Garb::Management::* counterparts.
12
+
13
+ I'll be working hard to update the documentation over the next day or so to highlight all of the
14
+ old features in the new classes, as well as any new features brought by the new classes. If you
15
+ are looking for something in particular, please open an issue and I will try to prioritize these
16
+ requests.
15
17
 
16
18
  Please read CHANGELOG
17
19
 
@@ -35,47 +37,39 @@ OAuth Access Token
35
37
 
36
38
  > Garb::Session.access_token = access_token # assign from oauth gem
37
39
 
38
- Accounts
40
+ Accounts, WebProperties, Profiles, and Goals
39
41
  --------
40
42
 
41
- > Garb::Account.all
43
+ > Garb::Management::Account.all
44
+ > Garb::Management::WebProperty.all
45
+ > Garb::Management::Profile.all
46
+ > Garb::Management::Goal.all
42
47
 
43
- Profiles
48
+ Profiles for a UA- Number (a WebProperty)
44
49
  --------
45
50
 
46
- > Garb::Account.first.profiles
47
-
48
- > Garb::Profile.first('UA-XXXX-XX')
49
-
50
- > Garb::Profile.all
51
- > profile = Garb::Profile.all.first
51
+ > profile = profile = Garb::Management::Profile.all.detect {|p| p.web_property_id == 'UA-XXXXXXX-X'}
52
52
 
53
53
  Define a Report Class
54
54
  ---------------------
55
55
 
56
56
  class Exits
57
- extend Garb::Resource
57
+ extend Garb::Model
58
58
 
59
- metrics :exits, :pageviews, :exit_rate
59
+ metrics :exits, :pageviews
60
60
  dimensions :page_path
61
- sort :exits
62
-
63
- filters do
64
- eql(:page_path, 'season')
65
- end
66
-
67
- # alternative:
68
- # filters :page_path.eql => 10
69
61
  end
70
62
 
71
63
  Get the Results
72
64
  ---------------
73
65
 
74
- > Exits.results(profile)
66
+ > Exits.results(profile, :filters => {:page_path.eql => '/'})
75
67
 
76
68
  OR shorthand
77
69
 
78
- > profile.exits
70
+ > profile.exits(:filters => {:page_path.eql => '/'})
71
+
72
+ Be forewarned, these numbers are for the last **30** days and may be slightly different from the numbers displayed in Google Analytics' dashboard for **1 month**.
79
73
 
80
74
  Other Parameters
81
75
  ----------------
@@ -88,7 +82,7 @@ Other Parameters
88
82
  Metrics & Dimensions
89
83
  --------------------
90
84
 
91
- Metrics and Dimensions are very complex because of the ways in which the can and cannot be combined.
85
+ **Metrics and Dimensions are very complex because of the ways in which the can and cannot be combined.**
92
86
 
93
87
  I suggest reading the google documentation to familiarize yourself with this.
94
88
 
@@ -97,52 +91,6 @@ Metrics & Dimensions
97
91
  When you've returned, you can pass the appropriate combinations (up to 50 metrics and 2 dimenstions)
98
92
  to garb, as an array, of symbols. Or you can simply push a symbol into the array.
99
93
 
100
- Sorting
101
- -------
102
-
103
- Sorting can be done on any metric or dimension defined in the request, with .desc reversing the sort.
104
-
105
- Building a Report
106
- -----------------
107
-
108
- Given the class, session, and profile from above we can do:
109
-
110
- Exits.results(profile, :limit => 10, :offset => 19)
111
-
112
- Or, with sorting and filters:
113
-
114
- Exits.results(profile, :limit => 10, :offset => 19) do
115
- sort :exits
116
-
117
- filters do
118
- contains(:page_path, 'season')
119
- gt(:exits, 100)
120
- end
121
-
122
- # or with a hash
123
- # filters :page_path.contains => 'season', :exits.gt => 100
124
- end
125
-
126
- reports will be an array of OpenStructs with methods for the metrics and dimensions returned.
127
-
128
- Build a One-Off Report
129
- ----------------------
130
-
131
- report = Garb::Report.new(profile)
132
- report.metrics :pageviews, :exits
133
- report.dimensions :page_path
134
- report.sort :exits
135
-
136
- report.filters do
137
- contains(:page_path, 'season')
138
- gte(:exits, 10)
139
- and
140
-
141
- # or with a hash
142
- # report.filters :page_path.contains => 'season', :exits.gt => 100
143
-
144
- report.results
145
-
146
94
  Filtering
147
95
  ---------
148
96
 
@@ -174,15 +122,9 @@ Filtering
174
122
  substring => '=@',
175
123
  not_substring => '!@'
176
124
 
177
- Given the previous example one-off report, we can add a line for filter:
178
-
179
- report.filters do
180
- eql(:page_path, '/extend/effectively-using-git-with-subversion/')
181
- end
182
-
183
- Or, if you're comfortable using symbol operators:
125
+ Given the previous Exits example report, we can add an options for filter:
184
126
 
185
- report.filters :page_path.eql => '/extend/effectively-using-git-with-subversion/'
127
+ profile.exits(:filters => {:page_path.eql => '/extend/effectively-using-git-with-subversion/')
186
128
 
187
129
  SSL
188
130
  ---
@@ -200,9 +142,7 @@ SSL
200
142
  TODOS
201
143
  -----
202
144
 
203
- * Read opensearch header in results
204
- * Investigate new features from GA to see if they're in the API, implement if so
205
- * clarify AND/OR filtering behavior in code and documentation
145
+ * rebuild AND/OR filtering in Garb::Model
206
146
 
207
147
  Requirements
208
148
  ------------
@@ -213,13 +153,13 @@ Requirements
213
153
  Requirements for Testing
214
154
  ------------------------
215
155
 
156
+ * shoulda
216
157
  * jferris-mocha
217
- * tpitale-shoulda (works with minitest)
218
158
 
219
159
  Install
220
160
  -------
221
161
 
222
- sudo gem install garb
162
+ gem install garb
223
163
 
224
164
  Contributors
225
165
  ------------
@@ -33,9 +33,11 @@ require 'garb/model'
33
33
 
34
34
  # management
35
35
  require 'garb/management/feed'
36
+ require 'garb/management/segment'
36
37
  require 'garb/management/account'
37
38
  require 'garb/management/web_property'
38
39
  require 'garb/management/profile'
40
+ require 'garb/management/goal'
39
41
 
40
42
  require 'support'
41
43
 
@@ -9,6 +9,7 @@ module Garb
9
9
  end
10
10
 
11
11
  def self.all(session = Session)
12
+ ActiveSupport::Deprecation.warn("The use of Garb::Account has been deprecated in favor of 'Garb::Management::Account'")
12
13
  profiles = {}
13
14
 
14
15
  Profile.all(session).each do |profile|
@@ -15,11 +15,11 @@ module Garb
15
15
  end
16
16
 
17
17
  def entries
18
- parsed_response ? [parsed_response['feed']['entry']].flatten : []
18
+ parsed_response ? Array(parsed_response['feed']['entry']).flatten.compact : []
19
19
  end
20
20
 
21
21
  def segments
22
- parsed_response ? [parsed_response['feed']['dxp:segment']].flatten : []
22
+ parsed_response ? Array(parsed_response['feed']['dxp:segment']).flatten.compact : []
23
23
  end
24
24
  end
25
25
  end
@@ -1,6 +1,8 @@
1
1
  module Garb
2
2
  class Destination
3
- attr_reader :match_type, :expression, :steps
3
+ attr_reader :match_type, :expression, :steps, :case_sensitive
4
+
5
+ alias :case_sensitive? :case_sensitive
4
6
 
5
7
  def initialize(attributes)
6
8
  return unless attributes.is_a?(Hash)
@@ -12,9 +14,5 @@ module Garb
12
14
  step_attributes = attributes[Garb.to_ga('step')]
13
15
  @steps = Array(step_attributes.is_a?(Hash) ? [step_attributes] : step_attributes).map {|s| Step.new(s)}
14
16
  end
15
-
16
- def case_sensitive?
17
- @case_sensitive
18
- end
19
17
  end
20
18
  end
@@ -5,8 +5,7 @@ module Garb
5
5
  attr_accessor :id, :title, :name
6
6
 
7
7
  def self.all(session = Session)
8
- feed = Feed.new(session, '/accounts') # builds request and parses response
9
-
8
+ feed = Feed.new(session, '/accounts')
10
9
  feed.entries.map {|entry| new_from_entry(entry, session)}
11
10
  end
12
11
 
@@ -14,7 +13,7 @@ module Garb
14
13
  account = new
15
14
  account.session = session
16
15
  account.path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
17
- account.title = entry['title'].gsub('Google Analytics Account ', '')
16
+ account.title = entry['title'].gsub('Google Analytics Account ', '') # can we get this in properties=?
18
17
  account.properties = Garb.parse_properties(entry)
19
18
  account
20
19
  end
@@ -25,12 +24,16 @@ module Garb
25
24
  end
26
25
 
27
26
  def web_properties
28
- @web_properties ||= WebProperty.for_account(self) # will call path
27
+ @web_properties ||= WebProperty.for_account(self)
29
28
  end
30
29
 
31
30
  def profiles
32
31
  @profiles ||= Profile.for_account(self)
33
32
  end
33
+
34
+ def goals
35
+ @goals ||= Goal.for_account(self)
36
+ end
34
37
  end
35
38
  end
36
39
  end
@@ -15,7 +15,7 @@ module Garb
15
15
 
16
16
  def entries
17
17
  # possible to have nil entries, yuck
18
- parsed_response ? [parsed_response['feed']['entry']].flatten.reject {|e| e.nil?} : []
18
+ parsed_response ? Array(parsed_response['feed']['entry']).flatten.compact : []
19
19
  end
20
20
 
21
21
  def response
@@ -1,20 +1,44 @@
1
1
  module Garb
2
- class Goal
3
- attr_reader :name, :number, :value, :destination
2
+ module Management
3
+ class Goal
4
4
 
5
- def initialize(attributes={})
6
- return unless attributes.is_a?(Hash)
5
+ attr_accessor :session, :path
6
+ attr_accessor :name, :number, :value, :destination, :active
7
7
 
8
- @name = attributes['name']
9
- @number = attributes['number'].to_i
10
- @value = attributes['value'].to_f
11
- @active = (attributes['active'] == 'true')
8
+ alias :active? :active
12
9
 
13
- @destination = Destination.new(attributes[Garb.to_ga('destination')])
14
- end
10
+ def self.all(session = Session, path = '/accounts/~all/webproperties/~all/profiles/~all/goals')
11
+ feed = Feed.new(session, path)
12
+ feed.entries.map {|entry| new_from_entry(entry, session)}
13
+ end
14
+
15
+ def self.for_account(account)
16
+ all(account.session, account.path + '/webproperties/~all/profiles/~all/goals')
17
+ end
18
+
19
+ def self.for_web_property(web_property)
20
+ all(web_property.session, web_property.path + '/profiles/~all/goals')
21
+ end
22
+
23
+ def self.for_profile(profile)
24
+ all(profile.session, profile.path + '/goals')
25
+ end
26
+
27
+ def self.new_from_entry(entry, session)
28
+ goal = new
29
+ goal.session = session
30
+ goal.path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
31
+ goal.properties = entry[Garb.to_ga('goal')]
32
+ goal
33
+ end
15
34
 
16
- def active?
17
- @active
35
+ def properties=(properties)
36
+ self.name = properties["name"]
37
+ self.number = properties["number"].to_i
38
+ self.value = properties["value"].to_f
39
+ self.active = (properties["active"] == "true")
40
+ self.destination = Destination.new(properties[Garb.to_ga('destination')])
41
+ end
18
42
  end
19
43
  end
20
44
  end
@@ -22,11 +22,9 @@ module Garb
22
22
 
23
23
  def self.new_from_entry(entry, session)
24
24
  profile = new
25
-
26
25
  profile.session = session
27
26
  profile.path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
28
27
  profile.properties = Garb.parse_properties(entry)
29
-
30
28
  profile
31
29
  end
32
30
 
@@ -38,8 +36,9 @@ module Garb
38
36
  self.web_property_id = properties['web_property_id']
39
37
  end
40
38
 
41
- # def goals
42
- # end
39
+ def goals
40
+ Goal.for_profile(self)
41
+ end
43
42
  end
44
43
  end
45
44
  end
@@ -0,0 +1,27 @@
1
+ module Garb
2
+ module Management
3
+ class Segment
4
+ attr_accessor :session, :path
5
+ attr_accessor :id, :name, :definition
6
+
7
+ def self.all(session = Session)
8
+ feed = Feed.new(session, '/segments')
9
+ feed.entries.map {|entry| new_from_entry(entry, session)}
10
+ end
11
+
12
+ def self.new_from_entry(entry, session)
13
+ segment = new
14
+ segment.session = session
15
+ segment.path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
16
+ segment.properties = entry['dxp:segment']
17
+ segment
18
+ end
19
+
20
+ def properties=(properties)
21
+ self.id = properties['id']
22
+ self.name = properties['name']
23
+ self.definition = properties['dxp:definition']
24
+ end
25
+ end
26
+ end
27
+ end
@@ -29,6 +29,10 @@ module Garb
29
29
  def profiles
30
30
  @profiles ||= Profile.for_web_property(self)
31
31
  end
32
+
33
+ def goals
34
+ @goals ||= Goal.for_web_property(self)
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -10,7 +10,7 @@ module Garb
10
10
  # returns Exits.results(self, options_hash, &block)
11
11
  # every class defined which extends Resource will add to the module
12
12
 
13
- # ActiveSupport::Deprecation.warn
13
+ ActiveSupport::Deprecation.warn("The use of Garb::Resource will be removed in favor of 'extend Garb::Model'")
14
14
  ProfileReports.add_report_method(base)
15
15
  end
16
16
 
@@ -2,8 +2,8 @@ module Garb
2
2
  module Version
3
3
 
4
4
  MAJOR = 0
5
- MINOR = 8
6
- TINY = 5
5
+ MINOR = 9
6
+ TINY = 0
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
@@ -1,6 +1,14 @@
1
1
  begin
2
2
  require 'simplecov'
3
- SimpleCov.start 'rails'
3
+ SimpleCov.adapters.define 'garb' do
4
+ add_filter '/test/'
5
+ add_filter '/config/'
6
+ add_filter 'version'
7
+
8
+ add_group 'Libraries', 'lib'
9
+ end
10
+
11
+ SimpleCov.start 'garb'
4
12
  rescue LoadError
5
13
  puts "Install simplecov if you use 1.9 and want coverage metrics"
6
14
  end