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)
@@ -23,13 +23,13 @@ module StatsCollect
23
23
  require 'mechanize'
24
24
  lMechanizeAgent = Mechanize.new
25
25
  # Get the number of shares
26
- if (oStatsProxy.isCategoryIncluded?('Monthly shares'))
26
+ if (oStatsProxy.is_category_included?('Monthly shares'))
27
27
  getDomains(oStatsProxy, lMechanizeAgent, iConf, 'month', 'Monthly shares')
28
28
  end
29
- if (oStatsProxy.isCategoryIncluded?('Weekly shares'))
29
+ if (oStatsProxy.is_category_included?('Weekly shares'))
30
30
  getDomains(oStatsProxy, lMechanizeAgent, iConf, 'week', 'Weekly shares')
31
31
  end
32
- if (oStatsProxy.isCategoryIncluded?('Daily shares'))
32
+ if (oStatsProxy.is_category_included?('Daily shares'))
33
33
  getDomains(oStatsProxy, lMechanizeAgent, iConf, 'day', 'Daily shares')
34
34
  end
35
35
  end
@@ -38,7 +38,7 @@ module StatsCollect
38
38
 
39
39
  # Get domains stats for a given period
40
40
  #
41
- # Parameters:
41
+ # Parameters::
42
42
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
43
43
  # * *iMechanizeAgent* (_Mechanize_): The mechanize agent
44
44
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
@@ -54,7 +54,7 @@ module StatsCollect
54
54
  lNbrShares = iDataInfo['shares']
55
55
  end
56
56
  end
57
- oStatsProxy.addStat(iObject, iCategory, lNbrShares)
57
+ oStatsProxy.add_stat(iObject, iCategory, lNbrShares)
58
58
  end
59
59
  end
60
60
 
@@ -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,9 +22,9 @@ 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
  lCSVLocations = []
29
29
  lCSVObjects = []
30
30
  lCSVCategories = []
@@ -38,7 +38,7 @@ module StatsCollect
38
38
  # We have locations in this line
39
39
  iRow[1..-1].each do |iLocationName|
40
40
  if (lLocations[iLocationName] == nil)
41
- logWarn "Unknown location from CSV file #{iFileName}: #{iLocationName}"
41
+ log_warn "Unknown location from CSV file #{iFileName}: #{iLocationName}"
42
42
  lMissingIDs = true
43
43
  end
44
44
  lCSVLocations << iLocationName
@@ -47,7 +47,7 @@ module StatsCollect
47
47
  # We have objects in this line
48
48
  iRow[1..-1].each do |iObjectName|
49
49
  if (lObjects[iObjectName] == nil)
50
- logWarn "Unknown object from CSV file #{iFileName}: #{iObjectName}"
50
+ log_warn "Unknown object from CSV file #{iFileName}: #{iObjectName}"
51
51
  lMissingIDs = true
52
52
  end
53
53
  lCSVObjects << iObjectName
@@ -56,7 +56,7 @@ module StatsCollect
56
56
  # We have categories in this line
57
57
  iRow[1..-1].each do |iCategoryName|
58
58
  if (lCategories[iCategoryName] == nil)
59
- logWarn "Unknown category from CSV file #{iFileName}: #{iCategoryName}"
59
+ log_warn "Unknown category from CSV file #{iFileName}: #{iCategoryName}"
60
60
  lMissingIDs = true
61
61
  end
62
62
  lCSVCategories << iCategoryName
@@ -89,7 +89,7 @@ module StatsCollect
89
89
  else
90
90
  raise RuntimeError.new("Unknown value type for category #{lCSVCategories[iIdx]}: #{lValueType}")
91
91
  end
92
- oStatsProxy.addStat(lCSVObjects[iIdx], lCSVCategories[iIdx], lValue, :Timestamp => lTimestamp, :Location => lCSVLocations[iIdx])
92
+ oStatsProxy.add_stat(lCSVObjects[iIdx], lCSVCategories[iIdx], lValue, :Timestamp => lTimestamp, :Location => lCSVLocations[iIdx])
93
93
  end
94
94
  end
95
95
  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,15 +29,15 @@ module StatsCollect
29
29
  lLoginForm.pass = iConf[:LoginPassword]
30
30
  # Submit to get to the home page
31
31
  lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first)
