hubba 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/HISTORY.md +4 -0
- data/Manifest.txt +13 -0
- data/README.md +20 -0
- data/Rakefile +30 -0
- data/lib/hubba.rb +23 -0
- data/lib/hubba/cache.rb +61 -0
- data/lib/hubba/client.rb +46 -0
- data/lib/hubba/github.rb +83 -0
- data/lib/hubba/version.rb +21 -0
- data/test/cache/users~geraldb~orgs.json +46 -0
- data/test/cache/users~geraldb~repos.json +263 -0
- data/test/helper.rb +9 -0
- data/test/test_cache.rb +46 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9937213efe86ccdf1201342462c78ab41a5989ab
|
4
|
+
data.tar.gz: ebaa428b0f7ed4fcf42faacc3cf4246f49b82df6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 09c25c8a5f786a22639e437905f0f44223ac5722bac018243a56ab830651f3b4c6592bef0c6738cc880e5da4f720b334eabb54c0ccf0aaa6af19cae1c2bcbd6b
|
7
|
+
data.tar.gz: cb1f795ea7fb06f1804f1cf40350635305d22a6d96e45a3242fd477054dbdf35f86a8d74b55c8ab2755721108e884ff0b6a8505d651836a8f1a95bf85b4d3967
|
data/HISTORY.md
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
HISTORY.md
|
2
|
+
Manifest.txt
|
3
|
+
README.md
|
4
|
+
Rakefile
|
5
|
+
lib/hubba.rb
|
6
|
+
lib/hubba/cache.rb
|
7
|
+
lib/hubba/client.rb
|
8
|
+
lib/hubba/github.rb
|
9
|
+
lib/hubba/version.rb
|
10
|
+
test/cache/users~geraldb~orgs.json
|
11
|
+
test/cache/users~geraldb~repos.json
|
12
|
+
test/helper.rb
|
13
|
+
test/test_cache.rb
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# hubba
|
2
|
+
|
3
|
+
hubba gem - (yet) another (lite) GitHub HTTP API client / library
|
4
|
+
|
5
|
+
* home :: [github.com/rubylibs/hubba](https://github.com/rubylibs/hubba)
|
6
|
+
* bugs :: [github.com/rubylibs/hubba/issues](https://github.com/rubylibs/hubba/issues)
|
7
|
+
* gem :: [rubygems.org/gems/hubba](https://rubygems.org/gems/hubba)
|
8
|
+
* rdoc :: [rubydoc.info/gems/hubba](http://rubydoc.info/gems/hubba)
|
9
|
+
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
TBD
|
14
|
+
|
15
|
+
|
16
|
+
## License
|
17
|
+
|
18
|
+
The `hubba` scripts are dedicated to the public domain.
|
19
|
+
Use it as you please with no restrictions whatsoever.
|
20
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/hubba/version.rb'
|
3
|
+
|
4
|
+
Hoe.spec 'hubba' do
|
5
|
+
|
6
|
+
self.version = Hubba::VERSION
|
7
|
+
|
8
|
+
self.summary = 'hubba - (yet) another (lite) GitHub HTTP API client / library'
|
9
|
+
self.description = summary
|
10
|
+
|
11
|
+
self.urls = ['https://github.com/rubylibs/hubba']
|
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 = 'HISTORY.md'
|
19
|
+
|
20
|
+
self.extra_deps = [
|
21
|
+
['logutils' ],
|
22
|
+
]
|
23
|
+
|
24
|
+
self.licenses = ['Public Domain']
|
25
|
+
|
26
|
+
self.spec_extras = {
|
27
|
+
required_ruby_version: '>= 1.9.2'
|
28
|
+
}
|
29
|
+
|
30
|
+
end
|
data/lib/hubba.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require "net/https"
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'pp'
|
8
|
+
require 'json'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
|
12
|
+
# 3rd party gems/libs
|
13
|
+
require 'logutils'
|
14
|
+
|
15
|
+
# our own code
|
16
|
+
require 'hubba/version' # note: let version always go first
|
17
|
+
require 'hubba/cache'
|
18
|
+
require 'hubba/client'
|
19
|
+
require 'hubba/github'
|
20
|
+
|
21
|
+
|
22
|
+
# say hello
|
23
|
+
puts Hubba.banner if defined?($RUBYLIBS_DEBUG)
|
data/lib/hubba/cache.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hubba
|
4
|
+
|
5
|
+
class Cache ## lets you work with GitHub api "offline" using just a local cache of stored json
|
6
|
+
|
7
|
+
def initialize( dir )
|
8
|
+
@dir = dir
|
9
|
+
end
|
10
|
+
|
11
|
+
## fix/todo: cut of query string e.g. ?per_page=100 why? why not?
|
12
|
+
def get( request_uri )
|
13
|
+
## check if request_uri exists in local cache
|
14
|
+
basename = request_uri_to_basename( request_uri )
|
15
|
+
path = "#{@dir}/#{basename}.json"
|
16
|
+
if File.exist?( path )
|
17
|
+
text = File.read( path ) ## todo/fix: use File.read_utf8
|
18
|
+
json = JSON.parse( text )
|
19
|
+
else
|
20
|
+
nil ## todo/fix: raise exception - why? why not??
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def put( request_uri, obj )
|
25
|
+
basename = request_uri_to_basename( request_uri )
|
26
|
+
path = "#{@dir}/#{basename}.json"
|
27
|
+
|
28
|
+
if obj.is_a?( Resource ) ## note: for convenience support Resource obj too
|
29
|
+
data = obj.data
|
30
|
+
else
|
31
|
+
data = obj # assume Hash or Array -- todo: add support for String - why? why not??
|
32
|
+
end
|
33
|
+
|
34
|
+
File.open( path, 'w' ) do |f|
|
35
|
+
f.write JSON.pretty_generate( data )
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def request_uri_to_basename( request_uri )
|
41
|
+
## 1) cut off leading /
|
42
|
+
## 2) convert / to ~
|
43
|
+
## 3) remove (optional) query string (for now) - why? why not?
|
44
|
+
##
|
45
|
+
## e.g.
|
46
|
+
## '/users/geraldb' => 'users~geraldb',
|
47
|
+
## '/users/geraldb/repos' => 'users~geraldb~repos',
|
48
|
+
## '/users/geraldb/orgs' => 'users~geraldb~orgs',
|
49
|
+
## '/orgs/wikiscript/repos' => 'orgs~wikiscript~repos',
|
50
|
+
## '/orgs/planetjekyll/repos' => 'orgs~planetjekyll~repos',
|
51
|
+
## '/orgs/vienna-rb/repos' => 'orgs~vienna~rb.repos',
|
52
|
+
|
53
|
+
basename = request_uri[1..-1]
|
54
|
+
basename = basename.gsub( '/', '~')
|
55
|
+
basename = basename.sub( /\?.*\z/, '' ) ## note: must escape ? (use \z for $)
|
56
|
+
basename
|
57
|
+
end
|
58
|
+
|
59
|
+
end ## class Cache
|
60
|
+
|
61
|
+
end ## module Hubba
|
data/lib/hubba/client.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hubba
|
4
|
+
|
5
|
+
|
6
|
+
class Client
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
uri = URI.parse( "https://api.github.com" )
|
10
|
+
@http = Net::HTTP.new(uri.host, uri.port)
|
11
|
+
@http.use_ssl = true
|
12
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
13
|
+
end # method initialize
|
14
|
+
|
15
|
+
def get( request_uri )
|
16
|
+
puts "GET #{request_uri}"
|
17
|
+
|
18
|
+
req = Net::HTTP::Get.new( request_uri )
|
19
|
+
## req = Net::HTTP::Get.new( "/users/geraldb" )
|
20
|
+
## req = Net::HTTP::Get.new( "/users/geraldb/repos" )
|
21
|
+
req["User-Agent"] = "ruby/github.rb" ## required by GitHub API
|
22
|
+
req["Accept" ] = "application/vnd.github.v3+json" ## recommend by GitHub API
|
23
|
+
|
24
|
+
res = @http.request(req)
|
25
|
+
|
26
|
+
# Get specific header
|
27
|
+
# response["content-type"]
|
28
|
+
# => "text/html; charset=UTF-8"
|
29
|
+
|
30
|
+
# Iterate all response headers.
|
31
|
+
res.each_header do |key, value|
|
32
|
+
p "#{key} => #{value}"
|
33
|
+
end
|
34
|
+
# => "location => http://www.google.com/"
|
35
|
+
# => "content-type => text/html; charset=UTF-8"
|
36
|
+
# ...
|
37
|
+
|
38
|
+
json = JSON.parse( res.body )
|
39
|
+
## pp json
|
40
|
+
json
|
41
|
+
end # methdo get
|
42
|
+
|
43
|
+
end ## class Client
|
44
|
+
|
45
|
+
|
46
|
+
end # module Hubba
|
data/lib/hubba/github.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hubba
|
4
|
+
|
5
|
+
class Resource
|
6
|
+
attr_reader :data
|
7
|
+
def initialize( data )
|
8
|
+
@data = data
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Repos < Resource
|
13
|
+
def names
|
14
|
+
## sort by name
|
15
|
+
data.map { |item| item['name'] }.sort
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Orgs < Resource
|
20
|
+
def logins
|
21
|
+
## sort by name
|
22
|
+
data.map { |item| item['login'] }.sort
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
class Github
|
29
|
+
|
30
|
+
def initialize( cache_dir: './cache' )
|
31
|
+
@cache = Cache.new( cache_dir )
|
32
|
+
@client = Client.new
|
33
|
+
|
34
|
+
@offline = false
|
35
|
+
end
|
36
|
+
|
37
|
+
def offline!() @offline = true; end ## switch to offline - todo: find a "better" way - why? why not?
|
38
|
+
def offline?() @offline; end
|
39
|
+
|
40
|
+
|
41
|
+
def user( name )
|
42
|
+
Resource.new( get "/users/#{name}" )
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def user_repos( name )
|
47
|
+
Repos.new( get "/users/#{name}/repos" ) ## add ?per_page=100 - why? why not?
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
##
|
52
|
+
# note: pagination
|
53
|
+
# requests that return multiple items will be paginated to 30 items by default.
|
54
|
+
# You can specify further pages with the ?page parameter.
|
55
|
+
# For some resources, you can also set a custom page size up to 100
|
56
|
+
# with the ?per_page=100 parameter
|
57
|
+
|
58
|
+
def user_orgs( name )
|
59
|
+
Orgs.new( get "/users/#{name}/orgs?per_page=100" )
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def org( name )
|
64
|
+
Resource.new( get "/orgs/#{name}" )
|
65
|
+
end
|
66
|
+
|
67
|
+
def org_repos( name )
|
68
|
+
Repos.new( get "/orgs/#{name}/repos?per_page=100" )
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
private
|
73
|
+
def get( request_uri )
|
74
|
+
if offline?
|
75
|
+
@cache.get( request_uri )
|
76
|
+
else
|
77
|
+
@client.get( request_uri )
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end # class Github
|
82
|
+
|
83
|
+
end # module Hubba
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hubba
|
4
|
+
MAJOR = 0 ## todo: namespace inside version or something - why? why not??
|
5
|
+
MINOR = 1
|
6
|
+
PATCH = 0
|
7
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
8
|
+
|
9
|
+
def self.version
|
10
|
+
VERSION
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.banner
|
14
|
+
"hubba/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.root
|
18
|
+
"#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
|
19
|
+
end
|
20
|
+
end # module Hubba
|
21
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"login": "vienna-rb",
|
4
|
+
"id": 3541331,
|
5
|
+
"url": "https://api.github.com/orgs/vienna-rb",
|
6
|
+
"repos_url": "https://api.github.com/orgs/vienna-rb/repos",
|
7
|
+
"events_url": "https://api.github.com/orgs/vienna-rb/events",
|
8
|
+
"members_url": "https://api.github.com/orgs/vienna-rb/members{/member}",
|
9
|
+
"public_members_url": "https://api.github.com/orgs/vienna-rb/public_members{/member}",
|
10
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/3541331?v=3",
|
11
|
+
"description": null
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"login": "openbeer",
|
15
|
+
"id": 4464191,
|
16
|
+
"url": "https://api.github.com/orgs/openbeer",
|
17
|
+
"repos_url": "https://api.github.com/orgs/openbeer/repos",
|
18
|
+
"events_url": "https://api.github.com/orgs/openbeer/events",
|
19
|
+
"members_url": "https://api.github.com/orgs/openbeer/members{/member}",
|
20
|
+
"public_members_url": "https://api.github.com/orgs/openbeer/public_members{/member}",
|
21
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/4464191?v=3",
|
22
|
+
"description": "Open Public Domain Beer, Brewery n Brewpub Data - Incl. The Free World Beer Book"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"login": "slideshow-s9",
|
26
|
+
"id": 4464373,
|
27
|
+
"url": "https://api.github.com/orgs/slideshow-s9",
|
28
|
+
"repos_url": "https://api.github.com/orgs/slideshow-s9/repos",
|
29
|
+
"events_url": "https://api.github.com/orgs/slideshow-s9/events",
|
30
|
+
"members_url": "https://api.github.com/orgs/slideshow-s9/members{/member}",
|
31
|
+
"public_members_url": "https://api.github.com/orgs/slideshow-s9/public_members{/member}",
|
32
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/4464373?v=3",
|
33
|
+
"description": "Free Web Alternative to PowerPoint and Keynote Using Easy-to-Write and Easy-to-Read Plain Text Wiki-Style Markup"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"login": "openfootball",
|
37
|
+
"id": 4477026,
|
38
|
+
"url": "https://api.github.com/orgs/openfootball",
|
39
|
+
"repos_url": "https://api.github.com/orgs/openfootball/repos",
|
40
|
+
"events_url": "https://api.github.com/orgs/openfootball/events",
|
41
|
+
"members_url": "https://api.github.com/orgs/openfootball/members{/member}",
|
42
|
+
"public_members_url": "https://api.github.com/orgs/openfootball/public_members{/member}",
|
43
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/4477026?v=3",
|
44
|
+
"description": "Open Public Domain Football Data - Incl. The Free World Football Almanac"
|
45
|
+
}
|
46
|
+
]
|
@@ -0,0 +1,263 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 33192631,
|
4
|
+
"name": "austria",
|
5
|
+
"full_name": "geraldb/austria",
|
6
|
+
"owner": {
|
7
|
+
"login": "geraldb",
|
8
|
+
"id": 53281,
|
9
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/53281?v=3",
|
10
|
+
"gravatar_id": "",
|
11
|
+
"url": "https://api.github.com/users/geraldb",
|
12
|
+
"html_url": "https://github.com/geraldb",
|
13
|
+
"followers_url": "https://api.github.com/users/geraldb/followers",
|
14
|
+
"following_url": "https://api.github.com/users/geraldb/following{/other_user}",
|
15
|
+
"gists_url": "https://api.github.com/users/geraldb/gists{/gist_id}",
|
16
|
+
"starred_url": "https://api.github.com/users/geraldb/starred{/owner}{/repo}",
|
17
|
+
"subscriptions_url": "https://api.github.com/users/geraldb/subscriptions",
|
18
|
+
"organizations_url": "https://api.github.com/users/geraldb/orgs",
|
19
|
+
"repos_url": "https://api.github.com/users/geraldb/repos",
|
20
|
+
"events_url": "https://api.github.com/users/geraldb/events{/privacy}",
|
21
|
+
"received_events_url": "https://api.github.com/users/geraldb/received_events",
|
22
|
+
"type": "User",
|
23
|
+
"site_admin": false
|
24
|
+
},
|
25
|
+
"private": false,
|
26
|
+
"html_url": "https://github.com/geraldb/austria",
|
27
|
+
"description": "open data and scripts for austria (österreich)",
|
28
|
+
"fork": false,
|
29
|
+
"url": "https://api.github.com/repos/geraldb/austria",
|
30
|
+
"forks_url": "https://api.github.com/repos/geraldb/austria/forks",
|
31
|
+
"keys_url": "https://api.github.com/repos/geraldb/austria/keys{/key_id}",
|
32
|
+
"collaborators_url": "https://api.github.com/repos/geraldb/austria/collaborators{/collaborator}",
|
33
|
+
"teams_url": "https://api.github.com/repos/geraldb/austria/teams",
|
34
|
+
"hooks_url": "https://api.github.com/repos/geraldb/austria/hooks",
|
35
|
+
"issue_events_url": "https://api.github.com/repos/geraldb/austria/issues/events{/number}",
|
36
|
+
"events_url": "https://api.github.com/repos/geraldb/austria/events",
|
37
|
+
"assignees_url": "https://api.github.com/repos/geraldb/austria/assignees{/user}",
|
38
|
+
"branches_url": "https://api.github.com/repos/geraldb/austria/branches{/branch}",
|
39
|
+
"tags_url": "https://api.github.com/repos/geraldb/austria/tags",
|
40
|
+
"blobs_url": "https://api.github.com/repos/geraldb/austria/git/blobs{/sha}",
|
41
|
+
"git_tags_url": "https://api.github.com/repos/geraldb/austria/git/tags{/sha}",
|
42
|
+
"git_refs_url": "https://api.github.com/repos/geraldb/austria/git/refs{/sha}",
|
43
|
+
"trees_url": "https://api.github.com/repos/geraldb/austria/git/trees{/sha}",
|
44
|
+
"statuses_url": "https://api.github.com/repos/geraldb/austria/statuses/{sha}",
|
45
|
+
"languages_url": "https://api.github.com/repos/geraldb/austria/languages",
|
46
|
+
"stargazers_url": "https://api.github.com/repos/geraldb/austria/stargazers",
|
47
|
+
"contributors_url": "https://api.github.com/repos/geraldb/austria/contributors",
|
48
|
+
"subscribers_url": "https://api.github.com/repos/geraldb/austria/subscribers",
|
49
|
+
"subscription_url": "https://api.github.com/repos/geraldb/austria/subscription",
|
50
|
+
"commits_url": "https://api.github.com/repos/geraldb/austria/commits{/sha}",
|
51
|
+
"git_commits_url": "https://api.github.com/repos/geraldb/austria/git/commits{/sha}",
|
52
|
+
"comments_url": "https://api.github.com/repos/geraldb/austria/comments{/number}",
|
53
|
+
"issue_comment_url": "https://api.github.com/repos/geraldb/austria/issues/comments{/number}",
|
54
|
+
"contents_url": "https://api.github.com/repos/geraldb/austria/contents/{+path}",
|
55
|
+
"compare_url": "https://api.github.com/repos/geraldb/austria/compare/{base}...{head}",
|
56
|
+
"merges_url": "https://api.github.com/repos/geraldb/austria/merges",
|
57
|
+
"archive_url": "https://api.github.com/repos/geraldb/austria/{archive_format}{/ref}",
|
58
|
+
"downloads_url": "https://api.github.com/repos/geraldb/austria/downloads",
|
59
|
+
"issues_url": "https://api.github.com/repos/geraldb/austria/issues{/number}",
|
60
|
+
"pulls_url": "https://api.github.com/repos/geraldb/austria/pulls{/number}",
|
61
|
+
"milestones_url": "https://api.github.com/repos/geraldb/austria/milestones{/number}",
|
62
|
+
"notifications_url": "https://api.github.com/repos/geraldb/austria/notifications{?since,all,participating}",
|
63
|
+
"labels_url": "https://api.github.com/repos/geraldb/austria/labels{/name}",
|
64
|
+
"releases_url": "https://api.github.com/repos/geraldb/austria/releases{/id}",
|
65
|
+
"created_at": "2015-03-31T15:16:05Z",
|
66
|
+
"updated_at": "2015-03-31T21:03:02Z",
|
67
|
+
"pushed_at": "2015-03-31T21:03:02Z",
|
68
|
+
"git_url": "git://github.com/geraldb/austria.git",
|
69
|
+
"ssh_url": "git@github.com:geraldb/austria.git",
|
70
|
+
"clone_url": "https://github.com/geraldb/austria.git",
|
71
|
+
"svn_url": "https://github.com/geraldb/austria",
|
72
|
+
"homepage": null,
|
73
|
+
"size": 552,
|
74
|
+
"stargazers_count": 1,
|
75
|
+
"watchers_count": 1,
|
76
|
+
"language": "Ruby",
|
77
|
+
"has_issues": true,
|
78
|
+
"has_downloads": true,
|
79
|
+
"has_wiki": false,
|
80
|
+
"has_pages": false,
|
81
|
+
"forks_count": 0,
|
82
|
+
"mirror_url": null,
|
83
|
+
"open_issues_count": 0,
|
84
|
+
"forks": 0,
|
85
|
+
"open_issues": 0,
|
86
|
+
"watchers": 1,
|
87
|
+
"default_branch": "master"
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"id": 31158327,
|
91
|
+
"name": "auto",
|
92
|
+
"full_name": "geraldb/auto",
|
93
|
+
"owner": {
|
94
|
+
"login": "geraldb",
|
95
|
+
"id": 53281,
|
96
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/53281?v=3",
|
97
|
+
"gravatar_id": "",
|
98
|
+
"url": "https://api.github.com/users/geraldb",
|
99
|
+
"html_url": "https://github.com/geraldb",
|
100
|
+
"followers_url": "https://api.github.com/users/geraldb/followers",
|
101
|
+
"following_url": "https://api.github.com/users/geraldb/following{/other_user}",
|
102
|
+
"gists_url": "https://api.github.com/users/geraldb/gists{/gist_id}",
|
103
|
+
"starred_url": "https://api.github.com/users/geraldb/starred{/owner}{/repo}",
|
104
|
+
"subscriptions_url": "https://api.github.com/users/geraldb/subscriptions",
|
105
|
+
"organizations_url": "https://api.github.com/users/geraldb/orgs",
|
106
|
+
"repos_url": "https://api.github.com/users/geraldb/repos",
|
107
|
+
"events_url": "https://api.github.com/users/geraldb/events{/privacy}",
|
108
|
+
"received_events_url": "https://api.github.com/users/geraldb/received_events",
|
109
|
+
"type": "User",
|
110
|
+
"site_admin": false
|
111
|
+
},
|
112
|
+
"private": false,
|
113
|
+
"html_url": "https://github.com/geraldb/auto",
|
114
|
+
"description": "auto - scripts to automate building databases, books, etc.",
|
115
|
+
"fork": false,
|
116
|
+
"url": "https://api.github.com/repos/geraldb/auto",
|
117
|
+
"forks_url": "https://api.github.com/repos/geraldb/auto/forks",
|
118
|
+
"keys_url": "https://api.github.com/repos/geraldb/auto/keys{/key_id}",
|
119
|
+
"collaborators_url": "https://api.github.com/repos/geraldb/auto/collaborators{/collaborator}",
|
120
|
+
"teams_url": "https://api.github.com/repos/geraldb/auto/teams",
|
121
|
+
"hooks_url": "https://api.github.com/repos/geraldb/auto/hooks",
|
122
|
+
"issue_events_url": "https://api.github.com/repos/geraldb/auto/issues/events{/number}",
|
123
|
+
"events_url": "https://api.github.com/repos/geraldb/auto/events",
|
124
|
+
"assignees_url": "https://api.github.com/repos/geraldb/auto/assignees{/user}",
|
125
|
+
"branches_url": "https://api.github.com/repos/geraldb/auto/branches{/branch}",
|
126
|
+
"tags_url": "https://api.github.com/repos/geraldb/auto/tags",
|
127
|
+
"blobs_url": "https://api.github.com/repos/geraldb/auto/git/blobs{/sha}",
|
128
|
+
"git_tags_url": "https://api.github.com/repos/geraldb/auto/git/tags{/sha}",
|
129
|
+
"git_refs_url": "https://api.github.com/repos/geraldb/auto/git/refs{/sha}",
|
130
|
+
"trees_url": "https://api.github.com/repos/geraldb/auto/git/trees{/sha}",
|
131
|
+
"statuses_url": "https://api.github.com/repos/geraldb/auto/statuses/{sha}",
|
132
|
+
"languages_url": "https://api.github.com/repos/geraldb/auto/languages",
|
133
|
+
"stargazers_url": "https://api.github.com/repos/geraldb/auto/stargazers",
|
134
|
+
"contributors_url": "https://api.github.com/repos/geraldb/auto/contributors",
|
135
|
+
"subscribers_url": "https://api.github.com/repos/geraldb/auto/subscribers",
|
136
|
+
"subscription_url": "https://api.github.com/repos/geraldb/auto/subscription",
|
137
|
+
"commits_url": "https://api.github.com/repos/geraldb/auto/commits{/sha}",
|
138
|
+
"git_commits_url": "https://api.github.com/repos/geraldb/auto/git/commits{/sha}",
|
139
|
+
"comments_url": "https://api.github.com/repos/geraldb/auto/comments{/number}",
|
140
|
+
"issue_comment_url": "https://api.github.com/repos/geraldb/auto/issues/comments{/number}",
|
141
|
+
"contents_url": "https://api.github.com/repos/geraldb/auto/contents/{+path}",
|
142
|
+
"compare_url": "https://api.github.com/repos/geraldb/auto/compare/{base}...{head}",
|
143
|
+
"merges_url": "https://api.github.com/repos/geraldb/auto/merges",
|
144
|
+
"archive_url": "https://api.github.com/repos/geraldb/auto/{archive_format}{/ref}",
|
145
|
+
"downloads_url": "https://api.github.com/repos/geraldb/auto/downloads",
|
146
|
+
"issues_url": "https://api.github.com/repos/geraldb/auto/issues{/number}",
|
147
|
+
"pulls_url": "https://api.github.com/repos/geraldb/auto/pulls{/number}",
|
148
|
+
"milestones_url": "https://api.github.com/repos/geraldb/auto/milestones{/number}",
|
149
|
+
"notifications_url": "https://api.github.com/repos/geraldb/auto/notifications{?since,all,participating}",
|
150
|
+
"labels_url": "https://api.github.com/repos/geraldb/auto/labels{/name}",
|
151
|
+
"releases_url": "https://api.github.com/repos/geraldb/auto/releases{/id}",
|
152
|
+
"created_at": "2015-02-22T09:27:17Z",
|
153
|
+
"updated_at": "2015-04-06T14:16:32Z",
|
154
|
+
"pushed_at": "2015-04-06T14:16:32Z",
|
155
|
+
"git_url": "git://github.com/geraldb/auto.git",
|
156
|
+
"ssh_url": "git@github.com:geraldb/auto.git",
|
157
|
+
"clone_url": "https://github.com/geraldb/auto.git",
|
158
|
+
"svn_url": "https://github.com/geraldb/auto",
|
159
|
+
"homepage": null,
|
160
|
+
"size": 288,
|
161
|
+
"stargazers_count": 1,
|
162
|
+
"watchers_count": 1,
|
163
|
+
"language": "Ruby",
|
164
|
+
"has_issues": true,
|
165
|
+
"has_downloads": true,
|
166
|
+
"has_wiki": false,
|
167
|
+
"has_pages": false,
|
168
|
+
"forks_count": 0,
|
169
|
+
"mirror_url": null,
|
170
|
+
"open_issues_count": 0,
|
171
|
+
"forks": 0,
|
172
|
+
"open_issues": 0,
|
173
|
+
"watchers": 1,
|
174
|
+
"default_branch": "master"
|
175
|
+
},
|
176
|
+
{
|
177
|
+
"id": 33404369,
|
178
|
+
"name": "backup",
|
179
|
+
"full_name": "geraldb/backup",
|
180
|
+
"owner": {
|
181
|
+
"login": "geraldb",
|
182
|
+
"id": 53281,
|
183
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/53281?v=3",
|
184
|
+
"gravatar_id": "",
|
185
|
+
"url": "https://api.github.com/users/geraldb",
|
186
|
+
"html_url": "https://github.com/geraldb",
|
187
|
+
"followers_url": "https://api.github.com/users/geraldb/followers",
|
188
|
+
"following_url": "https://api.github.com/users/geraldb/following{/other_user}",
|
189
|
+
"gists_url": "https://api.github.com/users/geraldb/gists{/gist_id}",
|
190
|
+
"starred_url": "https://api.github.com/users/geraldb/starred{/owner}{/repo}",
|
191
|
+
"subscriptions_url": "https://api.github.com/users/geraldb/subscriptions",
|
192
|
+
"organizations_url": "https://api.github.com/users/geraldb/orgs",
|
193
|
+
"repos_url": "https://api.github.com/users/geraldb/repos",
|
194
|
+
"events_url": "https://api.github.com/users/geraldb/events{/privacy}",
|
195
|
+
"received_events_url": "https://api.github.com/users/geraldb/received_events",
|
196
|
+
"type": "User",
|
197
|
+
"site_admin": false
|
198
|
+
},
|
199
|
+
"private": false,
|
200
|
+
"html_url": "https://github.com/geraldb/backup",
|
201
|
+
"description": "backup - scripts to backup repos, etc.",
|
202
|
+
"fork": false,
|
203
|
+
"url": "https://api.github.com/repos/geraldb/backup",
|
204
|
+
"forks_url": "https://api.github.com/repos/geraldb/backup/forks",
|
205
|
+
"keys_url": "https://api.github.com/repos/geraldb/backup/keys{/key_id}",
|
206
|
+
"collaborators_url": "https://api.github.com/repos/geraldb/backup/collaborators{/collaborator}",
|
207
|
+
"teams_url": "https://api.github.com/repos/geraldb/backup/teams",
|
208
|
+
"hooks_url": "https://api.github.com/repos/geraldb/backup/hooks",
|
209
|
+
"issue_events_url": "https://api.github.com/repos/geraldb/backup/issues/events{/number}",
|
210
|
+
"events_url": "https://api.github.com/repos/geraldb/backup/events",
|
211
|
+
"assignees_url": "https://api.github.com/repos/geraldb/backup/assignees{/user}",
|
212
|
+
"branches_url": "https://api.github.com/repos/geraldb/backup/branches{/branch}",
|
213
|
+
"tags_url": "https://api.github.com/repos/geraldb/backup/tags",
|
214
|
+
"blobs_url": "https://api.github.com/repos/geraldb/backup/git/blobs{/sha}",
|
215
|
+
"git_tags_url": "https://api.github.com/repos/geraldb/backup/git/tags{/sha}",
|
216
|
+
"git_refs_url": "https://api.github.com/repos/geraldb/backup/git/refs{/sha}",
|
217
|
+
"trees_url": "https://api.github.com/repos/geraldb/backup/git/trees{/sha}",
|
218
|
+
"statuses_url": "https://api.github.com/repos/geraldb/backup/statuses/{sha}",
|
219
|
+
"languages_url": "https://api.github.com/repos/geraldb/backup/languages",
|
220
|
+
"stargazers_url": "https://api.github.com/repos/geraldb/backup/stargazers",
|
221
|
+
"contributors_url": "https://api.github.com/repos/geraldb/backup/contributors",
|
222
|
+
"subscribers_url": "https://api.github.com/repos/geraldb/backup/subscribers",
|
223
|
+
"subscription_url": "https://api.github.com/repos/geraldb/backup/subscription",
|
224
|
+
"commits_url": "https://api.github.com/repos/geraldb/backup/commits{/sha}",
|
225
|
+
"git_commits_url": "https://api.github.com/repos/geraldb/backup/git/commits{/sha}",
|
226
|
+
"comments_url": "https://api.github.com/repos/geraldb/backup/comments{/number}",
|
227
|
+
"issue_comment_url": "https://api.github.com/repos/geraldb/backup/issues/comments{/number}",
|
228
|
+
"contents_url": "https://api.github.com/repos/geraldb/backup/contents/{+path}",
|
229
|
+
"compare_url": "https://api.github.com/repos/geraldb/backup/compare/{base}...{head}",
|
230
|
+
"merges_url": "https://api.github.com/repos/geraldb/backup/merges",
|
231
|
+
"archive_url": "https://api.github.com/repos/geraldb/backup/{archive_format}{/ref}",
|
232
|
+
"downloads_url": "https://api.github.com/repos/geraldb/backup/downloads",
|
233
|
+
"issues_url": "https://api.github.com/repos/geraldb/backup/issues{/number}",
|
234
|
+
"pulls_url": "https://api.github.com/repos/geraldb/backup/pulls{/number}",
|
235
|
+
"milestones_url": "https://api.github.com/repos/geraldb/backup/milestones{/number}",
|
236
|
+
"notifications_url": "https://api.github.com/repos/geraldb/backup/notifications{?since,all,participating}",
|
237
|
+
"labels_url": "https://api.github.com/repos/geraldb/backup/labels{/name}",
|
238
|
+
"releases_url": "https://api.github.com/repos/geraldb/backup/releases{/id}",
|
239
|
+
"created_at": "2015-04-04T12:14:24Z",
|
240
|
+
"updated_at": "2015-06-28T11:55:10Z",
|
241
|
+
"pushed_at": "2015-11-10T08:58:28Z",
|
242
|
+
"git_url": "git://github.com/geraldb/backup.git",
|
243
|
+
"ssh_url": "git@github.com:geraldb/backup.git",
|
244
|
+
"clone_url": "https://github.com/geraldb/backup.git",
|
245
|
+
"svn_url": "https://github.com/geraldb/backup",
|
246
|
+
"homepage": null,
|
247
|
+
"size": 184,
|
248
|
+
"stargazers_count": 1,
|
249
|
+
"watchers_count": 1,
|
250
|
+
"language": "Ruby",
|
251
|
+
"has_issues": true,
|
252
|
+
"has_downloads": true,
|
253
|
+
"has_wiki": true,
|
254
|
+
"has_pages": false,
|
255
|
+
"forks_count": 0,
|
256
|
+
"mirror_url": null,
|
257
|
+
"open_issues_count": 0,
|
258
|
+
"forks": 0,
|
259
|
+
"open_issues": 0,
|
260
|
+
"watchers": 1,
|
261
|
+
"default_branch": "master"
|
262
|
+
}
|
263
|
+
]
|
data/test/helper.rb
ADDED
data/test/test_cache.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_cache.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
|
11
|
+
class TestCache < MiniTest::Test
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@cache = Hubba::Cache.new( "#{Hubba.root}/test/cache" )
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_basename
|
18
|
+
mappings = [['/users/geraldb', 'users~geraldb'],
|
19
|
+
['/users/geraldb/repos', 'users~geraldb~repos'],
|
20
|
+
['/users/geraldb/repos?per_page=100', 'users~geraldb~repos'],
|
21
|
+
['/users/geraldb/orgs', 'users~geraldb~orgs'],
|
22
|
+
['/users/geraldb/orgs?per_page=100', 'users~geraldb~orgs'],
|
23
|
+
['/orgs/wikiscript/repos', 'orgs~wikiscript~repos'],
|
24
|
+
['/orgs/planetjekyll/repos', 'orgs~planetjekyll~repos'],
|
25
|
+
['/orgs/vienna-rb/repos', 'orgs~vienna-rb~repos']]
|
26
|
+
|
27
|
+
mappings.each do |mapping|
|
28
|
+
assert_equal mapping[1], @cache.request_uri_to_basename( mapping[0] )
|
29
|
+
end
|
30
|
+
end # method test_basename
|
31
|
+
|
32
|
+
def test_cache
|
33
|
+
orgs = @cache.get( '/users/geraldb/orgs' )
|
34
|
+
assert_equal 4, orgs.size
|
35
|
+
|
36
|
+
repos = @cache.get( '/users/geraldb/repos' )
|
37
|
+
assert_equal 3, repos.size
|
38
|
+
end # method test_cache
|
39
|
+
|
40
|
+
def test_cache_miss
|
41
|
+
assert_equal nil, @cache.get( '/test/hello' )
|
42
|
+
assert_equal nil, @cache.get( '/test/hola' )
|
43
|
+
end # method test_cache_miss
|
44
|
+
|
45
|
+
end # class TestCache
|
46
|
+
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hubba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logutils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.14'
|
55
|
+
description: hubba - (yet) another (lite) GitHub HTTP API client / library
|
56
|
+
email: ruby-talk@ruby-lang.org
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files:
|
60
|
+
- HISTORY.md
|
61
|
+
- Manifest.txt
|
62
|
+
- README.md
|
63
|
+
files:
|
64
|
+
- HISTORY.md
|
65
|
+
- Manifest.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/hubba.rb
|
69
|
+
- lib/hubba/cache.rb
|
70
|
+
- lib/hubba/client.rb
|
71
|
+
- lib/hubba/github.rb
|
72
|
+
- lib/hubba/version.rb
|
73
|
+
- test/cache/users~geraldb~orgs.json
|
74
|
+
- test/cache/users~geraldb~repos.json
|
75
|
+
- test/helper.rb
|
76
|
+
- test/test_cache.rb
|
77
|
+
homepage: https://github.com/rubylibs/hubba
|
78
|
+
licenses:
|
79
|
+
- Public Domain
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options:
|
83
|
+
- "--main"
|
84
|
+
- README.md
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.9.2
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.2.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: hubba - (yet) another (lite) GitHub HTTP API client / library
|
103
|
+
test_files: []
|