hubba-reports 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/README.md +11 -3
- data/lib/hubba/reports.rb +1 -0
- data/lib/hubba/reports/reports/languages.rb +97 -0
- data/lib/hubba/reports/reports/traffic.rb +18 -0
- data/lib/hubba/reports/reports/traffic_pages.rb +16 -0
- data/lib/hubba/reports/reports/traffic_referrers.rb +17 -0
- data/lib/hubba/reports/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70dc07063bf62e795d5108be9264de6775e03d98
|
4
|
+
data.tar.gz: 2cd758aeb541c1b5681f424d3114a2fbb157d8fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55d57dabc6cd034c292ae3d25d1b31d65a065e5604c50894417754ca060e14124b66d07d82ae0f3df9adef3bfcbb70e90cf0aec0dd80a2a06edc682518a03504
|
7
|
+
data.tar.gz: 21c0b6274481cab436da6d43961e7fd8fad508069793525324fa501d07e47201283eef510080d0af1a7f386b4113b0ddc482cc850481c953eb203cac37217ba5
|
data/Manifest.txt
CHANGED
@@ -6,6 +6,7 @@ lib/hubba/reports.rb
|
|
6
6
|
lib/hubba/reports/folio.rb
|
7
7
|
lib/hubba/reports/reports/base.rb
|
8
8
|
lib/hubba/reports/reports/catalog.rb
|
9
|
+
lib/hubba/reports/reports/languages.rb
|
9
10
|
lib/hubba/reports/reports/size.rb
|
10
11
|
lib/hubba/reports/reports/stars.rb
|
11
12
|
lib/hubba/reports/reports/summary.rb
|
data/README.md
CHANGED
@@ -17,18 +17,24 @@ See the [hubba gem](https://github.com/rubycoco/git/tree/master/hubba) on how to
|
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
-
###
|
20
|
+
### Statistics / reports
|
21
21
|
|
22
22
|
|
23
|
-
Hubba has
|
23
|
+
Hubba has about a dozen built-in reports (for now):
|
24
24
|
|
25
25
|
- `ReportSummary` - A-Z list of your repos by orgs with stars and size in kb
|
26
26
|
- `ReportStars` - your repos ranked by stars
|
27
27
|
- `ReportTimeline` - your repos in reverse chronological order by creation
|
28
28
|
- `ReportUpdates` - your repos in reverse chronological order by last commit
|
29
|
+
- ...
|
29
30
|
|
31
|
+
Look into the [/reports](https://github.com/rubycoco/git/tree/master/hubba-reports/lib/hubba/reports/reports)
|
32
|
+
directory for all reports and, yes, you can - on how to code your very own.
|
30
33
|
|
31
|
-
|
34
|
+
|
35
|
+
#### Generate statistic / reports
|
36
|
+
|
37
|
+
If you only generate a single built-in report, use:
|
32
38
|
|
33
39
|
``` ruby
|
34
40
|
require 'hubba/reports'
|
@@ -54,6 +60,8 @@ report.save( './TIMELINE.md' )
|
|
54
60
|
|
55
61
|
report = Hubba::ReportUpdates.new( stats )
|
56
62
|
report.save( './UPDATES.md' )
|
63
|
+
|
64
|
+
# ...
|
57
65
|
```
|
58
66
|
|
59
67
|
|
data/lib/hubba/reports.rb
CHANGED
@@ -9,6 +9,7 @@ require 'hubba/reports/folio'
|
|
9
9
|
|
10
10
|
require 'hubba/reports/reports/base'
|
11
11
|
require 'hubba/reports/reports/catalog'
|
12
|
+
require 'hubba/reports/reports/languages'
|
12
13
|
require 'hubba/reports/reports/size'
|
13
14
|
require 'hubba/reports/reports/stars'
|
14
15
|
require 'hubba/reports/reports/summary'
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Hubba
|
2
|
+
|
3
|
+
|
4
|
+
class ReportLanguages < Report
|
5
|
+
|
6
|
+
def build
|
7
|
+
|
8
|
+
## note: orgs is orgs+users e.g. geraldb, yorobot etc
|
9
|
+
buf = String.new('')
|
10
|
+
buf << "# Languages"
|
11
|
+
buf << " - #{@stats.repos.size} Repos @ #{@stats.orgs.size} Orgs"
|
12
|
+
buf << "\n\n"
|
13
|
+
|
14
|
+
|
15
|
+
buf << "language lines in byte / language used in repos (count)"
|
16
|
+
buf << "\n\n"
|
17
|
+
|
18
|
+
|
19
|
+
### note: skip repos WITHOUT languages stats e.g. empty hash {}
|
20
|
+
repos = @stats.repos.select do |repo|
|
21
|
+
langs = repo.stats.languages
|
22
|
+
res = langs && langs.size > 0 ## return true if present and non-empty hash too
|
23
|
+
puts " no languages - skipping >#{repo.full_name}<..." unless res
|
24
|
+
res
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
## collect all langs with refs to repos
|
29
|
+
## note/warn: do NOT use langs as local variable - will RESET this langs here!!!
|
30
|
+
langs = {}
|
31
|
+
|
32
|
+
repos.each do |repo|
|
33
|
+
puts "#{repo.full_name}:"
|
34
|
+
pp repo.stats.languages
|
35
|
+
repo.stats.languages.each do |lang,bytes|
|
36
|
+
# note: keep using all string (NOT symbol) keys - why? why not?
|
37
|
+
line = langs[ lang ] ||= { 'count' => 0, 'bytes' => 0 }
|
38
|
+
line[ 'count' ] += 1
|
39
|
+
line[ 'bytes' ] += bytes
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
langs_by_bytes = langs.sort {|(llang,lline),(rlang,rline)|
|
44
|
+
res = rline['bytes'] <=> lline['bytes']
|
45
|
+
res = llang <=> rlang if res == 0
|
46
|
+
res
|
47
|
+
}
|
48
|
+
.to_h # convert back to hash (from array)
|
49
|
+
|
50
|
+
|
51
|
+
bytes_total = langs.reduce(0) {|sum,(lang,line)| sum+line['bytes'] }
|
52
|
+
langs_by_bytes.each_with_index do |(lang, line),i|
|
53
|
+
bytes = line['bytes']
|
54
|
+
percent = Float(100*bytes)/Float(bytes_total)
|
55
|
+
|
56
|
+
buf << "#{i+1}. "
|
57
|
+
buf << "#{bytes} (#{('%2.2f' % percent)}%) "
|
58
|
+
buf << "**#{lang}** "
|
59
|
+
buf << "_(#{line['count']})_"
|
60
|
+
buf << "\n"
|
61
|
+
end
|
62
|
+
buf << "<!-- break -->\n" ## markdown hack: add a list end marker
|
63
|
+
buf << "\n\n"
|
64
|
+
|
65
|
+
|
66
|
+
buf << "Languages used in repos (count):"
|
67
|
+
buf << "\n\n"
|
68
|
+
|
69
|
+
|
70
|
+
langs_by_count = langs.sort {|(llang,lline),(rlang,rline)|
|
71
|
+
res = rline['count'] <=> lline['count']
|
72
|
+
res = llang <=> rlang if res == 0
|
73
|
+
res
|
74
|
+
}
|
75
|
+
.to_h # convert back to hash (from array)
|
76
|
+
|
77
|
+
|
78
|
+
count_total = repos.size # note: use (filtered) repos for count total
|
79
|
+
langs_by_count.each_with_index do |(lang, line),i|
|
80
|
+
count = line['count']
|
81
|
+
percent = Float(100*count)/Float(count_total)
|
82
|
+
|
83
|
+
buf << "#{i+1}. "
|
84
|
+
buf << "#{count} (#{('%2.2f' % percent)}%) "
|
85
|
+
buf << "**#{lang}** "
|
86
|
+
buf << "(#{line['bytes']} bytes)"
|
87
|
+
buf << "\n"
|
88
|
+
end
|
89
|
+
buf << "<!-- break -->\n" ## markdown hack: add a list end marker
|
90
|
+
buf << "\n\n"
|
91
|
+
|
92
|
+
|
93
|
+
buf
|
94
|
+
end # method build
|
95
|
+
end # class ReportLanguages
|
96
|
+
|
97
|
+
end # module Hubba
|
@@ -60,6 +60,24 @@ repos_by_org = repos.group_by { |repo|
|
|
60
60
|
.to_h ## convert back to hash
|
61
61
|
|
62
62
|
|
63
|
+
### start with summary
|
64
|
+
## limit to top 10 or top 20 - why? why not?
|
65
|
+
repos_by_org.each_with_index do |(owner, repos),i|
|
66
|
+
views = repos.reduce(0) {|sum,repo| sum+repo.stats.traffic['summary']['views']['count'] }
|
67
|
+
clones = repos.reduce(0) {|sum,repo| sum+repo.stats.traffic['summary']['clones']['count'] }
|
68
|
+
|
69
|
+
buf << "#{i+1}. **#{owner}** views: #{views}, clones: #{clones} _(#{repos.size})_"
|
70
|
+
buf << "\n"
|
71
|
+
end
|
72
|
+
|
73
|
+
buf << "<!-- break -->\n" ## markdown hack: add a list end marker
|
74
|
+
buf << "\n\n"
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
buf << "Details:" ## markdown hack: add a list end marker
|
79
|
+
buf << "\n\n"
|
80
|
+
|
63
81
|
repos_by_org.each_with_index do |(owner, repos),i|
|
64
82
|
views = repos.reduce(0) {|sum,repo| sum+repo.stats.traffic['summary']['views']['count'] }
|
65
83
|
clones = repos.reduce(0) {|sum,repo| sum+repo.stats.traffic['summary']['clones']['count'] }
|
@@ -85,6 +85,22 @@ lines_by_path = lines.group_by { |line|
|
|
85
85
|
.to_h ## convert back to hash
|
86
86
|
|
87
87
|
|
88
|
+
### start with summary
|
89
|
+
## limit to top 10 or top 20 - why? why not?
|
90
|
+
lines_by_path.each_with_index do |(path, lines),i|
|
91
|
+
count = lines.reduce(0) {|sum,line| sum+line['count']}
|
92
|
+
buf << "#{i+1}. **#{path}** #{count} _(#{lines.size})_"
|
93
|
+
buf << "\n"
|
94
|
+
end
|
95
|
+
|
96
|
+
buf << "<!-- break -->\n" ## markdown hack: add a list end marker
|
97
|
+
buf << "\n\n"
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
buf << "Details:"
|
102
|
+
buf << "\n\n"
|
103
|
+
|
88
104
|
lines_by_path.each_with_index do |(path, lines),i|
|
89
105
|
count = lines.reduce(0) {|sum,line| sum+line['count']}
|
90
106
|
buf << "#{i+1}. **#{path}** #{count} _(#{lines.size})_"
|
@@ -76,6 +76,23 @@ lines_by_referrer = lines.group_by { |line| line['referrer'] }
|
|
76
76
|
.to_h ## convert back to hash
|
77
77
|
|
78
78
|
|
79
|
+
### start with summary
|
80
|
+
## limit to top 10 or top 20 - why? why not?
|
81
|
+
lines_by_referrer.each_with_index do |(referrer, lines),i|
|
82
|
+
count = lines.reduce(0) {|sum,line| sum+line['count']}
|
83
|
+
buf << "#{i+1}. **#{referrer}** #{count} _(#{lines.size})_"
|
84
|
+
buf << "\n"
|
85
|
+
end
|
86
|
+
|
87
|
+
buf << "<!-- break -->\n" ## markdown hack: add a list end marker
|
88
|
+
buf << "\n\n"
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
buf << "Details:"
|
93
|
+
buf << "\n\n"
|
94
|
+
|
95
|
+
|
79
96
|
lines_by_referrer.each_with_index do |(referrer, lines),i|
|
80
97
|
count = lines.reduce(0) {|sum,line| sum+line['count']}
|
81
98
|
buf << "#{i+1}. **#{referrer}** #{count} _(#{lines.size})_"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubba-reports
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hubba
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- lib/hubba/reports/folio.rb
|
77
77
|
- lib/hubba/reports/reports/base.rb
|
78
78
|
- lib/hubba/reports/reports/catalog.rb
|
79
|
+
- lib/hubba/reports/reports/languages.rb
|
79
80
|
- lib/hubba/reports/reports/size.rb
|
80
81
|
- lib/hubba/reports/reports/stars.rb
|
81
82
|
- lib/hubba/reports/reports/summary.rb
|