ghee 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,66 @@
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 Commits
14
+ class Proxy < ::Ghee::ResourceProxy
15
+
16
+ def comments
17
+ Ghee::API::Repos::Commits::Comments::Proxy.new connection, path_prefix
18
+ end
19
+ end
20
+
21
+ module Comments
22
+ class Proxy < ::Ghee::ResourceProxy
23
+
24
+ def create(attributes)
25
+ connection.post(path_prefix, attributes).body
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ module Comments
32
+ class Proxy < ::Ghee::ResourceProxy
33
+
34
+ def patch(attibutes)
35
+ connection.patch(path_prefix, attibutes).body
36
+ end
37
+
38
+ def destroy
39
+ connection.delete(path_prefix).status == 204
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+ # Gists::Proxy inherits from Ghee::Proxy and
46
+ # enables defining methods on the proxy object
47
+ #
48
+ class Proxy < ::Ghee::ResourceProxy
49
+ def compare(base, head)
50
+ connection.get("#{path_prefix}/compare/#{base}...#{head}").body
51
+ end
52
+ def commits(sha=nil, params={})
53
+ params = sha if sha.is_a?Hash
54
+ prefix = (!sha.is_a?(Hash) and sha) ? "#{path_prefix}/commits/#{sha}" : "#{path_prefix}/commits"
55
+ Ghee::API::Repos::Commits::Proxy.new(connection, prefix, params)
56
+ end
57
+ def comments(id=nil)
58
+ prefix = id ? "#{path_prefix}/comments/#{id}" : "#{path_prefix}/comments"
59
+ Ghee::API::Repos::Comments::Proxy.new connection, prefix
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+
@@ -0,0 +1,30 @@
1
+ class Ghee
2
+
3
+ # API module encapsulates all of API endpoints
4
+ # implemented thus far
5
+ #
6
+ module API
7
+
8
+ module Users
9
+ module Emails
10
+ class Proxy < ::Ghee::ResourceProxy
11
+
12
+ def add(emails)
13
+ connection.post(path_prefix, emails).body
14
+ end
15
+
16
+ def remove(emails)
17
+ connection.run_request(:delete,path_prefix, emails,nil).status == 204
18
+ end
19
+ end
20
+ end
21
+ class Proxy < ::Ghee::ResourceProxy
22
+ def emails
23
+ Ghee::API::Users::Emails::Proxy.new connection, "#{path_prefix}/emails"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+
@@ -0,0 +1,31 @@
1
+ class Ghee
2
+
3
+ # API module encapsulates all of API endpoints
4
+ # implemented thus far
5
+ #
6
+ module API
7
+
8
+ module Users
9
+ class Proxy < ::Ghee::ResourceProxy
10
+ def followers
11
+ connection.get("#{path_prefix}/followers").body
12
+ end
13
+ def following
14
+ connection.get("#{path_prefix}/following").body
15
+ end
16
+ def following?(user)
17
+ connection.get("#{path_prefix}/following/#{user}").status == 204
18
+ end
19
+ def follow(user)
20
+ connection.put("#{path_prefix}/following/#{user}").status == 204
21
+ end
22
+ def follow!(user)
23
+ connection.delete("#{path_prefix}/following/#{user}").status == 204
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+
@@ -0,0 +1,34 @@
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 Forks
14
+ class Proxy < ::Ghee::ResourceProxy
15
+ def create(org=nil)
16
+ params = org ? {:org => org} : {}
17
+ puts params
18
+ connection.post(path_prefix, params).body
19
+ end
20
+ end
21
+ end
22
+
23
+ # Gists::Proxy inherits from Ghee::Proxy and
24
+ # enables defining methods on the proxy object
25
+ #
26
+ class Proxy < ::Ghee::ResourceProxy
27
+ def forks(params={})
28
+ Ghee::API::Repos::Forks::Proxy.new connection, "#{path_prefix}/forks", params
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
@@ -10,14 +10,6 @@ class Ghee
10
10
  #
11
11
  module Repos
12
12
 
