StatsCollect 0.2.0.20110830 → 0.3.0.20120314

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -14,7 +14,7 @@ module StatsCollect
14
14
  # It can filter only objects and categories given.
15
15
  # It has access to its configuration.
16
16
  #
17
- # Parameters:
17
+ # Parameters::
18
18
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
19
19
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
20
20
  # * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
@@ -22,36 +22,36 @@ module StatsCollect
22
22
  def execute(oStatsProxy, iConf, iLstObjects, iLstCategories)
23
23
  if (!iConf[:Files].empty?)
24
24
  # Get the list of categories, locations and objects
25
- lCategories = oStatsProxy.getCategories
26
- lObjects = oStatsProxy.getObjects
27
- lLocations = oStatsProxy.getLocations
25
+ lCategories = oStatsProxy.get_categories
26
+ lObjects = oStatsProxy.get_objects
27
+ lLocations = oStatsProxy.get_locations
28
28
  iConf[:Files].each do |iFileName|
29
29
  lLstStats = nil
30
30
  File.open(iFileName, 'r') do |iFile|
31
31
  lLstStats = eval(iFile.read)
32
32
  end
33
33
  lMissingIDs = false
34
- logInfo "Read #{lLstStats.size} stats from RB file."
34
+ log_info "Read #{lLstStats.size} stats from RB file."
35
35
  lLstStats.each do |ioStatInfo|
36
36
  iCheckExistenceBeforeAdd, iTimeStamp, iLocationName, iObjectName, iCategoryName, iValue = ioStatInfo
37
37
  ioStatInfo[1] = DateTime.strptime(iTimeStamp, iConf[:DateTimeFormat])
38
38
  if (iConf[:IDsMustExist])
39
39
  if (lLocations[iLocationName] == nil)
40
- logWarn "Unknown location from RB file #{iFileName}: #{iLocationName}"
40
+ log_warn "Unknown location from RB file #{iFileName}: #{iLocationName}"
41
41
  lMissingIDs = true
42
42
  end
43
43
  if (lObjects[iObjectName] == nil)
44
- logWarn "Unknown object from RB file #{iFileName}: #{iObjectName}"
44
+ log_warn "Unknown object from RB file #{iFileName}: #{iObjectName}"
45
45
  lMissingIDs = true
46
46
  end
47
47
  if (lCategories[iCategoryName] == nil)
48
- logWarn "Unknown category from RB file #{iFileName}: #{iCategoryName}"
48
+ log_warn "Unknown category from RB file #{iFileName}: #{iCategoryName}"
49
49
  lMissingIDs = true
50
50
  end
51
51
  end
52
52
  end
53
53
  if (!lMissingIDs)
54
- oStatsProxy.addStatsList(lLstStats)
54
+ oStatsProxy.add_stats_list(lLstStats)
55
55
  end
56
56
  end
57
57
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -14,7 +14,7 @@ module StatsCollect
14
14
  # It can filter only objects and categories given.
15
15
  # It has access to its configuration.
16
16
  #
17
- # Parameters:
17
+ # Parameters::
18
18
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
19
19
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
20
20
  # * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
@@ -29,28 +29,28 @@ module StatsCollect
29
29
  lHomePage = lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first)
30
30
  # Get the user id, as it will be necessary for further requests
31
31
  lUserID = lHomePage.uri.to_s.match(/^http:\/\/www\.reverbnation\.com\/artist\/control_room\/(\d*)$/)[1]
32
- if ((oStatsProxy.isCategoryIncluded?('Song plays')) or
33
- (oStatsProxy.isCategoryIncluded?('Song downloads')) or
34
- (oStatsProxy.isCategoryIncluded?('Song play ratio')) or
35
- (oStatsProxy.isCategoryIncluded?('Song likes')) or
36
- (oStatsProxy.isCategoryIncluded?('Song dislikes')))
32
+ if ((oStatsProxy.is_category_included?('Song plays')) or
33
+ (oStatsProxy.is_category_included?('Song downloads')) or
34
+ (oStatsProxy.is_category_included?('Song play ratio')) or
35
+ (oStatsProxy.is_category_included?('Song likes')) or
36
+ (oStatsProxy.is_category_included?('Song dislikes')))
37
37
  getPlays(oStatsProxy, lMechanizeAgent, lUserID)