32
- if ((oStatsProxy.isObjectIncluded?('Global')) and
33
- (oStatsProxy.isCategoryIncluded?('Friends')))
32
+ if ((oStatsProxy.is_object_included?('Global')) and
33
+ (oStatsProxy.is_category_included?('Friends')))
34
34
  getProfile(oStatsProxy, lMechanizeAgent, iConf)
35
35
  end
36
36
  end
37
37
 
38
38
  # Get the profile statistics
39
39
  #
40
- # Parameters:
40
+ # Parameters::
41
41
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
42
42
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
43
43
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
@@ -55,9 +55,9 @@ module StatsCollect
55
55
  end
56
56
  end
57
57
  if (lNbrFriends == nil)
58
- logErr "Unable to get number of friends: #{lProfilePage.root}"
58
+ log_err "Unable to get number of friends: #{lProfilePage.root}"
59
59
  else
60
- oStatsProxy.addStat('Global', 'Friends', lNbrFriends)
60
+ oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)
61
61
  end
62
62
  end
63
63
 
@@ -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,15 +29,15 @@ module StatsCollect
29
29
  lLoginForm.pass = iConf[:LoginPassword]
30
30
  # Submit to get to the home page
31
31
  lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first)
32
- if ((oStatsProxy.isObjectIncluded?('Global')) and
33
- (oStatsProxy.isCategoryIncluded?('Likes')))
32
+ if ((oStatsProxy.is_object_included?('Global')) and
33
+ (oStatsProxy.is_category_included?('Likes')))
34
34
  getArtistProfile(oStatsProxy, lMechanizeAgent, iConf)
35
35
  end
36
36
  end
37
37
 
38
38
  # Get the artist profile statistics
39
39
  #
40
- # Parameters:
40
+ # Parameters::
41
41
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
42
42
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
43
43
  # * *iConf* (<em>map<Symbol,Object></em>): The conf
@@ -52,9 +52,9 @@ module StatsCollect
52
52
  end
53
53
  end
54
54
  if (lNbrLikes == nil)
55
- logErr "Unable to get number of likes: #{lProfilePage.root}"
55
+ log_err "Unable to get number of likes: #{lProfilePage.root}"
56
56
  else
57
- oStatsProxy.addStat('Global', 'Likes', lNbrLikes)
57
+ oStatsProxy.add_stat('Global', 'Likes', lNbrLikes)
58
58
  end
59
59
  end
60
60
 
@@ -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)
@@ -24,23 +24,23 @@ module StatsCollect
24
24
  lMechanizeAgent = Mechanize.new
25
25
  # Get the number of likes from Facebook
26
26
  lErrorObjects = []
27
- if (oStatsProxy.isCategoryIncluded?('Likes'))
27
+ if (oStatsProxy.is_category_included?('Likes'))
28
28
  iConf[:Objects].each do |iObject|
29
- if (oStatsProxy.isObjectIncluded?(iObject))
29
+ if (oStatsProxy.is_object_included?(iObject))
30
30
  lLikesContent = lMechanizeAgent.get("http://www.facebook.com/plugins/like.php?href=#{iObject}").root.css('span.connect_widget_not_connected_text').first.content.delete(',')
31
31
  lMatch = lLikesContent.match(/^(\d*) likes./)
32
32
  if (lMatch == nil)
33
- logErr "Unable to parse FacebookLike output for object #{iObject}: #{lLikesContent}"
33
+ log_err "Unable to parse FacebookLike output for object #{iObject}: #{lLikesContent}"
34
34
  lErrorObjects << iObject
35
35
  else
36
36
  lNbrLikes = Integer(lMatch[1])
37
- oStatsProxy.addStat(iObject, 'Likes', lNbrLikes)
37
+ oStatsProxy.add_stat(iObject, 'Likes', lNbrLikes)
38
38
  end
39
39
  end
40
40
  end
41
41
  end
42
42
  if (!lErrorObjects.empty?)
43
- oStatsProxy.addUnrecoverableOrder(lErrorObjects, ['Likes'])
43
+ oStatsProxy.add_unrecoverable_order(lErrorObjects, ['Likes'])
44
44
  end
45
45
  end
46
46
 
@@ -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
 
@@ -18,7 +18,7 @@ module StatsCollect
18
18
  # It can filter only objects and categories given.
