Class: Hubba::ReportTopics
- Defined in:
- lib/hubba/reports/reports/topics.rb
Instance Method Summary collapse
Methods inherited from Report
Constructor Details
This class inherits a constructor from Hubba::Report
Instance Method Details
#build ⇒ Object
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 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/hubba/reports/reports/topics.rb', line 6 def build ## note: orgs is orgs+users e.g. geraldb, yorobot etc buf = String.new('') buf << "# Topics" buf << " - #{@stats.repos.size} Repos @ #{@stats.orgs.size} Orgs" buf << "\n\n" topics = {} ## collect all topics with refs to repos @stats.repos.each do |repo| repo.stats.topics.each do |topic| repos = topics[ topic ] ||= [] repos << repo end end topics = topics.sort {|(ltopic,_),(rtopic,_)| ltopic <=> rtopic ## sort topic by a-z } .to_h # convert back to hash (from array) topics.each do |topic,repos| buf << "`#{topic}` _(#{repos.size})_\n" end buf << "\n" topics.each do |topic,repos| buf << "## `#{topic}` _(#{repos.size})_\n" buf << repos.map {|repo| repo.full_name }.join( ' · ' ) ## use interpunct? - was: • (bullet) buf << "\n\n" end buf end |