13
- # The Commits module handles repo commit endpoints
14
- #
15
- module Commits
16
- class Proxy < ::Ghee::ResourceProxy
17
- include Ghee::CUD
18
- end
19
- end
20
-
21
13
  # The Git module handles all of the raw git data endpoints
22
14
  #
23
15
  module Git
@@ -89,9 +81,9 @@ class Ghee
89
81
 
90
82
  # Get tree by a given sha
91
83
  #
92
- def trees(sha=nil)
84
+ def trees(sha=nil,params={})
93
85
  prefix = sha ? "#{path_prefix}/trees/#{sha}" : "#{path_prefix}/trees"
94
- Ghee::API::Repos::Git::Trees::Proxy.new(connection, prefix)
86
+ Ghee::API::Repos::Git::Trees::Proxy.new(connection, prefix, params)
95
87
  end
96
88
 
97
89
  # Get a tag by a given sha
@@ -102,6 +94,12 @@ class Ghee
102
94
  end
103
95
  end
104
96
  end
97
+ class Proxy < :: Ghee::ResourceProxy
98
+
99
+ def git
100
+ Ghee::API::Repos::Git::Proxy.new(connection, "#{path_prefix}/git")
101
+ end
102
+ end
105
103
  end
106
104
  end
107
105
  end
@@ -0,0 +1,45 @@
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
+
14
+ module Hooks
15
+ class Proxy < ::Ghee::ResourceProxy
16
+ include Ghee::CUD
17
+
18
+ # Test hook - This will trigger the hook with the
19
+ # latest push to the current repository.
20
+ #
21
+ def test
22
+ connection.post("#{path_prefix}/test").body
23
+ end
24
+
25
+
26
+ end
27
+ end
28
+
29
+ # Gists::Proxy inherits from Ghee::Proxy and
30
+ # enables defining methods on the proxy object
31
+ #
32
+ class Proxy < ::Ghee::ResourceProxy
33
+ # Get hooks
34
+ #
35
+ # Returns json
36
+ #
37
+ def hooks(number=nil, params={})
38
+ params = number if number.is_a?Hash
39
+ prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/hooks/#{number}" : "#{path_prefix}/hooks"
40
+ Ghee::API::Repos::Hooks::Proxy.new(connection, prefix, params)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -5,108 +5,123 @@ class Ghee
5
5
  #
6
6
  module API
7
7
 
8
+ module Repos
8
9
 
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
10
+ # The Issues module handles all of the Github Repo Issues
15
11
  # API endpoints
16
12
  #
17
- module Labels
13
+ module Issues
14
+
15
+ # API labels module handles all of the Github Issues
16
+ # API endpoints
17
+ #
18
+ module Labels
19
+ class Proxy < ::Ghee::ResourceProxy
20
+
21
+ # Creates label for an issue using the authenicated user
22
+ #
23
+ # labels - Array of labels
24
+ #
25
+ # return json
26
+ #
27
+ def add(labels)
28
+ connection.post(path_prefix,labels).body
29
+ end
30
+
31
+ # Patchs and existing label
32
+ #
33
+ # return json
34
+ #
35
+ def replace(labels)
36
+ connection.put(path_prefix, labels).body
37
+ end
38
+
39
+ # Destroys label by id
40
+ #
41
+ # return boolean
42
+ #
43
+ def remove
44
+ connection.delete(path_prefix).status == 204
45
+ end
46
+ end
47
+ end
48
+
49
+ # API Comments module handles all of the Github Issues
50
+ # API endpoints
51
+ #
52
+ module Comments
53
+ class Proxy < ::Ghee::ResourceProxy
54
+ include Ghee::CUD
55
+ end
56
+ end
57
+
58
+ module Events
59
+ class Proxy < ::Ghee::ResourceProxy
60
+
61
+ end
62
+ end
63
+
64
+ # Gists::Proxy inherits from Ghee::Proxy and
65
+ # enables defining methods on the proxy object
66
+ #
18
67
  class Proxy < ::Ghee::ResourceProxy
68
+ include Ghee::CUD
19
69
 