19
19
  # It has access to its configuration.
20
20
  #
21
- # Parameters:
21
+ # Parameters::
22
22
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
23
23
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration associated to this plugin
24
24
  # * *iLstObjects* (<em>list<String></em>): List of objects to filter (can be empty for all)
@@ -35,10 +35,10 @@ module StatsCollect
35
35
  lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first).meta.first.click
36
36
  end
37
37
  iConf[:Objects].each do |iGroupName|
38
- if (oStatsProxy.isCategoryIncluded?('Friends'))
38
+ if (oStatsProxy.is_category_included?('Friends'))
39
39
  getMembers(oStatsProxy, lMechanizeAgent, iGroupName)
40
40
  end
41
- if (oStatsProxy.isCategoryIncluded?('Friends list'))
41
+ if (oStatsProxy.is_category_included?('Friends list'))
42
42
  getMembersList(oStatsProxy, lMechanizeAgent, iGroupName)
43
43
  end
44
44
  end
@@ -46,24 +46,24 @@ module StatsCollect
46
46
 
47
47
  # Get the members statistics
48
48
  #
49
- # Parameters:
49
+ # Parameters::
50
50
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
51
51
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
52
52
  # * *iGroupName* (_String_): Name of the group to retrieve members from
53
53
  def getMembers(oStatsProxy, iMechanizeAgent, iGroupName)
54
54
  lMembersPage = iMechanizeAgent.get("http://groups.google.com/group/#{iGroupName}/manage_members?hl=en")
55
55
  lNbrFriends = Integer(lMembersPage.root.css('div.mngcontentbox table.membertabs tr td.st b').first.content.match(/All members \((\d*)\)/)[1])
56
- oStatsProxy.addStat(iGroupName, 'Friends', lNbrFriends)
56
+ oStatsProxy.add_stat(iGroupName, 'Friends', lNbrFriends)
57
57
  end
58
58
 
59
59
  # Get the members list
60
60
  #
61
- # Parameters:
61
+ # Parameters::
62
62
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
63
63
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
64
64
  # * *iGroupName* (_String_): Name of the group to retrieve members from
65
65
  def getMembersList(oStatsProxy, iMechanizeAgent, iGroupName)
66
- lExportForm = iMechanizeAgent.get("http://groups.google.com/group/#{iGroupName}/manage_members?hl=en").forms[4]
66
+ lExportForm = iMechanizeAgent.get("http://groups.google.com/group/#{iGroupName}/manage_members?hl=en").forms[6]
67
67
  lLstMembers = iMechanizeAgent.submit(lExportForm, lExportForm.buttons.first).content.split("\n")[2..-1]
68
68
  # The map of members
69
69
  # map< Name, [ MemberStatus, JoinDateTime ] >
@@ -79,7 +79,7 @@ module StatsCollect
79
79
  when 'owner'
80
80
  lStatus = MEMBERSTATUS_OWNER
81
81
  else
82
- logErr "Unknown member status (#{lStrStatus}) for email #{lEmail}. Will be counted as a member."
82
+ log_err "Unknown member status (#{lStrStatus}) for email #{lEmail}. Will be counted as a member."
83
83
  lStatus = MEMBERSTATS_MEMBER
84
84
  end
85
85
  lMapMembers[lEmail] = [
@@ -93,7 +93,7 @@ module StatsCollect
93
93
  lStrSecond.to_i)
94
94
  ]
95
95
  end
96
- oStatsProxy.addStat(iGroupName, 'Friends list', lMapMembers)
96
+ oStatsProxy.add_stat(iGroupName, 'Friends list', lMapMembers)
97
97
  end
98
98
 
99
99
  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,20 +14,20 @@ 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
23
  iConf[:Objects].each do |iObject|
24
- if ((oStatsProxy.isObjectIncluded?(iObject)) and
25
- (oStatsProxy.isCategoryIncluded?('Search results')))
24
+ if ((oStatsProxy.is_object_included?(iObject)) and
25
+ (oStatsProxy.is_category_included?('Search results')))
26
26
  require 'mechanize'
27
27
  lMechanizeAgent = Mechanize.new
28
28
  lProfilePage = lMechanizeAgent.get("http://www.google.com/search?q=#{URI.escape(iObject)}")