38
38
  end
39
- if (oStatsProxy.isCategoryIncluded?('Video plays'))
39
+ if (oStatsProxy.is_category_included?('Video plays'))
40
40
  getVideos(oStatsProxy, lMechanizeAgent, lUserID)
41
41
  end
42
- if ((oStatsProxy.isObjectIncluded?('Global')) and
43
- ((oStatsProxy.isCategoryIncluded?('Chart position genre')) or
44
- (oStatsProxy.isCategoryIncluded?('Chart position global')) or
45
- (oStatsProxy.isCategoryIncluded?('Band equity')) or
46
- (oStatsProxy.isCategoryIncluded?('Friends'))))
42
+ if ((oStatsProxy.is_object_included?('Global')) and
43
+ ((oStatsProxy.is_category_included?('Chart position genre')) or
44
+ (oStatsProxy.is_category_included?('Chart position global')) or
45
+ (oStatsProxy.is_category_included?('Band equity')) or
46
+ (oStatsProxy.is_category_included?('Friends'))))
47
47
  getReport(oStatsProxy, lMechanizeAgent, lUserID)
48
48
  end
49
49
  end
50
50
 
51
51
  # Get the plays statistics
52
52
  #
53
- # Parameters:
53
+ # Parameters::
54
54
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
55
55
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
56
56
  # * *iUserID* (_String_): The ReverbNation user ID
@@ -66,22 +66,22 @@ module StatsCollect
66
66
  lNbrSongPlays = Integer(lNodeContents[3].content)
67
67
  lNbrSongDownloads = Integer(lNodeContents[4].content)
68
68
  lPlayRatio = Integer(lNodeContents[5].content.match(/^(\d*)%$/)[1])
69
- lMatch = lNodeContents[6].content.match(/^(\d*)\/(\d*)$/)
70
- lNbrLikes = Integer(lMatch[1])
71
- lNbrDislikes = Integer(lMatch[2])
72
- oStatsProxy.addStat(lSongTitle, 'Song plays', lNbrSongPlays)
73
- oStatsProxy.addStat(lSongTitle, 'Song downloads', lNbrSongDownloads)
74
- oStatsProxy.addStat(lSongTitle, 'Song play ratio', lPlayRatio)
75
- oStatsProxy.addStat(lSongTitle, 'Song likes', lNbrLikes)
76
- oStatsProxy.addStat(lSongTitle, 'Song dislikes', lNbrDislikes)
69
+ # lMatch = lNodeContents[6].content.match(/^(\d*)\/(\d*)$/)
70
+ # lNbrLikes = Integer(lMatch[1])
71
+ # lNbrDislikes = Integer(lMatch[2])
72
+ oStatsProxy.add_stat(lSongTitle, 'Song plays', lNbrSongPlays)
73
+ oStatsProxy.add_stat(lSongTitle, 'Song downloads', lNbrSongDownloads)
74
+ oStatsProxy.add_stat(lSongTitle, 'Song play ratio', lPlayRatio)
75
+ # oStatsProxy.add_stat(lSongTitle, 'Song likes', lNbrLikes)
76
+ # oStatsProxy.add_stat(lSongTitle, 'Song dislikes', lNbrDislikes)
77
77
  lLstSongsRead << lSongTitle
78
78
  end
79
- logDebug "#{lLstSongsRead.size} songs read: #{lLstSongsRead.join(', ')}"
79
+ log_debug "#{lLstSongsRead.size} songs read: #{lLstSongsRead.join(', ')}"
80
80
  end
81
81
 
82
82
  # Get the videos statistics
83
83
  #
84
- # Parameters:
84
+ # Parameters::
85
85
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
86
86
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
87
87
  # * *iUserID* (_String_): The ReverbNation user ID
@@ -95,15 +95,15 @@ module StatsCollect
95
95
  lNodeContents = iSongNode.css('td')
