ghee 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +1 -0
- data/.gitignore +5 -0
- data/.rspec +0 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +353 -0
- data/Rakefile +15 -0
- data/ghee.gemspec +31 -0
- data/lib/ghee.rb +49 -0
- data/lib/ghee/api/authorizations.rb +14 -0
- data/lib/ghee/api/events.rb +25 -0
- data/lib/ghee/api/gists.rb +75 -0
- data/lib/ghee/api/issues.rb +98 -0
- data/lib/ghee/api/milestones.rb +47 -0
- data/lib/ghee/api/orgs.rb +103 -0
- data/lib/ghee/api/repos.rb +96 -0
- data/lib/ghee/api/users.rb +72 -0
- data/lib/ghee/connection.rb +33 -0
- data/lib/ghee/resource_proxy.rb +111 -0
- data/lib/ghee/state_methods.rb +29 -0
- data/lib/ghee/version.rb +4 -0
- data/spec/ghee/api/authorizations_spec.rb +46 -0
- data/spec/ghee/api/events_spec.rb +47 -0
- data/spec/ghee/api/gists_spec.rb +153 -0
- data/spec/ghee/api/hooks_spec.rb +52 -0
- data/spec/ghee/api/issues_spec.rb +122 -0
- data/spec/ghee/api/milestones_spec.rb +103 -0
- data/spec/ghee/api/orgs_spec.rb +56 -0
- data/spec/ghee/api/repos_spec.rb +126 -0
- data/spec/ghee/api/teams_spec.rb +90 -0
- data/spec/ghee/api/users_spec.rb +102 -0
- data/spec/ghee/connection_spec.rb +54 -0
- data/spec/ghee/resource_proxy_spec.rb +207 -0
- data/spec/ghee_spec.rb +42 -0
- data/spec/settings.yml.sample +5 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +16 -0
- metadata +208 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
class Ghee
|
2
|
+
module API
|
3
|
+
module Authorizations
|
4
|
+
class Proxy < ::Ghee::ResourceProxy
|
5
|
+
include Ghee::CUD
|
6
|
+
end
|
7
|
+
|
8
|
+
def authorizations(number=nil)
|
9
|
+
prefix = number ? "/authorizations/#{number}" : "/authorizations"
|
10
|
+
Ghee::API::Authorizations::Proxy.new(connection, prefix)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Ghee
|
2
|
+
|
3
|
+
# API module encapsulates all of API endpoints
|
4
|
+
# implemented thus far
|
5
|
+
#
|
6
|
+
module API
|
7
|
+
|
8
|
+
# The Events module handles all of the Github Event
|
9
|
+
# API endpoints
|
10
|
+
#
|
11
|
+
module Events
|
12
|
+
class Proxy < ::Ghee::ResourceProxy
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get events
|
16
|
+
#
|
17
|
+
# Returns json
|
18
|
+
#
|
19
|
+
def events(params={})
|
20
|
+
return Proxy.new(connection, "/events",params)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class Ghee
|
2
|
+
|
3
|
+
# API module encapsulates all of API endpoints
|
4
|
+
# implemented thus far
|
5
|
+
#
|
6
|
+
module API
|
7
|
+
|
8
|
+
# The Gists module handles all of the Github Gist
|
9
|
+
# API endpoints
|
10
|
+
#
|
11
|
+
module Gists
|
12
|
+
|
13
|
+
# Gists::Proxy inherits from Ghee::Proxy and
|
14
|
+
# enables defining methods on the proxy object
|
15
|
+
#
|
16
|
+
class Proxy < ::Ghee::ResourceProxy
|
17
|
+
include Ghee::CUD
|
18
|
+
|
19
|
+
|
20
|
+
# Star a gist
|
21
|
+
#
|
22
|
+
# Returns true/false
|
23
|
+
#
|
24
|
+
def star
|
25
|
+
connection.put("#{path_prefix}/star").status == 204
|
26
|
+
end
|
27
|
+
|
28
|
+
# Unstar a gist
|
29
|
+
#
|
30
|
+
# Returns true/false
|
31
|
+
#
|
32
|
+
def unstar
|
33
|
+
connection.delete("#{path_prefix}/star").status == 204
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns whether gist is starred
|
37
|
+
#
|
38
|
+
# Returns true/false
|
39
|
+
#
|
40
|
+
def starred?
|
41
|
+
connection.get("#{path_prefix}/star").status == 204
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get public gists
|
45
|
+
#
|
46
|
+
# Returns json
|
47
|
+
#
|
48
|
+
def public
|
49
|
+
connection.get("#{path_prefix}/public").body
|
50
|
+
end
|
51
|
+
|
52
|
+
# Get starred gists
|
53
|
+
#
|
54
|
+
# Returns json
|
55
|
+
#
|
56
|
+
def starred
|
57
|
+
connection.get("#{path_prefix}/starred").body
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
# Get gists
|
63
|
+
#
|
64
|
+
# id - String of gist id
|
65
|
+
#
|
66
|
+
# Returns json
|
67
|
+
#
|
68
|
+
def gists(id=nil, params={})
|
69
|
+
params = id if id.is_a?Hash
|
70
|
+
path_prefix = (!id.is_a?(Hash) and id) ? "/gists/#{id}" : '/gists'
|
71
|
+
Proxy.new(connection, path_prefix,params)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
class Ghee
|
2
|
+
|
3
|
+
# API module encapsulates all of API endpoints
|
4
|
+
# implemented thus far
|
5
|
+
#
|
6
|
+
module API
|
7
|
+
|
8
|
+
|
9
|
+
# The Issues module handles all of the Github Repo Issues
|
10
|
+
# API endpoints
|
11
|
+
#
|
12
|
+
module Issues
|
13
|
+
|
14
|
+
# API labels module handles all of the Github Issues
|
15
|
+
# API endpoints
|
16
|
+
#
|
17
|
+
module Labels
|
18
|
+
class Proxy < ::Ghee::ResourceProxy
|
19
|
+
|
20
|
+
# Creates label for an issue using the authenicated user
|
21
|
+
#
|
22
|
+
# labels - Array of labels
|
23
|
+
#
|
24
|
+
# return json
|
25
|
+
#
|
26
|
+
def add(labels)
|
27
|
+
connection.post(path_prefix,labels).body
|
28
|
+
end
|
29
|
+
|
30
|
+
# Patchs and existing label
|
31
|
+
#
|
32
|
+
# return json
|
33
|
+
#
|
34
|
+
def replace(labels)
|
35
|
+
connection.put(path_prefix, labels).body
|
36
|
+
end
|
37
|
+
|
38
|
+
# Destroys label by id
|
39
|
+
#
|
40
|
+
# return boolean
|
41
|
+
#
|
42
|
+
def remove
|
43
|
+
connection.delete(path_prefix).status == 204
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# API Comments module handles all of the Github Issues
|
49
|
+
# API endpoints
|
50
|
+
#
|
51
|
+
module Comments
|
52
|
+
class Proxy < ::Ghee::ResourceProxy
|
53
|
+
include Ghee::CUD
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Gists::Proxy inherits from Ghee::Proxy and
|
58
|
+
# enables defining methods on the proxy object
|
59
|
+
#
|
60
|
+
class Proxy < ::Ghee::ResourceProxy
|
61
|
+
include Ghee::CUD
|
62
|
+
|
63
|
+
# Close issue - closed issue by id
|
64
|
+
#
|
65
|
+
# usage - ghee.repos("my_repo").issues(1).close
|
66
|
+
#
|
67
|
+
# returns boolean
|
68
|
+
#
|
69
|
+
def close
|
70
|
+
connection.patch(path_prefix,:state => "closed").body["state"] == "closed"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns closed issues
|
74
|
+
#
|
75
|
+
# Returns json
|
76
|
+
#
|
77
|
+
def closed
|
78
|
+
response = connection.get path_prefix do |req|
|
79
|
+
req.params["state"] = "closed"
|
80
|
+
end
|
81
|
+
response.body
|
82
|
+
end
|
83
|
+
|
84
|
+
def comments(id=nil)
|
85
|
+
prefix = id ? "#{path_prefix}/comments/#{id}" : "#{path_prefix}/comments"
|
86
|
+
Ghee::API::Issues::Comments::Proxy.new(connection,prefix)
|
87
|
+
end
|
88
|
+
|
89
|
+
def labels
|
90
|
+
Ghee::API::Issues::Labels::Proxy.new(connection, "#{path_prefix}/labels")
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class Ghee
|
2
|
+
|
3
|
+
# API module encapsulates all of API endpoints
|
4
|
+
# implemented thus far
|
5
|
+
#
|
6
|
+
module API
|
7
|
+
|
8
|
+
|
9
|
+
# The Milestones module handles all of the Github Repo Milestones
|
10
|
+
# API endpoints
|
11
|
+
#
|
12
|
+
module Milestones
|
13
|
+
|
14
|
+
|
15
|
+
# Gists::Proxy inherits from Ghee::Proxy and
|
16
|
+
# enables defining methods on the proxy object
|
17
|
+
#
|
18
|
+
class Proxy < ::Ghee::ResourceProxy
|
19
|
+
include Ghee::CUD
|
20
|
+
|
21
|
+
# Close milestone - closed milestone by id
|
22
|
+
#
|
23
|
+
# usage - ghee.repos("my_repo").milestones(1).close
|
24
|
+
#
|
25
|
+
# returns boolean
|
26
|
+
#
|
27
|
+
def close
|
28
|
+
connection.patch(path_prefix,:state => "closed").body["state"] == "closed"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns closed milestones
|
32
|
+
#
|
33
|
+
# Returns json
|
34
|
+
#
|
35
|
+
def closed
|
36
|
+
response = connection.get path_prefix do |req|
|
37
|
+
req.params["state"] = "closed"
|
38
|
+
end
|
39
|
+
response.body
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,103 @@
|
|
1
|
+
class Ghee
|
2
|
+
|
3
|
+
# API module encapsulates all of API endpoints
|
4
|
+
# implemented thus far
|
5
|
+
#
|
6
|
+
module API
|
7
|
+
|
8
|
+
# The Orgs module handles all of the Github Organization
|
9
|
+
# API endpoints
|
10
|
+
#
|
11
|
+
module Orgs
|
12
|
+
|
13
|
+
# Orgs::Teams module handles all of the Github Organization Teams
|
14
|
+
# API endpoints
|
15
|
+
#
|
16
|
+
module Teams
|
17
|
+
|
18
|
+
# Orgs::Teams::Members module handles all of the Github Organization Teams members
|
19
|
+
# API endpoints
|
20
|
+
#
|
21
|
+
module Members
|
22
|
+
|
23
|
+
# Members::Proxy inherits from Ghee::Proxy and
|
24
|
+
# enables defining methods on the proxy object
|
25
|
+
#
|
26
|
+
class Proxy < ::Ghee::ResourceProxy
|
27
|
+
|
28
|
+
def add(member)
|
29
|
+
connection.put("#{path_prefix}/#{member}").status == 204
|
30
|
+
end
|
31
|
+
|
32
|
+
def remove(member)
|
33
|
+
connection.delete("#{path_prefix}/#{member}").status == 204
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Teams::Proxy inherits from Ghee::Proxy and
|
39
|
+
# enables defining methods on the proxy object
|
40
|
+
#
|
41
|
+
class Proxy < ::Ghee::ResourceProxy
|
42
|
+
include Ghee::CUD
|
43
|
+
|
44
|
+
def members(name=nil)
|
45
|
+
prefix = name ? "#{path_prefix}/members/#{name}" : "#{path_prefix}/members"
|
46
|
+
Ghee::API::Orgs::Teams::Members::Proxy.new(connection, prefix)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Orgs::Proxy inherits from Ghee::Proxy and
|
53
|
+
# enables defining methods on the proxy object
|
54
|
+
#
|
55
|
+
class Proxy < ::Ghee::ResourceProxy
|
56
|
+
include Ghee::CUD
|
57
|
+
|
58
|
+
# Teams for an org
|
59
|
+
#
|
60
|
+
# Returns json
|
61
|
+
#
|
62
|
+
def teams(number=nil,params={})
|
63
|
+
params = number if number.is_a?Hash
|
64
|
+
prefix = (!number.is_a?(Hash) and number) ? "/teams/#{number}" : "#{path_prefix}/teams"
|
65
|
+
Ghee::API::Orgs::Teams::Proxy.new(connection, prefix, params)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Repos for a orgs
|
69
|
+
#
|
70
|
+
# Returns json
|
71
|
+
#
|
72
|
+
def repos(name=nil,params={})
|
73
|
+
params = name if name.is_a?Hash
|
74
|
+
prefix = (!name.is_a?(Hash) and name) ? "/repos/#{self["login"]}/#{name}" : "#{path_prefix}/repos"
|
75
|
+
Ghee::API::Repos::Proxy.new(connection,prefix,params)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Team by id
|
80
|
+
#
|
81
|
+
# Returns json
|
82
|
+
#
|
83
|
+
def team(number, params={})
|
84
|
+
prefix = "/teams/#{number}"
|
85
|
+
Ghee::API::Orgs::Teams::Proxy.new(connection, prefix, params)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Returns list of the authenticated users organizations or
|
89
|
+
# an organization by name
|
90
|
+
#
|
91
|
+
# org - String name of the organization (optional)
|
92
|
+
#
|
93
|
+
# Returns json
|
94
|
+
#
|
95
|
+
def orgs(name=nil, params={})
|
96
|
+
params = name if name.is_a?Hash
|
97
|
+
prefix = (!name.is_a?(Hash) and name) ? "/orgs/#{name}" : "user/orgs"
|
98
|
+
Proxy.new(connection, prefix, params)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class Ghee
|
2
|
+
|
3
|
+
# API module encapsulates all of API endpoints
|
4
|
+
# implemented thus far
|
5
|
+
#
|
6
|
+
module API
|
7
|
+
|
8
|
+
# The Repos module handles all of the Github Repo
|
9
|
+
# API endpoints
|
10
|
+
#
|
11
|
+
module Repos
|
12
|
+
|
13
|
+
module Labels
|
14
|
+
class Proxy < ::Ghee::ResourceProxy
|
15
|
+
include Ghee::CUD
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Hooks
|
20
|
+
class Proxy < ::Ghee::ResourceProxy
|
21
|
+
include Ghee::CUD
|
22
|
+
|
23
|
+
# Test hook - This will trigger the hook with the
|
24
|
+
# latest push to the current repository.
|
25
|
+
#
|
26
|
+
def test
|
27
|
+
connection.post("#{path_prefix}/test").body
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Gists::Proxy inherits from Ghee::Proxy and
|
35
|
+
# enables defining methods on the proxy object
|
36
|
+
#
|
37
|
+
class Proxy < ::Ghee::ResourceProxy
|
38
|
+
|
39
|
+
# Get issues
|
40
|
+
#
|
41
|
+
# Returns json
|
42
|
+
#
|
43
|
+
def issues(number=nil, params={})
|
44
|
+
params = number if number.is_a?Hash
|
45
|
+
prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/issues/#{number}" : "#{path_prefix}/issues"
|
46
|
+
Ghee::API::Issues::Proxy.new(connection, prefix, params)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Get labels for a repo
|
50
|
+
#
|
51
|
+
# id - Number get a specific label (optional)
|
52
|
+
#
|
53
|
+
# Returns json
|
54
|
+
#
|
55
|
+
def labels(number=nil, params={})
|
56
|
+
params = number if number.is_a?Hash
|
57
|
+
prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/labels/#{number}" : "#{path_prefix}/labels"
|
58
|
+
Ghee::API::Repos::Labels::Proxy.new(connection, prefix, params)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Get milestones
|
62
|
+
#
|
63
|
+
# Returns json
|
64
|
+
#
|
65
|
+
def milestones(number=nil, params={})
|
66
|
+
params = number if number.is_a?Hash
|
67
|
+
prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/milestones/#{number}" : "#{path_prefix}/milestones"
|
68
|
+
Ghee::API::Milestones::Proxy.new(connection, prefix, params)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Get hooks
|
72
|
+
#
|
73
|
+
# Returns json
|
74
|
+
#
|
75
|
+
def hooks(number=nil, params={})
|
76
|
+
params = number if number.is_a?Hash
|
77
|
+
prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/hooks/#{number}" : "#{path_prefix}/hooks"
|
78
|
+
Ghee::API::Repos::Hooks::Proxy.new(connection, prefix, params)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get repos
|
84
|
+
#
|
85
|
+
# name - String of the name of the repo
|
86
|
+
#
|
87
|
+
# Returns json
|
88
|
+
#
|
89
|
+
def repos(login,name)
|
90
|
+
path_prefix = "/repos/#{login}/#{name}"
|
91
|
+
Proxy.new(connection, path_prefix)
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|