29
- lNbrSearchResults = Integer(lProfilePage.root.css('div#resultStats').first.content.delete(',').strip.match(/ (\d*) /)[1])
30
- oStatsProxy.addStat(iObject, 'Search results', lNbrSearchResults)
29
+ lNbrSearchResults = Integer(lProfilePage.root.css('div#subform_ctrl div')[1].content.delete(',').strip.match(/ (\d*) /)[1])
30
+ oStatsProxy.add_stat(iObject, 'Search results', lNbrSearchResults)
31
31
  end
32
32
  end
33
33
  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)
@@ -30,36 +30,36 @@ module StatsCollect
30
30
  lLoginForm.Password = iConf[:LoginPassword]
31
31
  # Submit to get to the home page
32
32
  lMechanizeAgent.submit(lLoginForm, lLoginForm.buttons.first)
33
- if (oStatsProxy.isObjectIncluded?('Global'))
34
- if (oStatsProxy.isCategoryIncluded?('Comments'))
33
+ if (oStatsProxy.is_object_included?('Global'))
34
+ if (oStatsProxy.is_category_included?('Comments'))
35
35
  getProfile(oStatsProxy, lMechanizeAgent)
36
36
  end
37
- if ((oStatsProxy.isCategoryIncluded?('Friends')) or
38
- (oStatsProxy.isCategoryIncluded?('Visits')))
37
+ if ((oStatsProxy.is_category_included?('Friends')) or
38
+ (oStatsProxy.is_category_included?('Visits')))
39
39
  getDashboard(oStatsProxy, lMechanizeAgent)
40
40
  end
41
- if (oStatsProxy.isCategoryIncluded?('Friends list'))
41
+ if (oStatsProxy.is_category_included?('Friends list'))
42
42
  getFriendsList(oStatsProxy, lMechanizeAgent)
43
43
  end
44
44
  end
45
- if (oStatsProxy.isCategoryIncluded?('Song plays'))
45
+ if (oStatsProxy.is_category_included?('Song plays'))
46
46
  getSongs(oStatsProxy, lMechanizeAgent)
47
47
  end
48
- if ((oStatsProxy.isCategoryIncluded?('Video plays')) or
49
- (oStatsProxy.isCategoryIncluded?('Video comments')) or
50
- (oStatsProxy.isCategoryIncluded?('Video likes')) or
51
- (oStatsProxy.isCategoryIncluded?('Video rating')))
48
+ if ((oStatsProxy.is_category_included?('Video plays')) or
49
+ (oStatsProxy.is_category_included?('Video comments')) or
50
+ (oStatsProxy.is_category_included?('Video likes')) or
51
+ (oStatsProxy.is_category_included?('Video rating')))
52
52
  getVideos(oStatsProxy, lMechanizeAgent)
53
53
  end
54
- if ((oStatsProxy.isCategoryIncluded?('Blog reads')) or
55
- (oStatsProxy.isCategoryIncluded?('Blog likes')))
54
+ if ((oStatsProxy.is_category_included?('Blog reads')) or
55
+ (oStatsProxy.is_category_included?('Blog likes')))
56
56
  getBlogs(oStatsProxy, lMechanizeAgent, iConf)
57
57
  end
58
58
  end
59
59
 
60
60
  # Get the profile statistics
61
61
  #
62
- # Parameters:
62
+ # Parameters::
63
63
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
64
64
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
65
65
  def getProfile(oStatsProxy, iMechanizeAgent)
@@ -68,12 +68,12 @@ module StatsCollect
68
68
  # Screen scrap it
69
69
  lNbrComments = Integer(lProfilePage.root.css('article#module18 div.wrapper section.content div.commentContainer a.moreComments span.cnt').first.content.match(/of (\d*)/)[1])
70
70
 
71
- oStatsProxy.addStat('Global', 'Comments', lNbrComments)
71
+ oStatsProxy.add_stat('Global', 'Comments', lNbrComments)
72
72
  end
73
73
 
74
74
  # Get the dashboard statistics
75
75
  #
76
- # Parameters:
76
+ # Parameters::
77
77
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
78
78
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
79
79
  def getDashboard(oStatsProxy, iMechanizeAgent)
@@ -81,8 +81,8 @@ module StatsCollect
81
81
  lJSonData = eval(iMechanizeAgent.get_file('http://www.myspace.com/stats/fans_json/profile_stats/en-US/x=0').gsub(':','=>'))