96
96
  lVideoTitle = lNodeContents[1].children[0].content
97
97
  lNbrVideoPlays = Integer(lNodeContents[3].content)
98
- oStatsProxy.addStat(lVideoTitle, 'Video plays', lNbrVideoPlays)
98
+ oStatsProxy.add_stat(lVideoTitle, 'Video plays', lNbrVideoPlays)
99
99
  lLstVideosRead << lVideoTitle
100
100
  end
101
- logDebug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
101
+ log_debug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
102
102
  end
103
103
 
104
104
  # Get the report statistics
105
105
  #
106
- # Parameters:
106
+ # Parameters::
107
107
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
108
108
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
109
109
  # * *iUserID* (_String_): The ReverbNation user ID
@@ -127,7 +127,7 @@ module StatsCollect
127
127
  end
128
128
  end
129
129
  if (lChartPositionGenre == nil)
130
- logErr "Unable to get the chart positions: #{lReportPage.root}"
130
+ log_err "Unable to get the chart positions: #{lReportPage.root}"
131
131
  else
132
132
  lBandEquityScore = nil
133
133
  lNbrFriends = nil
@@ -146,14 +146,14 @@ module StatsCollect
146
146
  end
147
147
  end
148
148
  if (lBandEquityScore == nil)
149
- logErr "Unable to get the band equity score: #{lReportPage.root}"
149
+ log_err "Unable to get the band equity score: #{lReportPage.root}"
150
150
  elsif (lNbrFriends == nil)
151
- logErr "Unable to get the number of friends: #{lReportPage.root}"
151
+ log_err "Unable to get the number of friends: #{lReportPage.root}"
152
152
  else
153
- oStatsProxy.addStat('Global', 'Chart position genre', lChartPositionGenre)
154
- oStatsProxy.addStat('Global', 'Chart position global', lChartPositionGlobal)
155
- oStatsProxy.addStat('Global', 'Band equity', lBandEquityScore)
156
- oStatsProxy.addStat('Global', 'Friends', lNbrFriends)
153
+ oStatsProxy.add_stat('Global', 'Chart position genre', lChartPositionGenre)
154
+ oStatsProxy.add_stat('Global', 'Chart position global', lChartPositionGlobal)
155
+ oStatsProxy.add_stat('Global', 'Band equity', lBandEquityScore)
156
+ oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)
157
157
  end
158
158
  end
159
159
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -14,7 +14,7 @@ module StatsCollect
14
14
  # It can filter only objects and categories given.
15
15
  # It has access to its configuration.
16
16
  #
17
- # Parameters:
17
+ # Parameters::
18
18
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
19
19
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
20
20
  # * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
@@ -23,23 +23,23 @@ module StatsCollect
23
23
  require 'mechanize'
24
24
  lMechanizeAgent = Mechanize.new
25
25
  # Get the number of likes from Facebook
26
- if (oStatsProxy.isCategoryIncluded?('Tweets'))
26
+ if (oStatsProxy.is_category_included?('Tweets'))
27
27
  lFailedObjects = []
28
28
  iConf[:Objects].each do |iObject|
29
- if (oStatsProxy.isObjectIncluded?(iObject))
29
+ if (oStatsProxy.is_object_included?(iObject))
30
30
  lTweetsData = lMechanizeAgent.get_file("http://urls.api.twitter.com/1/urls/count.json?url=#{iObject}").gsub(/:/,'=>')
31
31
  if (lTweetsData.match(/Unable to access URL counting services/) != nil)
32
32
  # An error occurred: we can try again
33
- logErr "Error while fetching Tweets for #{iObject}: #{lTweetsData}"
33
+ log_err "Error while fetching Tweets for #{iObject}: #{lTweetsData}"
34
34
  lFailedObjects << iObject
35
35
  else
36
36
  lNbrTweets = eval(lTweetsData)['count']
37
- oStatsProxy.addStat(iObject, 'Tweets', lNbrTweets)
37
+ oStatsProxy.add_stat(iObject, 'Tweets', lNbrTweets)
38
38
  end
39
39
  end
