rubhub 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/README.md +0 -0
  2. data/lib/github/events/events.rb +45 -0
  3. data/lib/github/gists/gists.rb +66 -0
  4. data/lib/github/gists/gists_comments.rb +35 -0
  5. data/lib/github/gitdata/gitdata.rb +12 -0
  6. data/lib/github/gitdata/gitdata_blobs.rb +24 -0
  7. data/lib/github/gitdata/gitdata_commits.rb +42 -0
  8. data/lib/github/gitdata/gitdata_references.rb +44 -0
  9. data/lib/github/gitdata/gitdata_tags.rb +33 -0
  10. data/lib/github/gitdata/gitdata_trees.rb +25 -0
  11. data/lib/github/github.rb +95 -0
  12. data/lib/github/issues/issues.rb +84 -0
  13. data/lib/github/issues/issues_comments.rb +40 -0
  14. data/lib/github/issues/issues_events.rb +22 -0
  15. data/lib/github/issues/issues_labels.rb +76 -0
  16. data/lib/github/issues/issues_milestones.rb +54 -0
  17. data/lib/github/orgs/orgs.rb +32 -0
  18. data/lib/github/orgs/orgs_members.rb +40 -0
  19. data/lib/github/orgs/orgs_teams.rb +78 -0
  20. data/lib/github/pullreqs/pullreqs.rb +76 -0
  21. data/lib/github/pullreqs/pullreqs_reviewcomments.rb +53 -0
  22. data/lib/github/repos/repos.rb +104 -0
  23. data/lib/github/repos/repos_collaborators.rb +27 -0
  24. data/lib/github/repos/repos_commits.rb +72 -0
  25. data/lib/github/repos/repos_downloads.rb +55 -0
  26. data/lib/github/repos/repos_forks.rb +25 -0
  27. data/lib/github/repos/repos_hooks.rb +57 -0
  28. data/lib/github/repos/repos_keys.rb +43 -0
  29. data/lib/github/repos/repos_watching.rb +33 -0
  30. data/lib/github/users/users.rb +34 -0
  31. data/lib/github/users/users_emails.rb +22 -0
  32. data/lib/github/users/users_followers.rb +31 -0
  33. data/lib/github/users/users_keys.rb +37 -0
  34. data/lib/rubhub.rb +38 -0
  35. data/test/test.rb +9 -0
  36. metadata +101 -0