82
82
  lNbrVisits = Integer(lJSonData['data'].select { |iItem| next (iItem[0] == 'myspace_views') }.first[-1].gsub(',',''))
83
83
  lNbrFriends = Integer(lJSonData['data'].select { |iItem| next (iItem[0] == 'myspace_friends') }.first[-1].gsub(',',''))
84
- oStatsProxy.addStat('Global', 'Visits', lNbrVisits)
85
- oStatsProxy.addStat('Global', 'Friends', lNbrFriends)
84
+ oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)
85
+ oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)
86
86
 
87
87
  # OLD VERSION (keeping it as Myspace changes all the time
88
88
  # lDashboardPage = iMechanizeAgent.get('http://www.myspace.com/music/dashboard')
@@ -99,21 +99,21 @@ module StatsCollect
99
99
  # end
100
100
  # end
101
101
  # if (lCoreUserID == nil)
102
- # logErr "Unable to find the core user ID: #{lDashboardPage.root}"
102
+ # log_err "Unable to find the core user ID: #{lDashboardPage.root}"
103
103
  # else
104
104
  # # Call the Ajax script
105
105
  # lStatsAjaxContent = iMechanizeAgent.get_file("http://www.myspace.com/Modules/Music/Handlers/Dashboard.ashx?sourceApplication=#{lAppID}&pkey=#{lPKey}&action=GETCORESTATS&userID=#{lCoreUserID}")
106
106
  # lStrVisits, lStrFriends = lStatsAjaxContent.match(/^\{'totalprofileviews':'([^']*)','totalfriends':'([^']*)'/)[1..2]
107
107
  # lNbrVisits = Integer(lStrVisits.delete(','))
108
108
  # lNbrFriends = Integer(lStrFriends.delete(','))
109
- # oStatsProxy.addStat('Global', 'Visits', lNbrVisits)
110
- # oStatsProxy.addStat('Global', 'Friends', lNbrFriends)
109
+ # oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)
110
+ # oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)
111
111
  # end
112
112
  end
113
113
 
114
114
  # Get the songs statistics
115
115
  #
116
- # Parameters:
116
+ # Parameters::
117
117
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
118
118
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
119
119
  def getSongs(oStatsProxy, iMechanizeAgent)
@@ -132,19 +132,19 @@ module StatsCollect
132
132
  end
133
133
  lPlaysNode = iSongNode.children[11]
134
134
  if (lPlaysNode == nil)
135
- logErr "Unable to find plays node: #{iSongNode}"
135
+ log_err "Unable to find plays node: #{iSongNode}"
136
136
  else
137
137
  begin
138
138
  lNbrPlays = Integer(lPlaysNode.content)
139
139
  rescue Exception
140
- logErr "Invalid number of plays content: #{lPlaysNode}"
140
+ log_err "Invalid number of plays content: #{lPlaysNode}"
141
141
  end
142
142
  end
143
143
  if (lSongTitle == nil)
144
- logErr "Unable to get the song title: #{iSongNode}"
144
+ log_err "Unable to get the song title: #{iSongNode}"
145
145
  end
146
146
  if (lNbrPlays == nil)
147
- logErr "Unable to get the song number of plays: #{iSongNode}"
147
+ log_err "Unable to get the song number of plays: #{iSongNode}"
148
148
  if (lSongTitle != nil)
149
149
  # We can try this one again
150
150
  lLstRecoverableObjectsForSongPlays << lSongTitle
@@ -152,19 +152,19 @@ module StatsCollect
152
152
  end
153
153
  if ((lSongTitle != nil) and
154
154
  (lNbrPlays != nil))
155
- oStatsProxy.addStat(lSongTitle, 'Song plays', lNbrPlays)
155
+ oStatsProxy.add_stat(lSongTitle, 'Song plays', lNbrPlays)
156
156
  end
157
157
  lLstSongsPlayRead << lSongTitle
158
158
  end
159
- logDebug "#{lLstSongsPlayRead.size} songs read for songs plays: #{lLstSongsPlayRead.join(', ')}"
159
+ log_debug "#{lLstSongsPlayRead.size} songs read for songs plays: #{lLstSongsPlayRead.join(', ')}"
160
160
  if (!lLstRecoverableObjectsForSongPlays.empty?)
