hubba-reports 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3457b7a9fc6910bbe26fa50975203b0123eee0e6
4
+ data.tar.gz: b3229be480bad757b65a987add58e1d78ddec955
5
+ SHA512:
6
+ metadata.gz: e609a974ebca9b84cef071a7661a4d4ba85738432baba7a8c52de3538062ddc3ecd8fd6ca4632b8f88a428f3d201d7d9db49540b372a6140836af1908ecdeb0c
7
+ data.tar.gz: '091fe8391851921111298102ad2670f39f82c3b4e50db072f28350a9424a477dadb34c40f462780cd0bd107f38a9501971074eaf38a4e962786238c28bd00409'
@@ -0,0 +1,4 @@
1
+ ### 0.0.1 / 2020-10-14
2
+
3
+ * Everything is new. First release.
4
+
@@ -0,0 +1,27 @@
1
+ CHANGELOG.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ lib/hubba/reports.rb
6
+ lib/hubba/reports/folio.rb
7
+ lib/hubba/reports/reports/base.rb
8
+ lib/hubba/reports/reports/catalog.rb
9
+ lib/hubba/reports/reports/size.rb
10
+ lib/hubba/reports/reports/stars.rb
11
+ lib/hubba/reports/reports/summary.rb
12
+ lib/hubba/reports/reports/timeline.rb
13
+ lib/hubba/reports/reports/topics.rb
14
+ lib/hubba/reports/reports/traffic.rb
15
+ lib/hubba/reports/reports/traffic_pages.rb
16
+ lib/hubba/reports/reports/traffic_referrers.rb
17
+ lib/hubba/reports/reports/trending.rb
18
+ lib/hubba/reports/reports/updates.rb
19
+ lib/hubba/reports/stats.rb
20
+ lib/hubba/reports/version.rb
21
+ test/helper.rb
22
+ test/stats/j/jekyll~minima.json
23
+ test/stats/o/openblockchains~awesome-blockchains.json
24
+ test/stats/o/opendatajson~factbook.json.json
25
+ test/stats/p/poole~hyde.json
26
+ test/test_stats.rb
27
+ test/test_stats_tmp.rb
@@ -0,0 +1,177 @@
1
+ # hubba-reports
2
+
3
+ hubba-reports gem - auto-generate github statistics / analytics reports from github api data (stars, timeline, traffic, top pages, top referrers, etc.)
4
+
5
+ * home :: [github.com/rubycoco/git](https://github.com/rubycoco/git)
6
+ * bugs :: [github.com/rubycoco/git/issues](https://github.com/rubycoco/git/issues)
7
+ * gem :: [rubygems.org/gems/hubba-reports](https://rubygems.org/gems/hubba-reports)
8
+ * rdoc :: [rubydoc.info/gems/hubba-reports](http://rubydoc.info/gems/hubba-reports)
9
+
10
+
11
+
12
+ ## Usage
13
+
14
+ ### Step 0: Data, Data, Data
15
+
16
+ See the [hubba gem](https://github.com/rubycoco/git/tree/master/hubba) on how to collect github data (daily, weekly, monthly, etc.).
17
+
18
+
19
+
20
+ ### Generate some statistics / reports
21
+
22
+
23
+ Hubba has four built-in reports (for now):
24
+
25
+ - `ReportSummary` - A-Z list of your repos by orgs with stars and size in kb
26
+ - `ReportStars` - your repos ranked by stars
27
+ - `ReportTimeline` - your repos in reverse chronological order by creation
28
+ - `ReportUpdates` - your repos in reverse chronological order by last commit
29
+
30
+
31
+ If you only generate a single report, use:
32
+
33
+ ``` ruby
34
+ require 'hubba/reports'
35
+
36
+ report = Hubba::ReportSummary.new( './repos.yml' )
37
+ report.save( './SUMMARY.md' )
38
+ ```
39
+
40
+
41
+ If you generate more reports, (re)use the in-memory statistics cache / object:
42
+
43
+ ``` ruby
44
+ stats = Hubba.stats( './repos.yml' )
45
+
46
+ report = Hubba::ReportSummary.new( stats )
47
+ report.save( './SUMMARY.md' )
48
+
49
+ report = Hubba::ReportStars.new( stats )
50
+ report.save( './STARS.md' )
51
+
52
+ report = Hubba::ReportTimeline.new( stats )
53
+ report.save( './TIMELINE.md' )
54
+
55
+ report = Hubba::ReportUpdates.new( stats )
56
+ report.save( './UPDATES.md' )
57
+ ```
58
+
59
+
60
+ ### Report Examples
61
+
62
+ #### Report Example - Summary
63
+
64
+ A-Z list of your repos by orgs with stars and size in kb.
65
+ Results in:
66
+
67
+ ---
68
+
69
+ > ### geraldb _(11)_
70
+ >
71
+ > **austria** ★1 (552 kb) · **catalog** ★3 (156 kb) · **chelitas** ★1 (168 kb) · **geraldb.github.io** ★1 (520 kb) · **logos** ★1 (363 kb) · **sandbox** ★2 (529 kb) · **talks** ★200 (16203 kb) · **web-proxy-win** ★8 (152 kb) · **webcomponents** ★1 (164 kb) · **webpub-reader** ★3 (11 kb) · **wine.db.tools** ★1 (252 kb)
72
+ >
73
+ > ...
74
+
75
+ ---
76
+
77
+ (Live Example - [`SUMMARY.md`](https://github.com/yorobot/backup/blob/master/SUMMARY.md))
78
+
79
+
80
+ #### Report Example - Stars
81
+
82
+ Your repos ranked by stars. Results in:
83
+
84
+ ---
85
+
86
+ > 1. ★2936 **openblockchains/awesome-blockchains** (2514 kb)
87
+ > 2. ★851 **planetjekyll/awesome-jekyll-plugins** (148 kb)
88
+ > 3. ★604 **factbook/factbook.json** (7355 kb)
89
+ > 4. ★593 **openfootball/football.json** (2135 kb)
90
+ > 5. ★570 **openmundi/world.db** (1088 kb)
91
+ > 6. ★552 **openblockchains/programming-blockchains** (552 kb)
92
+ > 7. ★547 **mundimark/awesome-markdown** (83 kb)
93
+ > 8. ★532 **planetjekyll/awesome-jekyll** (110 kb)
94
+ > 9. ★489 **cryptocopycats/awesome-cryptokitties** (4154 kb)
95
+ > 10. ★445 **openfootball/world-cup** (638 kb)
96
+ >
97
+ > ...
98
+
99
+ ---
100
+
101
+ (Live Example: [`STARS.md`](https://github.com/yorobot/backup/blob/master/STARS.md))
102
+
103
+
104
+ #### Report Example - Timeline
105
+
106
+ Your repos in reverse chronological order by creation.
107
+ Results in:
108
+
109
+ ---
110
+
111
+ > ## 2020
112
+ >
113
+ > ### 9
114
+ >
115
+ > - 2020-09-18 ★1 **yorobot/workflow** (83 kb)
116
+ >
117
+ > ### 6
118
+ >
119
+ > - 2020-06-27 ★2 **yorobot/sport.db.more** (80 kb)
120
+ > - 2020-06-24 ★1 **yorobot/stage** (554 kb)
121
+ > - 2020-06-11 ★1 **yorobot/cache.csv** (336 kb)
122
+ >
123
+ > ...
124
+
125
+ ---
126
+
127
+ (Live Example: [`TIMELINE.md`](https://github.com/yorobot/backup/blob/master/TIMELINE.md))
128
+
129
+
130
+
131
+ #### Report Example - Updates
132
+
133
+ Your repos in reverse chronological order by last commit. Results in:
134
+
135
+ ---
136
+
137
+ > committed / pushed / updated / created
138
+ >
139
+ > - (1d) **yorobot/backup** ★4 - 2020-10-08 (=/=) / 2020-10-08 (=) / 2020-10-08 / 2015-04-04 - ‹› (1595 kb)
140
+ > - (1d) **yorobot/logs** ★1 - 2020-10-08 (=/=) / 2020-10-08 (=) / 2020-10-08 / 2016-09-13 - ‹› (172 kb)
141
+ > - (1d) **rubycoco/git** ★9 - 2020-10-08 (=/=) / 2020-10-08 (=) / 2020-10-08 / 2015-11-16 - ‹› (88 kb)
142
+ > - (1d) **openfootball/football.json** ★593 - 2020-10-08 (=/=) / 2020-10-08 (=) / 2020-10-08 / 2015-09-17 - ‹› (2135 kb)
143
+ > - (2d) **yorobot/workflow** ★1 - 2020-10-07 (=/=) / 2020-10-07 (=) / 2020-10-07 / 2020-09-18 - ‹› (83 kb)
144
+ > - (2d) **rubycoco/webclient** ★5 - 2020-10-07 (=/=) / 2020-10-07 (=) / 2020-10-07 / 2012-06-02 - ‹› (39 kb)
145
+ > - (3d) **footballcsv/belgium** ★1 - 2020-10-06 (=/=) / 2020-10-06 (=) / 2020-10-06 / 2014-07-25 - ‹› (314 kb)
146
+ > - (3d) **footballcsv/england** ★105 - 2020-10-06 (=/=) / 2020-10-06 (=) / 2020-10-06 / 2014-07-23 - ‹› (8666 kb)
147
+ > - (3d) **footballcsv/austria** ★1 - 2020-10-06 (=/=) / 2020-10-06 (=) / 2020-10-06 / 2018-07-16 - ‹› (91 kb)
148
+ > - (3d) **footballcsv/espana** ★15 - 2020-10-06 (=/=) / 2020-10-06 (=) / 2020-10-06 / 2014-07-23 - ‹› (1107 kb)
149
+ > - (3d) **footballcsv/deutschland** ★5 - 2020-10-06 (=/=) / 2020-10-06 (=) / 2020-10-06 / 2014-07-25 - ‹› (1343 kb)
150
+ >
151
+ > ...
152
+
153
+ ---
154
+
155
+ (Live Example: [`UPDATES.md`](https://github.com/yorobot/backup/blob/master/UPDATES.md))
156
+
157
+
158
+
159
+ That's all for now.
160
+
161
+
162
+
163
+ ## Installation
164
+
165
+ Use
166
+
167
+ gem install hubba-reports
168
+
169
+ or add the gem to your Gemfile
170
+
171
+ gem 'hubba-reports'
172
+
173
+
174
+ ## License
175
+
176
+ The `hubba` scripts are dedicated to the public domain.
177
+ Use it as you please with no restrictions whatsoever.
@@ -0,0 +1,30 @@
1
+ require 'hoe'
2
+ require './lib/hubba/reports/version.rb'
3
+
4
+ Hoe.spec 'hubba-reports' do
5
+
6
+ self.version = HubbaReports::VERSION
7
+
8
+ self.summary = 'hubba-reports - auto-generate github statistics / analytics reports from github api data (stars, timeline, traffic, top pages, top referrers, etc.)'
9
+ self.description = summary
10
+
11
+ self.urls = { home: 'https://github.com/rubycoco/git' }
12
+
13
+ self.author = 'Gerald Bauer'
14
+ self.email = 'ruby-talk@ruby-lang.org'
15
+
16
+ # switch extension to .markdown for gihub formatting
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'CHANGELOG.md'
19
+
20
+ self.extra_deps = [
21
+ ['hubba', '>= 0.7.0']
22
+ ]
23
+
24
+ self.licenses = ['Public Domain']
25
+
26
+ self.spec_extras = {
27
+ required_ruby_version: '>= 2.2.2'
28
+ }
29
+
30
+ end
@@ -0,0 +1,42 @@
1
+ require 'hubba'
2
+
3
+
4
+ ######
5
+ # our own code
6
+ require 'hubba/reports/version' # note: let version always go first
7
+ require 'hubba/reports/stats'
8
+ require 'hubba/reports/folio'
9
+
10
+ require 'hubba/reports/reports/base'
11
+ require 'hubba/reports/reports/catalog'
12
+ require 'hubba/reports/reports/size'
13
+ require 'hubba/reports/reports/stars'
14
+ require 'hubba/reports/reports/summary'
15
+ require 'hubba/reports/reports/timeline'
16
+ require 'hubba/reports/reports/topics'
17
+ require 'hubba/reports/reports/traffic_pages'
18
+ require 'hubba/reports/reports/traffic_referrers'
19
+ require 'hubba/reports/reports/traffic'
20
+ require 'hubba/reports/reports/trending'
21
+ require 'hubba/reports/reports/updates'
22
+
23
+
24
+
25
+
26
+ module Hubba
27
+ def self.stats( hash_or_path='./repos.yml' ) ## use read_stats or such - why? why not?
28
+ h = if hash_or_path.is_a?( String ) ## assume it is a file path!!!
29
+ path = hash_or_path
30
+ YAML.load_file( path )
31
+ else
32
+ hash_or_path # assume its a hash / reposet already!!!
33
+ end
34
+
35
+ Folio.new( h ) ## wrap in "easy-access" facade / wrapper
36
+ end ## method stats
37
+ end # module Hubba
38
+
39
+
40
+ # say hello
41
+ puts HubbaReports.banner
42
+
@@ -0,0 +1,60 @@
1
+ module Hubba
2
+
3
+ class Folio # todo/check: use a different name e.g (Port)Folio, Cache, Summary, (Data)Base, Census, Catalog, Collection, Index, Register or such???
4
+ class Repo ## (nested) class
5
+
6
+ attr_reader :owner,
7
+ :name
8
+
9
+ def initialize( owner, name )
10
+ @owner = owner ## rename to login, username - why? why not?
11
+ @name = name ## rename to reponame ??
12
+ end
13
+
14
+ def full_name() "#{owner}/#{name}"; end
15
+
16
+ def stats
17
+ ## note: load stats on demand only (first access) for now - why? why not?
18
+ @stats ||= begin
19
+ stats = Stats.new( full_name )
20
+ stats.read
21
+ stats
22
+ end
23
+ end
24
+
25
+ def diff
26
+ @diff ||= stats.calc_diff_stars( samples: 3, days: 30 )
27
+ end
28
+ end # (nested) class Repo
29
+
30
+
31
+ attr_reader :orgs, :repos
32
+
33
+ def initialize( h )
34
+ @orgs = [] # orgs and users -todo/check: use better name - logins or owners? why? why not?
35
+ @repos = []
36
+ add( h )
37
+
38
+ puts "#{@repos.size} repos @ #{@orgs.size} orgs"
39
+ end
40
+
41
+ #############
42
+ ## private helpes
43
+ def add( h ) ## add repos.yml set
44
+ h.each do |org_with_counter, names|
45
+ ## remove optional number from key e.g.
46
+ ## mrhydescripts (3) => mrhydescripts
47
+ ## footballjs (4) => footballjs
48
+ ## etc.
49
+ org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
50
+ repos = []
51
+ names.each do |name|
52
+ repo = Repo.new( org, name )
53
+ repos << repo
54
+ end
55
+ @orgs << [org, repos]
56
+ @repos += repos
57
+ end
58
+ end
59
+ end # class Folio
60
+ end # module Hubba
@@ -0,0 +1,36 @@
1
+ module Hubba
2
+
3
+ class Report
4
+ def initialize( stats_or_hash_or_path=Hubba.stats )
5
+ ## puts "[debug] Report#initialize:"
6
+ ## pp stats_or_hash_or_path if stats_or_hash_or_path.is_a?( String )
7
+
8
+ @stats = if stats_or_hash_or_path.is_a?( String ) ||
9
+ stats_or_hash_or_path.is_a?( Hash )
10
+ hash_or_path = stats_or_hash_or_path
11
+ Hubba.stats( hash_or_path )
12
+ else
13
+ stats_or_hash_or_path ## assume Summary/Stats - todo/fix: double check!!!
14
+ end
15
+ end
16
+
17
+
18
+ def save( path )
19
+ buf = build
20
+
21
+ banner =<<TXT
22
+ Auto-generated github (statistics) report;
23
+ built with [Hubba v#{HubbaReports::VERSION}](https://github.com/rubycoco/git/tree/master/hubba-reports).
24
+
25
+
26
+ TXT
27
+
28
+ puts "writing report >#{path}< ..."
29
+ File.open( path, "w:utf-8" ) do |f|
30
+ f.write( banner ) ## add banner for now - why? why not?
31
+ f.write( buf )
32
+ end
33
+ end
34
+ end ## class Report
35
+
36
+ end # module Hubba
@@ -0,0 +1,44 @@
1
+ module Hubba
2
+
3
+
4
+ class ReportCatalog < Report
5
+
6
+ def build
7
+
8
+ ## note: orgs is orgs+users e.g. geraldb, yorobot etc
9
+ buf = String.new('')
10
+ buf << "# Catalog"
11
+ buf << " - #{@stats.repos.size} Repos @ #{@stats.orgs.size} Orgs"
12
+ buf << "\n\n"
13
+
14
+
15
+ @stats.orgs.each do |org|
16
+ name = org[0]
17
+ repos = org[1]
18
+ buf << "### #{name} _(#{repos.size})_\n"
19
+ buf << "\n"
20
+
21
+ ### add stats for repos
22
+ repos.each do |repo|
23
+
24
+ buf << "**#{repo.name}** ★#{repo.stats.stars} (#{repo.stats.size} kb)"
25
+ buf << " <br>\n"
26
+
27
+ buf << "_#{repo.stats.description}_"
28
+
29
+ if repo.stats.topics && repo.stats.topics.size > 0
30
+ buf << " <br>\n"
31
+ ## wrap in backtip (verbatim code)
32
+ buf << repo.stats.topics.map {|topic| "`#{topic}`" }.join( ' · ' ) ## use interpunct? - was: • (bullet)
33
+ end
34
+ buf << "\n\n"
35
+ end
36
+
37
+ buf << "\n"
38
+ end
39
+
40
+ buf
41
+ end # method build
42
+ end # class ReportCatalog
43
+
44
+ end # module Hubba
@@ -0,0 +1,38 @@
1
+ module Hubba
2
+
3
+
4
+ class ReportSize < Report
5
+
6
+ def build
7
+
8
+ ## add stars, last_updates, etc.
9
+ ## org description etc??
10
+
11
+ ## note: orgs is orgs+users e.g. geraldb, yorobot etc
12
+ buf = String.new('')
13
+ buf << "# Size in KB"
14
+ buf << " - #{@stats.repos.size} Repos @ #{@stats.orgs.size} Orgs"
15
+ buf << "\n\n"
16
+
17
+
18
+ repos = @stats.repos.sort do |l,r|
19
+ ## note: use reverse sort (right,left) - e.g. most stars first
20
+ res = r.stats.size <=> l.stats.size
21
+ res = l.full_name <=> r.full_name if res == 0
22
+ res
23
+ end
24
+
25
+
26
+ repos.each_with_index do |repo,i|
27
+ buf << "#{i+1}. #{repo.stats.size} kb - **#{repo.full_name}**\n"
28
+ end
29
+ buf << "<!-- break -->\n" ## markdown hack: add a list end marker
30
+ buf << "\n\n"
31
+
32
+
33
+ buf
34
+ end # method build
35
+ end # class ReportSize
36
+
37
+
38
+ end # module Hubba