Class: Hubba::ReportSize

Inherits:
Report
  • Object
show all
Defined in:
lib/hubba/reports/reports/size.rb

Instance Method Summary collapse

Methods inherited from Report

#initialize, #save

Constructor Details

This class inherits a constructor from Hubba::Report

Instance Method Details

#buildObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hubba/reports/reports/size.rb', line 6

def build

##  add stars, last_updates, etc.
##  org description etc??

## note: orgs is orgs+users e.g. geraldb, yorobot etc
buf = String.new('')
buf << "# Size in KB"
buf << " - #{@stats.repos.size} Repos @ #{@stats.orgs.size} Orgs"
buf << "\n\n"


repos = @stats.repos.sort do |l,r|
  ## note: use reverse sort (right,left) - e.g. most stars first
  res = r.stats.size <=> l.stats.size
  res = l.full_name  <=> r.full_name    if res == 0
  res
end


repos.each_with_index do |repo,i|
  buf << "#{i+1}. #{repo.stats.size} kb - **#{repo.full_name}**\n"
end
buf << "<!-- break -->\n"   ## markdown hack: add a list end marker
buf << "\n\n"


buf
end