40
40
  end
41
41
  if (!lFailedObjects.empty?)
42
- oStatsProxy.addRecoverableOrder(lFailedObjects, ['Tweets'])
42
+ oStatsProxy.add_recoverable_order(lFailedObjects, ['Tweets'])
43
43
  end
44
44
  end
45
45
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -14,17 +14,17 @@ module StatsCollect
14
14
  # It can filter only objects and categories given.
15
15
  # It has access to its configuration.
16
16
  #
17
- # Parameters:
17
+ # Parameters::
18
18
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
19
19
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
20
20
  # * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
21
21
  # * *iLstCategories* (<em>list<String></em>): List of categories to filter (can be empty for all)
22
22
  def execute(oStatsProxy, iConf, iLstObjects, iLstCategories)
23
- if ((oStatsProxy.isObjectIncluded?('Global')) and
24
- ((oStatsProxy.isCategoryIncluded?('Following')) or
25
- (oStatsProxy.isCategoryIncluded?('Followers')) or
26
- (oStatsProxy.isCategoryIncluded?('Lists followers')) or
27
- (oStatsProxy.isCategoryIncluded?('Tweets'))))
23
+ if ((oStatsProxy.is_object_included?('Global')) and
24
+ ((oStatsProxy.is_category_included?('Following')) or
25
+ (oStatsProxy.is_category_included?('Followers')) or
26
+ (oStatsProxy.is_category_included?('Lists followers')) or
27
+ (oStatsProxy.is_category_included?('Tweets'))))
28
28
  require 'mechanize'
29
29
  lMechanizeAgent = Mechanize.new
30
30
  lProfilePage = lMechanizeAgent.get("http://twitter.com/#{iConf[:Name]}")
@@ -32,10 +32,10 @@ module StatsCollect
32
32
  lNbrFollowers = Integer(lProfilePage.root.css('span#follower_count').first.content.strip)
33
33
  lNbrLists = Integer(lProfilePage.root.css('span#lists_count').first.content.strip)
34
34
  lNbrTweets = Integer(lProfilePage.root.css('span#update_count').first.content.strip)
35
- oStatsProxy.addStat('Global', 'Following', lNbrFollowing)
36
- oStatsProxy.addStat('Global', 'Followers', lNbrFollowers)
37
- oStatsProxy.addStat('Global', 'Lists followers', lNbrLists)
38
- oStatsProxy.addStat('Global', 'Tweets', lNbrTweets)
35
+ oStatsProxy.add_stat('Global', 'Following', lNbrFollowing)
36
+ oStatsProxy.add_stat('Global', 'Followers', lNbrFollowers)
37
+ oStatsProxy.add_stat('Global', 'Lists followers', lNbrLists)
38
+ oStatsProxy.add_stat('Global', 'Tweets', lNbrTweets)
39
39
  end
40
40
  end
41
41
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -14,7 +14,7 @@ module StatsCollect
14
14
  # It can filter only objects and categories given.
15
15
  # It has access to its configuration.
16
16
  #
17
- # Parameters:
17
+ # Parameters::
18
18
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
19
19
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
20
20
  # * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
@@ -30,31 +30,27 @@ module StatsCollect
30
30
  else
31
31
  lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first).meta.first.click
32
32
  end
33
- if ((oStatsProxy.isCategoryIncluded?('Video plays')) or
34
- (oStatsProxy.isCategoryIncluded?('Video likes')) or
35
- (oStatsProxy.isCategoryIncluded?('Video dislikes')) or
36
- (oStatsProxy.isCategoryIncluded?('Video comments')) or
37
- (oStatsProxy.isCategoryIncluded?('Video responses')))
33
+ if ((oStatsProxy.is_category_included?('Video plays')) or
34
+ (oStatsProxy.is_category_included?('Video likes')) or
35
+ (oStatsProxy.is_category_included?('Video dislikes')) or
36
+ (oStatsProxy.is_category_included?('Video comments')) or
37
+ (oStatsProxy.is_category_included?('Video responses')))
38
38
  getVideos(oStatsProxy, lMechanizeAgent)
