hubba 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -4
- data/README.md +146 -146
- data/Rakefile +30 -30
- data/lib/hubba/config.rb +51 -51
- data/lib/hubba/github.rb +210 -210
- data/lib/hubba/reposet.rb +83 -83
- data/lib/hubba/stats.rb +284 -262
- data/lib/hubba/update.rb +46 -46
- data/lib/hubba/update_traffic.rb +51 -51
- data/lib/hubba/version.rb +18 -18
- data/lib/hubba.rb +46 -46
- data/test/helper.rb +7 -7
- data/test/test_config.rb +31 -31
- metadata +8 -9
data/lib/hubba/update_traffic.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
module Hubba
|
2
|
-
|
3
|
-
|
4
|
-
###
|
5
|
-
## note: keep update traffic separate from update (basic) stats
|
6
|
-
## traffic stats require (personal access) token with push access!!
|
7
|
-
|
8
|
-
def self.update_traffic( hash_or_path='./repos.yml' ) ## move to reposet e.g. Reposet#update_status!!!!
|
9
|
-
h = if hash_or_path.is_a?( String ) ## assume it is a file path!!!
|
10
|
-
path = hash_or_path
|
11
|
-
YAML.load_file( path )
|
12
|
-
else
|
13
|
-
hash_or_path # assume its a hash / reposet already!!!
|
14
|
-
end
|
15
|
-
|
16
|
-
gh = Github.new
|
17
|
-
|
18
|
-
h.each do |org_with_counter,names|
|
19
|
-
|
20
|
-
## remove optional number from key e.g.
|
21
|
-
## mrhydescripts (3) => mrhydescripts
|
22
|
-
## footballjs (4) => footballjs
|
23
|
-
## etc.
|
24
|
-
org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
|
25
|
-
|
26
|
-
## puts " -- #{key_with_counter} [#{key}] --"
|
27
|
-
|
28
|
-
names.each do |name|
|
29
|
-
full_name = "#{org}/#{name}"
|
30
|
-
|
31
|
-
## puts " fetching stats #{count+1}/#{repo_count} - >#{full_name}<..."
|
32
|
-
stats = Stats.new( full_name )
|
33
|
-
stats.read
|
34
|
-
|
35
|
-
puts "update >#{full_name}< [1/4] - fetching repo traffic clones..."
|
36
|
-
clones = gh.repo_traffic_clones( full_name )
|
37
|
-
puts "update >#{full_name}< [2/4] - fetching repo traffic views..."
|
38
|
-
views = gh.repo_traffic_views( full_name )
|
39
|
-
puts "update >#{full_name}< [3/4] - fetching repo traffic popular paths..."
|
40
|
-
paths = gh.repo_traffic_popular_paths( full_name )
|
41
|
-
puts "update >#{full_name}< [4/4] - fetching repo traffic popular referrers..."
|
42
|
-
referrers = gh.repo_traffic_popular_referrers( full_name )
|
43
|
-
|
44
|
-
stats.update_traffic( clones: clones,
|
45
|
-
views: views,
|
46
|
-
paths: paths,
|
47
|
-
referrers: referrers )
|
48
|
-
stats.write
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
module Hubba
|
2
|
+
|
3
|
+
|
4
|
+
###
|
5
|
+
## note: keep update traffic separate from update (basic) stats
|
6
|
+
## traffic stats require (personal access) token with push access!!
|
7
|
+
|
8
|
+
def self.update_traffic( hash_or_path='./repos.yml' ) ## move to reposet e.g. Reposet#update_status!!!!
|
9
|
+
h = if hash_or_path.is_a?( String ) ## assume it is a file path!!!
|
10
|
+
path = hash_or_path
|
11
|
+
YAML.load_file( path )
|
12
|
+
else
|
13
|
+
hash_or_path # assume its a hash / reposet already!!!
|
14
|
+
end
|
15
|
+
|
16
|
+
gh = Github.new
|
17
|
+
|
18
|
+
h.each do |org_with_counter,names|
|
19
|
+
|
20
|
+
## remove optional number from key e.g.
|
21
|
+
## mrhydescripts (3) => mrhydescripts
|
22
|
+
## footballjs (4) => footballjs
|
23
|
+
## etc.
|
24
|
+
org = org_with_counter.sub( /\([0-9]+\)/, '' ).strip
|
25
|
+
|
26
|
+
## puts " -- #{key_with_counter} [#{key}] --"
|
27
|
+
|
28
|
+
names.each do |name|
|
29
|
+
full_name = "#{org}/#{name}"
|
30
|
+
|
31
|
+
## puts " fetching stats #{count+1}/#{repo_count} - >#{full_name}<..."
|
32
|
+
stats = Stats.new( full_name )
|
33
|
+
stats.read
|
34
|
+
|
35
|
+
puts "update >#{full_name}< [1/4] - fetching repo traffic clones..."
|
36
|
+
clones = gh.repo_traffic_clones( full_name )
|
37
|
+
puts "update >#{full_name}< [2/4] - fetching repo traffic views..."
|
38
|
+
views = gh.repo_traffic_views( full_name )
|
39
|
+
puts "update >#{full_name}< [3/4] - fetching repo traffic popular paths..."
|
40
|
+
paths = gh.repo_traffic_popular_paths( full_name )
|
41
|
+
puts "update >#{full_name}< [4/4] - fetching repo traffic popular referrers..."
|
42
|
+
referrers = gh.repo_traffic_popular_referrers( full_name )
|
43
|
+
|
44
|
+
stats.update_traffic( clones: clones,
|
45
|
+
views: views,
|
46
|
+
paths: paths,
|
47
|
+
referrers: referrers )
|
48
|
+
stats.write
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
52
|
end # module Hubba
|
data/lib/hubba/version.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
module Hubba
|
2
|
-
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
|
3
|
-
MINOR = 0
|
4
|
-
PATCH =
|
5
|
-
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
6
|
-
|
7
|
-
def self.version
|
8
|
-
VERSION
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.banner
|
12
|
-
"hubba/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.root
|
16
|
-
|
17
|
-
end
|
18
|
-
end # module Hubba
|
1
|
+
module Hubba
|
2
|
+
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
|
3
|
+
MINOR = 0
|
4
|
+
PATCH = 1
|
5
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
6
|
+
|
7
|
+
def self.version
|
8
|
+
VERSION
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.banner
|
12
|
+
"hubba/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.root
|
16
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
17
|
+
end
|
18
|
+
end # module Hubba
|
data/lib/hubba.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
# 3rd party (our own)
|
2
|
-
require 'webclient'
|
3
|
-
|
4
|
-
|
5
|
-
###############
|
6
|
-
## helpers
|
7
|
-
|
8
|
-
def save_json( path, data ) ## data - hash or array
|
9
|
-
File.open( path, 'w:utf-8' ) do |f|
|
10
|
-
f.write( JSON.pretty_generate( data ))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def save_yaml( path, data )
|
15
|
-
File.open( path, 'w:utf-8' ) do |f|
|
16
|
-
f.write( data.to_yaml )
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
# our own code
|
23
|
-
require 'hubba/version' # note: let version always go first
|
24
|
-
require 'hubba/config'
|
25
|
-
require 'hubba/github'
|
26
|
-
require 'hubba/reposet'
|
27
|
-
|
28
|
-
### update stats (github data) machinery
|
29
|
-
require 'hubba/stats'
|
30
|
-
require 'hubba/update'
|
31
|
-
require 'hubba/update_traffic'
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
############
|
37
|
-
# add convenience alias for alternate spelling - why? why not?
|
38
|
-
module Hubba
|
39
|
-
GitHub = Github
|
40
|
-
end
|
41
|
-
|
42
|
-
|
43
|
-
# say hello
|
44
|
-
puts Hubba.banner
|
45
|
-
|
46
|
-
|
1
|
+
# 3rd party (our own)
|
2
|
+
require 'webclient'
|
3
|
+
|
4
|
+
|
5
|
+
###############
|
6
|
+
## helpers
|
7
|
+
|
8
|
+
def save_json( path, data ) ## data - hash or array
|
9
|
+
File.open( path, 'w:utf-8' ) do |f|
|
10
|
+
f.write( JSON.pretty_generate( data ))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def save_yaml( path, data )
|
15
|
+
File.open( path, 'w:utf-8' ) do |f|
|
16
|
+
f.write( data.to_yaml )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
# our own code
|
23
|
+
require 'hubba/version' # note: let version always go first
|
24
|
+
require 'hubba/config'
|
25
|
+
require 'hubba/github'
|
26
|
+
require 'hubba/reposet'
|
27
|
+
|
28
|
+
### update stats (github data) machinery
|
29
|
+
require 'hubba/stats'
|
30
|
+
require 'hubba/update'
|
31
|
+
require 'hubba/update_traffic'
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
############
|
37
|
+
# add convenience alias for alternate spelling - why? why not?
|
38
|
+
module Hubba
|
39
|
+
GitHub = Github
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# say hello
|
44
|
+
puts Hubba.banner
|
45
|
+
|
46
|
+
|
data/test/helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# minitest setup
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
|
5
|
-
## our own code
|
6
|
-
require 'hubba'
|
7
|
-
|
1
|
+
# minitest setup
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
|
5
|
+
## our own code
|
6
|
+
require 'hubba'
|
7
|
+
|
data/test/test_config.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
###
|
2
|
-
# to run use
|
3
|
-
# ruby -I ./lib -I ./test test/test_config.rb
|
4
|
-
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
|
9
|
-
class TestConfig < MiniTest::Test
|
10
|
-
|
11
|
-
def test_config
|
12
|
-
Hubba.configure do |config|
|
13
|
-
config.user = 'user1'
|
14
|
-
config.password = 'password1'
|
15
|
-
# -or-
|
16
|
-
config.token = 'token1'
|
17
|
-
end
|
18
|
-
|
19
|
-
assert_equal 'user1', Hubba.configuration.user
|
20
|
-
assert_equal 'password1', Hubba.configuration.password
|
21
|
-
assert_equal 'token1', Hubba.configuration.token
|
22
|
-
|
23
|
-
assert_equal 'user1', Hubba.config.user
|
24
|
-
assert_equal 'password1', Hubba.config.password
|
25
|
-
assert_equal 'token1', Hubba.config.token
|
26
|
-
|
27
|
-
assert_equal './data', Hubba.configuration.data_dir
|
28
|
-
assert_equal './data', Hubba.config.data_dir
|
29
|
-
end
|
30
|
-
|
31
|
-
end # class TestConfig
|
1
|
+
###
|
2
|
+
# to run use
|
3
|
+
# ruby -I ./lib -I ./test test/test_config.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'helper'
|
7
|
+
|
8
|
+
|
9
|
+
class TestConfig < MiniTest::Test
|
10
|
+
|
11
|
+
def test_config
|
12
|
+
Hubba.configure do |config|
|
13
|
+
config.user = 'user1'
|
14
|
+
config.password = 'password1'
|
15
|
+
# -or-
|
16
|
+
config.token = 'token1'
|
17
|
+
end
|
18
|
+
|
19
|
+
assert_equal 'user1', Hubba.configuration.user
|
20
|
+
assert_equal 'password1', Hubba.configuration.password
|
21
|
+
assert_equal 'token1', Hubba.configuration.token
|
22
|
+
|
23
|
+
assert_equal 'user1', Hubba.config.user
|
24
|
+
assert_equal 'password1', Hubba.config.password
|
25
|
+
assert_equal 'token1', Hubba.config.token
|
26
|
+
|
27
|
+
assert_equal './data', Hubba.configuration.data_dir
|
28
|
+
assert_equal './data', Hubba.config.data_dir
|
29
|
+
end
|
30
|
+
|
31
|
+
end # class TestConfig
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubba
|
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
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webclient
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
53
|
+
version: '4.0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
60
|
+
version: '4.0'
|
61
61
|
description: hubba - (yet) another (lite) GitHub HTTP API client / library
|
62
62
|
email: ruby-talk@ruby-lang.org
|
63
63
|
executables: []
|
@@ -85,7 +85,7 @@ homepage: https://github.com/rubycoco/git
|
|
85
85
|
licenses:
|
86
86
|
- Public Domain
|
87
87
|
metadata: {}
|
88
|
-
post_install_message:
|
88
|
+
post_install_message:
|
89
89
|
rdoc_options:
|
90
90
|
- "--main"
|
91
91
|
- README.md
|
@@ -102,9 +102,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
|
-
|
106
|
-
|
107
|
-
signing_key:
|
105
|
+
rubygems_version: 3.4.10
|
106
|
+
signing_key:
|
108
107
|
specification_version: 4
|
109
108
|
summary: hubba - (yet) another (lite) GitHub HTTP API client / library
|
110
109
|
test_files: []
|