20
- # Creates label for an issue using the authenicated user
70
+ # Close issue - closed issue by id
21
71
  #
22
- # labels - Array of labels
72
+ # usage - ghee.repos("my_repo").issues(1).close
23
73
  #
24
- # return json
74
+ # returns boolean
25
75
  #
26
- def add(labels)
27
- connection.post(path_prefix,labels).body
76
+ def close
77
+ connection.patch(path_prefix,:state => "closed").body["state"] == "closed"
28
78
  end
29
79
 
30
- # Patchs and existing label
80
+ # Returns closed issues
31
81
  #
32
- # return json
82
+ # Returns json
33
83
  #
34
- def replace(labels)
35
- connection.put(path_prefix, labels).body
84
+ def closed
85
+ response = connection.get path_prefix do |req|
86
+ req.params["state"] = "closed"
87
+ end
88
+ response.body
36
89
  end
37
90
 
38
- # Destroys label by id
39
- #
40
- # return boolean
41
- #
42
- def remove
43
- connection.delete(path_prefix).status == 204
91
+ # Returns issue comments for an issue or all of the comments
92
+ # for a repo
93
+ def comments(id=nil)
94
+ prefix = id ? "#{path_prefix}/comments/#{id}" : "#{path_prefix}/comments"
95
+ Ghee::API::Repos::Issues::Comments::Proxy.new(connection,prefix)
44
96
  end
45
- end
46
- end
47
97
 
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
98
+ # Returns all of the labels for repo
99
+ #
100
+ def labels
101
+ Ghee::API::Repos::Issues::Labels::Proxy.new(connection, "#{path_prefix}/labels")
102
+ end
56
103
 
57
- module Events
58
- class Proxy < ::Ghee::ResourceProxy
104
+ # Returns issue events for a repo or issue number
105
+ #
106
+ def events(id=nil)
107
+ prefix = id ? "#{path_prefix}/events/#{id}" : "#{path_prefix}/events"
108
+ Ghee::API::Repos::Issues::Events::Proxy.new(connection,prefix)
109
+ end
59
110
 
60
111
  end
61
112
  end
62
113
 
63
- # Gists::Proxy inherits from Ghee::Proxy and
64
- # enables defining methods on the proxy object
65
- #
66
114
  class Proxy < ::Ghee::ResourceProxy
67
- include Ghee::CUD
68
115
 
69
- # Close issue - closed issue by id
70
- #
71
- # usage - ghee.repos("my_repo").issues(1).close
72
- #
73
- # returns boolean
74
- #
75
- def close
76
- connection.patch(path_prefix,:state => "closed").body["state"] == "closed"
77
- end
78
-
79
- # Returns closed issues
116
+ # Get issues
80
117
  #
81
118
  # Returns json
82
119
  #
83
- def closed
84
- response = connection.get path_prefix do |req|
85
- req.params["state"] = "closed"
86
- end
87
- response.body
88
- end
89
-
90
- # Returns issue comments for an issue or all of the comments
91
- # for a repo
92
- def comments(id=nil)
93
- prefix = id ? "#{path_prefix}/comments/#{id}" : "#{path_prefix}/comments"
94
- Ghee::API::Issues::Comments::Proxy.new(connection,prefix)
120
+ def issues(number=nil, params={})
121
+ params = number if number.is_a?Hash
122
+ prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/issues/#{number}" : "#{path_prefix}/issues"
123
+ Ghee::API::Repos::Issues::Proxy.new(connection, prefix, params)
95
124
  end
96
-
97
- # Returns all of the labels for repo
98
- #
99
- def labels
100
- Ghee::API::Issues::Labels::Proxy.new(connection, "#{path_prefix}/labels")
101
- end
102
-
103
- # Returns issue events for a repo or issue number
104
- #
105
- def events(id=nil)
106
- prefix = id ? "#{path_prefix}/events/#{id}" : "#{path_prefix}/events"
107
- Ghee::API::Issues::Events::Proxy.new(connection,prefix)
108
- end
109
-
110
125
  end
111
126
  end
112
127
  end