File without changes
@@ -0,0 +1,45 @@
1
+ class Events
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def listEvents()
9
+ @github.get('events')
10
+ end
11
+
12
+ def listRepoEvents(repo, user=nil)
13
+ username = user == nil ? @github.username : user
14
+ @github.get('repos/%s/%s/events' % [username, repo])
15
+ end
16
+
17
+ def listRepoNetworkPublicEvents(repo, user=nil)
18
+ username = user == nil ? @github.username : user
19
+ @github.get('network/%s/%s/events' % [username, repo])
20
+ end
21
+
22
+ def listOrgPublicEvents(org)
23
+ @github.get('orgs/%s/events' % org)
24
+ end
25
+
26
+ def listRepoIssueEvents(repo, user=nil)
27
+ username = user == nil ? @github.username : user
28
+ @github.get('repos/%s/%s/issues/events' % [username, repo])
29
+ end
30
+
31
+ def listReceivedEvents(user=nil)
32
+ username = user == nil ? @github.username : user
33
+ @github.get('users/%s/received_events' % username)
34
+ end
35
+
36
+ def listReceivedPublicEvents(user=nil)
37
+ username = user == nil ? @github.username : user
38
+ @github.get('users/%s/received_events/public' % username)
39
+ end
40
+
41
+ def listOrgEvents(org)
42
+ username = @github.username
43
+ @github.get('users/%s/events/orgs/%s' % [username, org])
44
+ end
45
+ end
@@ -0,0 +1,66 @@
1
+ class Gists
2
+ attr_accessor :github, :comments
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ @comments = GistsComments.new(github)
7
+ end
8
+
9
+ def listGists(user=nil)
10
+ url = user != nil ? 'users/%s/gists' : 'gists'
11
+ @github.get(url)
12
+ end
13
+
14
+ def listPublicGists()
15
+ @github.get('gists/public')
16
+ end
17
+
18
+ def listStarredGists()
19
+ @github.get('gists/starred')
20
+ end
21
+
22
+ def getGist(id)
23
+ @github.get('gists/%s' % id)
24
+ end
25
+
26
+ def createGist(public, files, description=nil)
27
+ params = {
28
+ :description => description,
29
+ :public => public,
30
+ :files => files
31
+ }
32
+ params = @github.removeEmptyParams(params)
33
+ data = params.to_json
34
+ @github.post('gists', data)
35
+ end
36
+
37
+ def editGist(id, files=nil, description=nil)
38
+ params = {
39
+ :description => description,
40
+ :files => files
41
+ }
42
+ params = @github.removeEmptyParams(params)
43
+ data = params.to_json
44
+ @github.patch('gists/%s' % id, data)
45
+ end
46
+
47
+ def starGist(id)
48
+ @github.put('gists/%s/star' % id)
49
+ end
50
+
51
+ def unStarGist(id)
52
+ @github.delete('gists/%s/star' % id)
53
+ end
54
+
55
+ def checkIfGistStarred(id)
56
+ @github.get('gists/%s/star' % id)
57
+ end
58
+
59
+ def forkGist(id)
60
+ @github.post('gists/%s/fork' % id)
61
+ end
62
+
63
+ def deleteGist(id)
64
+ @github.delete('gists/%s' % id)
65
+ end
66
+ end
@@ -0,0 +1,35 @@
1
+ class GistsComments
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def listGistComments(id)
9
+ @github.get('gists/%s/comments' % id)
10
+ end
11
+
12
+ def getGistComment(id)
13
+ @github.get('gists/comments/%s' % id)
14
+ end
15
+
16
+ def createGistComment(id, body)
17
+ params = {
18
+ :body => body
19
+ }
20
+ data = params.to_json
21
+ @github.post('gists/%s/comments' % id, data)
22
+ end
23
+
24
+ def editGistComment(id, body)
25
+ params = {
26
+ :body => body
27
+ }
28
+ data = params.to_json
29
+ @github.patch('gists/comments/%s' % id, data)
30
+ end
31
+
32
+ def deleteGistComment(id)
33
+ @github.delete('gists/comments/%s' % id)
34
+ end
35
+ end
@@ -0,0 +1,12 @@
1
+ class GitData
2
+ attr_accessor :github, :blobs, :commits, :references, :tags, :trees
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ @blobs = GitDataBlobs.new(github)
7
+ @commits = GitDataCommits.new(github)
8
+ @references = GitDataReferences.new(github)
9
+ @tags = GitDataTags.new(github)
10
+ @trees = GitDataTrees.new(github)
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ class GitDataBlobs
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def getBlob(repo, sha, user=nil)
9
+ username = user == nil ? @github.username : user
10
+ @github.get(
11
+ 'repos/%s/%s/git/blobs/%s' % [username, repo, sha])
12
+ end
13
+
14
+ def createBlob(repo, content, encoding, user=nil)
15
+ username = user == nil ? @github.username : user
16
+ params = {
17
+ :content => content,
18
+ :encoding => encoding
19
+ }
20
+ data = params.to_json
21
+ @github.post('repos/%s/%s/git/blobs' % [username, repo],
22
+ data)
23
+ end
24
+ end
@@ -0,0 +1,42 @@
1
+ class GitDataCommits
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def getCommit(repo, sha, user=nil)
9
+ username = user == nil ? @github.username : user
10
+ @github.get(
11
+ 'repos/%s/%s/git/commits/%s' % [username, repo, sha])
12
+ end
13
+
14
+ def createCommit(repo, message, tree, parents, authorName=nil,
15
+ authorEmail=nil, authorDate=nil, committerName=nil,
16
+ committerEmail=nil, commiterDate=nil, user=nil)
17
+ username = user == nil ? @github.username : user
18
+ author = {
19
+ :name => authorName,
20
+ :email => authorEmail,
21
+ :date => authorDate,
22
+ }
23
+ author = @github.removeEmptyParams(author)
24
+ committer = {
25
+ :name => committerName,
26
+ :email => committerEmail,
27
+ :date => commiterDate
28
+ }
29
+ committer = @github.removeEmptyParams(committer)
30
+ params = {
31
+ :message => message,
32
+ :author => author,
33
+ :committer => committer,
34
+ :parents => parents,
35
+ :tree => tree
36
+ }
37
+ params = @github.removeEmptyParams(params)
38
+ data = params.to_json
39
+ @github.post(
40
+ 'repos/%s/%s/git/commits' % [username, repo], data)
41
+ end
42
+ end
@@ -0,0 +1,44 @@
1
+ class GitDataReferences
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def getReference(repo, ref, user=nil)
9
+ username = user == nil ? @github.username : user
10
+ @github.get(
11
+ 'repos/%s/%s/git/refs/%s' % [username, repo, ref])
12
+
13
+ def getReferences(repo, subnamespace=nil, user=nil)
14
+ username = user == nil ? @github.username : user
15
+ url = 'repos/%s/%s/git/refs' % [repo, username]
16
+ if subnamespace
17
+ url = subnamespace[0] == '/' ? '%s/%s' % [url, subnamespace]
18
+ : '%s/%s/' % [url, subnamespace]
19
+ end
20
+ @github.get(url)
21
+ end
22
+
23
+ def createReference(repo, ref, sha, user=nil)
24
+ username = user == nil ? @github.username : user
25
+ params = {
26
+ :ref => ref,
27
+ :sha => sha
28
+ }
29
+ data = params.to_json
30
+ @github.post('repos/%s/%s/git/refs' % [username, repo], data)
31
+ end
32
+
33
+ def editReference(repo, sha, force=FALSE, user=nil)
34
+ username = user == nil ? @github.username : user
35
+ params = {
36
+ :sha => sha,
37
+ :force => force
38
+ }
39
+ data = params.to_json
40
+ @github.patch('repos/%s/%s/git/refs' % [username, repo], data)
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,33 @@
1
+ class GitDataTags
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def getTag(repo, sha, user=nil)
9
+ username = user == nil ? @github.username : user
10
+ @github.get(
11
+ 'repos/%s/%s/git/tags/%s' % [username, repo, sha])
12
+ end
13
+
14
+ def createTagObject(repo, tag, message, object, type, taggerName,
15
+ taggerEmail, taggerDate, user=nil)
16
+ username = user == nil ? @github.username : user
17
+ tagger = {
18
+ :name => taggerName,
19
+ :email => taggerEmail,
20
+ :date => taggerDate
21
+ }
22
+ params = {
23
+ :tag => tag,
24
+ :message => message,
25
+ :object => object,
26
+ :type => type,
27
+ :tagger => tagger
28
+ }
29
+ data = params.to_json
30
+ url = 'repos/%s/%s/git/tags' % [user, repo]
31
+ @github.post(url % [username, repo], data)
32
+ end
33
+ end
@@ -0,0 +1,25 @@
1
+ class GitDataTrees
2
+ attr_accessor :github
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ end
7
+
8
+ def getTree(repo, sha, recursive=FALSE, user=nil)
9
+ username = user == nil ? @github.username : user
10
+ url = 'repos/%s/%s/git/trees/%s' % [username, repo, sha]
11
+ url = recursive ? '%s?recursive=1' % url : url
12
+ @github.get(url)
13
+ end
14
+
15
+ def createTree(repo, tree, baseTree=nil, user=nil)
16
+ username = user == nil ? @github.username : user
17
+ params = {
18
+ :base_tree => baseTree,
19
+ :tree => tree
20
+ }
21
+ params = @github.removeEmptyParams(params)
22
+ data = params.to_json
23
+ @github.post('repos/%s/%s/git/trees' % [username, repo], data)
24
+ end
25
+ end
@@ -0,0 +1,95 @@
1
+ class Github
2
+ attr_reader :username, :password, :apiurl
3
+ attr_accessor :events, :gists, :gitdata, :issues, :orgs, :pullreqs, :repos, :users
4
+
5
+ def initialize(username, password)
6
+ @apiurl = 'https://api.github.com'
7
+ @username = username
8
+ @password = password
9
+ @events = Events.new(self)
10
+ @gists = Gists.new(self)
11
+ @gitdata = GitData.new(self)
12
+ @issues = Issues.new(self)
13
+ @orgs = Orgs.new(self)
14
+ @pullreqs = PullReq.new(self)
15
+ @repos = Repos.new(self)
16
+ @users = Users.new(self)
17
+ @events = Events.new(self)
18
+ end
19
+
20
+ def head(path)
21
+ uri = URI(buildurl(path))
22
+ req = Net::HTTP::Head.new(uri.request_uri)
23
+ req.basic_auth @username, @password
24
+ res = Net::HTTP.start(uri.hostname, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
25
+ http.request(req)
26
+ }
27
+ JSON.parse(res.body)
28
+ end
29
+
30
+ def get(path)
31
+ uri = URI(buildurl(path))
32
+ req = Net::HTTP::Get.new(uri.request_uri)
33
+ req.basic_auth @username, @password
34
+ res = Net::HTTP.start(uri.hostname, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
35
+ http.request(req)
36
+ }
37
+ JSON.parse(res.body)
38
+ end
39
+
40
+ def post(path, data=nil)
41
+ uri = URI(buildurl(path))
42
+ req = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
43
+ req.basic_auth @username, @password
44
+ req.body = data
45
+ res = Net::HTTP.start(uri.hostname, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
46
+ http.request(req)
47
+ }
48
+ res.body
49
+ end
50
+
51
+ def patch(path, data)
52
+ uri = URI(buildurl(path))
53
+ req = Net::HTTP::Patch.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
54
+ req.basic_auth @username, @password
55
+ req.body = data
56
+ res = Net::HTTP.start(uri.hostname, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
57
+ http.request(req)
58
+ }
59
+ JSON.parse(res.body)
60
+ end
61
+
62
+ def put(path, data=nil)
63
+ uri = URI(buildurl(path))
64
+ req = Net::HTTP::Put.new(uri.request_uri, initheader = {'Content-Type' => 'application/json'})
65
+ req.basic_auth @username, @password
66
+ req.body = data
67
+ res = Net::HTTP.start(uri.hostname, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
68
+ http.request(req)
69
+ }
70
+ JSON.parse(res.body)
71
+ end
72
+
73
+ def delete(path, data=nil)
74
+ uri = URI(buildurl(path))
75
+ req = Net::HTTP::Delete.new(uri.request_uri)
76
+ req.basic_auth @username, @password
77
+ req.body = data
78
+ res = Net::HTTP.start(uri.hostname, use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE) { |http|
79
+ http.request(req)
80
+ }
81
+ res.body ? JSON.parse(res.body) : res.code
82
+ end
83
+
84
+ def buildurl(path)
85
+ @apiurl + ((path[0] == '/') ? path : ('/%s' % path))
86
+ end
87
+
88
+ def parameterize(params)
89
+ URI.escape(params.collect { |k, v| "#{k}=#{v}" }.join('&'))
90
+ end
91
+
92
+ def removeEmptyParams(params)
93
+ params.delete_if { |k, v| v.nil? }
94
+ end
95
+ end
@@ -0,0 +1,84 @@
1
+ class Issues
2
+ attr_accessor :github, :events, :labels, :milestones
3
+
4
+ def initialize(github)
5
+ @github = github
6
+ @comments = IssuesComments.new(github)
7
+ @events = IssuesEvents.new(github)
8
+ @labels = IssuesLabels.new(github)
9
+ @milestones = IssuesMilestones.new(github)
10
+ end
11
+
12
+ def listIssues(filter='assigned', state='open', labels=nil,
13
+ sort='created', direction='desc', since=nil)
14
+ params = {
15
+ :filter => filter,
16
+ :state => state,
17
+ :labels => labels,
18
+ :sort => sort,
19
+ :direction => direction,
20
+ :since => since
21
+ }
22
+ params = @github.removeEmptyParams(params)
23
+ url = 'issues?%s' % @github.parameterize(params)
24
+ @github.get(url)
25
+ end
26
+
27
+ def listRepoIssues(repo, milestone=nil, assignee=nil,
28
+ mentioned=nil, state='open', labels=nil,
29
+ sort='created', direction='desc', since=nil,
30
+ user=nil)
31
+ params = {
32
+ :filter => filter,
33
+ :state => state,
34
+ :assignee => assignee,
35
+ :mentioned => mentioned,
36
+ :labels => labels,
37
+ :sort => sort,
38
+ :direction => direction,
39
+ :since => since,
40
+ :milestone => milestone
41
+ }
42
+ params = @github.removeEmptyParams(params)
43
+ url = 'repos/%s/%s/issues?%s' % [user, repo, @github.parameterize(params)]
44
+ @github.get(url)
45
+ end
46
+
47
+ def getIssue(repo, number, user=nil)
48
+ username = user == nil ? @github.username : user
49
+ @github.get('repos/%s/%s/issues/%s' % [username, repo, number])
50
+ end
51
+
52
+ def createIssue(repo, title, body=nil, assignee=nil,
53
+ milestone=nil, labels=nil, user=nil)
54
+ params = {
55
+ :title => title,
56
+ :body => body,
57
+ :assignee => assignee,
58
+ :milestone => milestone,
59
+ :labels => labels
60
+ }
61
+ params = @github.removeEmptyParams(params)
62
+ data = params.to_json
63
+ @github.post('repos/%s/%s/issues' % [user, repo], data)
64
+ end
65
+
66
+ def editIssue(repo, id, title=nil, body=nil, assignee=nil,
67
+ state=nil, milestone=nil, labels=nil,
68
+ user=nil)
69
+ username = user == nil ? @github.username : user
70
+ params = {
71
+ :title => title,
72
+ :body => body,
73
+ :assignee => assignee,
74
+ :state => state,
75
+ :milestone => milestone,
76
+ :labels => labels
77
+ }
78
+ params = @github.removeEmptyParams(params)
79
+ data = params.to_json
80
+ @github.post('repos/%s/%s/issues/%s' % [username, repo, id], data)
81
+ end
82
+ end
83
+
84
+