161
- oStatsProxy.addRecoverableOrder(lLstRecoverableObjectsForSongPlays, ['Song plays'])
161
+ oStatsProxy.add_recoverable_order(lLstRecoverableObjectsForSongPlays, ['Song plays'])
162
162
  end
163
163
  end
164
164
 
165
165
  # Get the videos statistics
166
166
  #
167
- # Parameters:
167
+ # Parameters::
168
168
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
169
169
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
170
170
  def getVideos(oStatsProxy, iMechanizeAgent)
@@ -181,18 +181,18 @@ module StatsCollect
181
181
  lMatch = lStatsNodes[3].content.match(/^(\d*)% \((\d*) vote/)
182
182
  lRating = Integer(lMatch[1])
183
183
  lNbrLikes = Integer(lMatch[2])
184
- oStatsProxy.addStat(lVideoTitle, 'Video plays', lNbrPlays)
185
- oStatsProxy.addStat(lVideoTitle, 'Video comments', lNbrComments)
186
- oStatsProxy.addStat(lVideoTitle, 'Video likes', lNbrLikes)
187
- oStatsProxy.addStat(lVideoTitle, 'Video rating', lRating)
184
+ oStatsProxy.add_stat(lVideoTitle, 'Video plays', lNbrPlays)
185
+ oStatsProxy.add_stat(lVideoTitle, 'Video comments', lNbrComments)
186
+ oStatsProxy.add_stat(lVideoTitle, 'Video likes', lNbrLikes)
187
+ oStatsProxy.add_stat(lVideoTitle, 'Video rating', lRating)
188
188
  lLstVideosRead << lVideoTitle
189
189
  end
190
- logDebug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
190
+ log_debug "#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}"
191
191
  end
192
192
 
193
193
  # Get the blogs statistics
194
194
  #
195
- # Parameters:
195
+ # Parameters::
196
196
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
197
197
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
198
198
  # * *iConf* (<em>map<Symbol,Object></em>): The configuration
@@ -214,16 +214,16 @@ module StatsCollect
214
214
  if (!lStrReads.empty?)
215
215
  lNbrReads = Integer(lStrReads.match(/\((\d*)\)/)[1])
216
216
  end
217
- oStatsProxy.addStat(lBlogTitle, 'Blog likes', lNbrLikes)
218
- oStatsProxy.addStat(lBlogTitle, 'Blog reads', lNbrReads)
217
+ oStatsProxy.add_stat(lBlogTitle, 'Blog likes', lNbrLikes)
218
+ oStatsProxy.add_stat(lBlogTitle, 'Blog reads', lNbrReads)
219
219
  lLstBlogsRead << lBlogTitle
220
220
  end
221
- logDebug "#{lLstBlogsRead.size} blogs read: #{lLstBlogsRead.join(', ')}"
221
+ log_debug "#{lLstBlogsRead.size} blogs read: #{lLstBlogsRead.join(', ')}"
222
222
  end
223
223
 
224
224
  # Get the friends list
225
225
  #
226
- # Parameters:
226
+ # Parameters::
227
227
  # * *oStatsProxy* (_StatsProxy_): The stats proxy to be used to populate stats
228
228
  # * *iMechanizeAgent* (_Mechanize_): The agent reading pages
229
229
  def getFriendsList(oStatsProxy, iMechanizeAgent)
@@ -242,7 +242,7 @@ module StatsCollect
242
242
  iFriendNode.css('div div.vcard span.hcard a.nickname').each do |iFriendLinkNode|
243
243
  lFriendName = iFriendLinkNode['href'][1..-1]
244
244
  if (lFriendName == nil)
245
- logErr "Could not get friend's name for ID #{lFriendID}: #{iFriendLinkNode}"
245
+ log_err "Could not get friend's name for ID #{lFriendID}: #{iFriendLinkNode}"
246
246
  end
247
247
  lFriendsMap[lFriendID] = lFriendName
248
248
  end
@@ -265,7 +265,7 @@ module StatsCollect
265
265
  lIdxPage += 1
266
266
  end
267
267
  end
268
- oStatsProxy.addStat('Global', 'Friends list', lFriendsMap)
268
+ oStatsProxy.add_stat('Global', 'Friends list', lFriendsMap)
269
269
  end
270
270
 
271
271
  end