39
39
  end
40
- if ((oStatsProxy.isObjectIncluded?('Global')) and
41
- ((oStatsProxy.isCategoryIncluded?('Visits')) or
42
- (oStatsProxy.isCategoryIncluded?('Followers'))))
40
+ if ((oStatsProxy.is_object_included?('Global')) and
41
+ ((oStatsProxy.is_category_included?('Visits')) or
42
+ (oStatsProxy.is_category_included?('Followers'))))
43
43
  getOverview(oStatsProxy, lMechanizeAgent)
44
44
  end
45
- if ((oStatsProxy.isObjectIncluded?('Global')) and
46
- (oStatsProxy.isCategoryIncluded?('Friends')))
47
- getFriends(oStatsProxy, lMechanizeAgent)
48
- end
49
- if ((oStatsProxy.isObjectIncluded?('Global')) and
50
- (oStatsProxy.isCategoryIncluded?('Following')))
45
+ if ((oStatsProxy.is_object_included?('Global')) and
46
+ (oStatsProxy.is_category_included?('Following')))
51
47
  getSubscriptions(oStatsProxy, lMechanizeAgent)
52
48
  end
53
49
  end
54
50
 
55
51
  # Get the videos statistics
56
52
  #
57
- # Parameters:
53
+ # Parameters::
58
54
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
59
55
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
60
56
  def getVideos(oStatsProxy, iMechanizeAgent)
@@ -63,25 +59,24 @@ module StatsCollect
63
59
  lLstVideosRead = []
64
60
  lVideosPage.root.css('li.vm-video-item').each do |iVideoNode|
65
61
  lVideoTitle = iVideoNode.css('div.vm-video-title a').first.content
66
- lMetricNodes = iVideoNode.css('div.vm-video-metrics dl dd')
67
- lNbrPlays = Integer(lMetricNodes[0].css('a').first.content.strip)
68
- lNbrComments = Integer(lMetricNodes[1].content.strip)
69
- lNbrResponses = Integer(lMetricNodes[2].content.strip)
70
- lNbrLikes = Integer(lMetricNodes[3].content[0..-2].strip)
71
- lNbrDislikes = Integer(lMetricNodes[4].content.strip)
72
- oStatsProxy.addStat(lVideoTitle, 'Video plays', lNbrPlays)
73
- oStatsProxy.addStat(lVideoTitle, 'Video comments', lNbrComments)
74
- oStatsProxy.addStat(lVideoTitle, 'Video responses', lNbrResponses)
75
- oStatsProxy.addStat(lVideoTitle, 'Video likes', lNbrLikes)
76
- oStatsProxy.addStat(lVideoTitle, 'Video dislikes', lNbrDislikes)
62
+ lNbrPlays = Integer(iVideoNode.css('div.vm-video-metrics span.video-view-count span.vm-video-metric-value')[0].content.strip)
63
+ lNbrLikes = Integer(iVideoNode.css('div.vm-video-metrics span.video-likes-count span.vm-video-metric-value')[0].content.strip)
64
+ lNbrDislikes = Integer(iVideoNode.css('div.vm-video-metrics span.video-dislikes-count span.vm-video-metric-value')[0].content.strip)
65
+ lNbrComments = Integer(iVideoNode.css('div.vm-video-metrics span.video-comments span.vm-video-metric-value')[0].content.strip)
66
+ #lNbrResponses = Integer(lMetricNodes[2].content.strip)
67
+ oStatsProxy.add_stat(lVideoTitle, 'Video plays', lNbrPlays)
68
+ oStatsProxy.add_stat(lVideoTitle, 'Video comments', lNbrComments)
69
+ #oStatsProxy.add_stat(lVideoTitle, 'Video responses', lNbrResponses)
70
+ oStatsProxy.add_stat(lVideoTitle, 'Video likes', lNbrLikes)
71
+ oStatsProxy.add_stat(lVideoTitle, 'Video dislikes', lNbrDislikes)
77
72
  lLstVideosRead << lVideoTitle
78
73
  end
79
- logDebug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
74
+ log_debug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
80
75
  end
81
76
 
82
77
  # Get the overview statistics
83
78
  #
84
- # Parameters:
79
+ # Parameters::
85
80
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
86
81
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
87
82
  def getOverview(oStatsProxy, iMechanizeAgent)
@@ -103,35 +98,24 @@ module StatsCollect
103
98
  end
104
99
  end
105
100
  if (lNbrVisits == nil)
106
- logErr "Unable to get number of visits: #{lOverviewPage.content}"
101
+ log_err "Unable to get number of visits: #{lOverviewPage.content}"
107
102
  elsif (lNbrFollowers == nil)
108
- logErr "Unable to get number of followers: #{lOverviewPage.content}"
103
+ log_err "Unable to get number of followers: #{lOverviewPage.content}"
109
104
  else
110
- oStatsProxy.addStat('Global', 'Visits', lNbrVisits)
111
- oStatsProxy.addStat('Global', 'Followers', lNbrFollowers)
105
+ oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)
106
+ oStatsProxy.add_stat('Global', 'Followers', lNbrFollowers)
112
107
  end
113
108
  end
114
109
 
115
110
  # Get the friends statistics
116
111
  #
117
- # Parameters:
118
- # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
119
- # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
120
- def getFriends(oStatsProxy, iMechanizeAgent)
121
- lOverviewPage = iMechanizeAgent.get('http://www.youtube.com/profile?view=friends')
122
- lNbrFriends = Integer(lOverviewPage.root.xpath('//span[@name="channel-box-item-count"]').first.content)
123
- oStatsProxy.addStat('Global', 'Friends', lNbrFriends)
124
- end
125
-
126
- # Get the friends statistics
127
- #
128
- # Parameters:
112
+ # Parameters::
129
113
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
130
114
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
131
115
  def getSubscriptions(oStatsProxy, iMechanizeAgent)
132
- lOverviewPage = iMechanizeAgent.get('http://www.youtube.com/profile?view=subscriptions')
133
- lNbrFollowing = Integer(lOverviewPage.root.xpath('//span[@name="channel-box-item-count"]').first.content)
134
- oStatsProxy.addStat('Global', 'Following', lNbrFollowing)
116
+ lOverviewPage = iMechanizeAgent.get('http://www.youtube.com/profile')
117
+ lNbrFollowing = Integer(lOverviewPage.root.css('div.header-stats span.stat-value').first.content.strip)
118
+ oStatsProxy.add_stat('Global', 'Following', lNbrFollowing)
135
119
  end
136
120
 
137
121
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -11,10 +11,10 @@ module StatsCollect
11
11
 
12
12
  # Send a given notification
13
13
  #
14
- # Parameters:
14
+ # Parameters::
15
15
  # * *iConf* (<em>map<Symbol,Object></em>): The notifier config
16
16
  # * *iMessage* (_String_): Message to send
17
- def sendNotification(iConf, iMessage)
17
+ def send_notification(iConf, iMessage)
18
18
  iConf[:SendCode].call(iMessage)
19
19
  end
20
20
 
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2010 - 2011 Muriel Salvan (murielsalvan@users.sourceforge.net)
2
+ # Copyright (c) 2010 - 2012 Muriel Salvan (muriel@x-aeon.com)
3
3
  # Licensed under the terms specified in LICENSE file. No warranty is provided.
4
4
  #++
5
5
 
@@ -11,11 +11,11 @@ module StatsCollect
11
11
 
12
12
  # Send a given notification
13
13
  #
14
- # Parameters:
14
+ # Parameters::
15
15
  # * *iConf* (<em>map<Symbol,Object></em>): The notifier config
16
16
  # * *iMessage* (_String_): Message to send
17
- def sendNotification(iConf, iMessage)
18
- File.open(iConf[:LogFile], (iConf[:Append] == true) ? 'a' : 'w') do |oFile|
17
+ def send_notification(iConf, iMessage)
18
+ File.open(iConf[:log_file], (iConf[:Append] == true) ? 'a' : 'w') do |oFile|
19
19
  oFile.write(iMessage)
20
20
  end
21
21
  end