ghee 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
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 Keys
14
+ class Proxy < ::Ghee::ResourceProxy
15
+ include Ghee::CUD
16
+ end
17
+ end
18
+
19
+ # Proxy inherits from Ghee::Proxy and
20
+ # enables defining methods on the proxy object
21
+ #
22
+ class Proxy < ::Ghee::ResourceProxy
23
+
24
+ def keys(id=nil)
25
+ prefix = id ? "#{path_prefix}/keys/#{id}" : "#{path_prefix}/keys"
26
+ Ghee::API::Repos::Keys::Proxy.new connection, prefix
27
+ end
28
+ end
29
+ end
30
+ # The Users module handles all of the Github Repo
31
+ # API endpoints
32
+ #
33
+ module Users
34
+
35
+ module Keys
36
+ class Proxy < ::Ghee::ResourceProxy
37
+ include Ghee::CUD
38
+ end
39
+ end
40
+
41
+ # Proxy inherits from Ghee::Proxy and
42
+ # enables defining methods on the proxy object
43
+ #
44
+ class Proxy < ::Ghee::ResourceProxy
45
+
46
+ def keys(id=nil)
47
+ prefix = id ? "#{path_prefix}/keys/#{id}" : "#{path_prefix}/keys"
48
+ Ghee::API::Users::Keys::Proxy.new connection, prefix
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+
56
+
@@ -0,0 +1,38 @@
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
+ # Gists::Proxy inherits from Ghee::Proxy and
20
+ # enables defining methods on the proxy object
21
+ #
22
+ class Proxy < ::Ghee::ResourceProxy
23
+
24
+ # Get labels for a repo
25
+ #
26
+ # id - Number get a specific label (optional)
27
+ #
28
+ # Returns json
29
+ #
30
+ def labels(number=nil, params={})
31
+ params = number if number.is_a?Hash
32
+ prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/labels/#{number}" : "#{path_prefix}/labels"
33
+ Ghee::API::Repos::Labels::Proxy.new(connection, prefix, params)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -5,40 +5,58 @@ class Ghee
5
5
  #
6
6
  module API
7
7
 
8
+ module Repos
9
+
10
+ # The Milestones module handles all of the Github Repo Milestones
11
+ # API endpoints
12
+ #
13
+ module Milestones
8
14
 
9
- # The Milestones module handles all of the Github Repo Milestones
10
- # API endpoints
11
- #
12
- module Milestones
13
15
 
16
+ # Gists::Proxy inherits from Ghee::Proxy and
17
+ # enables defining methods on the proxy object
18
+ #
19
+ class Proxy < ::Ghee::ResourceProxy
20
+ include Ghee::CUD
21
+
22
+ # Close milestone - closed milestone by id
23
+ #
24
+ # usage - ghee.repos("my_repo").milestones(1).close
25
+ #
26
+ # returns boolean
27
+ #
28
+ def close
29
+ connection.patch(path_prefix,:state => "closed").body["state"] == "closed"
30
+ end
31
+
32
+ # Returns closed milestones
33
+ #
34
+ # Returns json
35
+ #
36
+ def closed
37
+ response = connection.get path_prefix do |req|
38
+ req.params["state"] = "closed"
39
+ end
40
+ response.body
41
+ end
42
+
43
+ end
44
+ end
14
45
 
15
46
  # Gists::Proxy inherits from Ghee::Proxy and
16
47
  # enables defining methods on the proxy object
17
48
  #
18
49
  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
50
 
31
- # Returns closed milestones
51
+ # Get milestones
32
52
  #
33
53
  # Returns json
34
54
  #
35
- def closed
36
- response = connection.get path_prefix do |req|
37
- req.params["state"] = "closed"
38
- end
39
- response.body
55
+ def milestones(number=nil, params={})
56
+ params = number if number.is_a?Hash
57
+ prefix = (!number.is_a?(Hash) and number) ? "#{path_prefix}/milestones/#{number}" : "#{path_prefix}/milestones"
58
+ Ghee::API::Repos::Milestones::Proxy.new(connection, prefix, params)
40
59
  end
41
-
42
60
  end
43
61
  end
44
62
  end
@@ -10,84 +10,10 @@ class Ghee
10
10
  #
11
11
  module Repos
12
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
13
  # Gists::Proxy inherits from Ghee::Proxy and
35
14
  # enables defining methods on the proxy object
36
15
  #
37
16
  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
- def commits(sha=nil, params={})
82
- params = sha if sha.is_a?Hash
83
- prefix = (!sha.is_a?(Hash) and sha) ? "#{path_prefix}/commits/#{sha}" : "#{path_prefix}/commits"
84
- Ghee::API::Repos::Commits::Proxy.new(connection, prefix, params)
85
- end
86
-
87
- def git
88
- Ghee::API::Repos::Git::Proxy.new(connection, "#{path_prefix}/git")
89
- end
90
-
91
17
  end
92
18
 
93
19
  # Get repos
@@ -0,0 +1,41 @@
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
+ # Proxy inherits from Ghee::Proxy and
14
+ # enables defining methods on the proxy object
15
+ #
16
+ class Proxy < ::Ghee::ResourceProxy
17
+
18
+ def watchers
19
+ connection.get("#{path_prefix}/watchers").body
20
+ end
21
+ end
22
+ end
23
+ module Users
24
+ class Proxy < ::Ghee::ResourceProxy
25
+ def watched
26
+ connection.get("#{path_prefix}/watched").body
27
+ end
28
+ def watching?(user,repo)
29
+ connection.get("#{path_prefix}/watched/#{user}/#{repo}").status == 204
30
+ end
31
+ def watch(user, repo)
32
+ connection.put("#{path_prefix}/watched/#{user}/#{repo}").status == 204
33
+ end
34
+ def watch!(user, repo)
35
+ connection.delete("#{path_prefix}/watched/#{user}/#{repo}").status == 204
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+
@@ -8,7 +8,7 @@ class Ghee
8
8
  class ResourceProxy
9
9
 
10
10
  # Undefine methods that might get in the way
11
- instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval|instance_variable_get|object_id/ }
11
+ instance_methods.each { |m| undef_method m unless m =~ /^__|instance_eval|instance_variable_get|object_id|respond_to/ }
12
12
 
13
13
  # Make connection and path_prefix readable
14
14
  attr_reader :connection, :path_prefix, :params
data/lib/ghee/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  class Ghee
3
- VERSION = "0.8.0"
3
+ VERSION = "0.9.0"
4
4
  end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ghee::API::Repos::Collaborators do
4
+ subject { Ghee.new(GH_AUTH).repos(GH_USER, GH_REPO) }
5
+
6
+ describe "#collaborators" do
7
+
8
+ # dont have a good way to test the collaborators api
9
+ it "should have a collaborators method" do
10
+ subject.respond_to?("collaborators").should be_true
11
+ end
12
+
13
+ end
14
+ end
@@ -40,6 +40,18 @@ describe Ghee::API::Repos::Git do
40
40
  should_be_a_commit commits.first
41
41
  end
42
42
  end
43
+ it "should return a single commit" do
44
+ VCR.use_cassette "#repos()#commit(sha)" do
45
+ sha = subject.commits.first["sha"]
46
+ commit = subject.commits(sha)
47
+ should_be_a_commit commit
48
+ end
49
+ end
50
+ it "should respond to comments" do
51
+ # check that the method is there
52
+ # Todo: create a comment in the before context
53
+ subject.respond_to?("comments").should be_true
54
+ end
43
55
  end
44
56
 
45
57
  describe "#repos(login,name)#git" do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Ghee::API::Issues do
3
+ describe Ghee::API::Repos::Issues do
4
4
  subject { Ghee.new(GH_AUTH) }
5
5
 
6
6
  def should_be_an_issue(issue)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Ghee::API::Milestones do
3
+ describe Ghee::API::Repos::Milestones do
4
4
  subject { Ghee.new(GH_AUTH) }
5
5
 
6
6
  def should_be_an_milestone(milestone)
@@ -98,5 +98,19 @@ describe Ghee::API::Users do
98
98
  user['login'].should == 'jonmagic'
99
99
  end
100
100
  end
101
+ describe "#emails" do
102
+ it "should add and remove emails" do
103
+ VCR.use_cassette("user#emails") do
104
+ user = subject.user
105
+ emails = user.emails.add (["support@microsoft.com","octocat@microsoft.com"])
106
+ emails.should include("support@microsoft.com")
107
+ emails.should include("octocat@microsoft.com")
108
+ user.emails.remove(["support@microsoft.com","octocat@microsoft.com"]).should be_true
109
+ emails = user.emails
110
+ emails.should_not include("support@microsoft.com")
111
+ emails.should_not include("octocat@microsoft.com")
112
+ end
113
+ end
114
+ end
101
115
  end
102
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-08 00:00:00.000000000Z
13
+ date: 2012-04-14 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
- requirement: &70200201095860 !ruby/object:Gem::Requirement
17
+ requirement: &70292263270720 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70200201095860
25
+ version_requirements: *70292263270720
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: faraday_middleware
28
- requirement: &70200201095200 !ruby/object:Gem::Requirement
28
+ requirement: &70292263270280 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70200201095200
36
+ version_requirements: *70292263270280
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: multi_json
39
- requirement: &70200201094540 !ruby/object:Gem::Requirement
39
+ requirement: &70292263269860 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70200201094540
47
+ version_requirements: *70292263269860
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: yajl-ruby
50
- requirement: &70200201094040 !ruby/object:Gem::Requirement
50
+ requirement: &70292263269440 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70200201094040
58
+ version_requirements: *70292263269440
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rake
61
- requirement: &70200201093440 !ruby/object:Gem::Requirement
61
+ requirement: &70292263269020 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70200201093440
69
+ version_requirements: *70292263269020
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: json
72
- requirement: &70200201092740 !ruby/object:Gem::Requirement
72
+ requirement: &70292263268600 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70200201092740
80
+ version_requirements: *70292263268600
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rspec
83
- requirement: &70200201076300 !ruby/object:Gem::Requirement
83
+ requirement: &70292263268100 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '2.0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70200201076300
91
+ version_requirements: *70292263268100
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: webmock
94
- requirement: &70200201075480 !ruby/object:Gem::Requirement
94
+ requirement: &70292263267680 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *70200201075480
102
+ version_requirements: *70292263267680
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: vcr
105
- requirement: &70200201074620 !ruby/object:Gem::Requirement
105
+ requirement: &70292263267220 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *70200201074620
113
+ version_requirements: *70292263267220
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: ZenTest
116
- requirement: &70200201073820 !ruby/object:Gem::Requirement
116
+ requirement: &70292257168360 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *70200201073820
124
+ version_requirements: *70292257168360
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: autotest-growl
127
- requirement: &70200201073000 !ruby/object:Gem::Requirement
127
+ requirement: &70292257167940 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
@@ -132,7 +132,7 @@ dependencies:
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *70200201073000
135
+ version_requirements: *70292257167940
136
136
  description: A complete, simple, and intuitive ruby API for all things Github.
137
137
  email:
138
138
  - rauh.ryan@gmail.com
@@ -150,21 +150,31 @@ files:
150
150
  - ghee.gemspec
151
151
  - lib/ghee.rb
152
152
  - lib/ghee/api/authorizations.rb
153
+ - lib/ghee/api/collaborators.rb
154
+ - lib/ghee/api/commits.rb
153
155
  - lib/ghee/api/downloads.rb
156
+ - lib/ghee/api/emails.rb
154
157
  - lib/ghee/api/events.rb
158
+ - lib/ghee/api/followers.rb
159
+ - lib/ghee/api/forks.rb
155
160
  - lib/ghee/api/gists.rb
156
161
  - lib/ghee/api/git_data.rb
162
+ - lib/ghee/api/hooks.rb
157
163
  - lib/ghee/api/issues.rb
164
+ - lib/ghee/api/keys.rb
165
+ - lib/ghee/api/labels.rb
158
166
  - lib/ghee/api/milestones.rb
159
167
  - lib/ghee/api/orgs.rb
160
168
  - lib/ghee/api/repos.rb
161
169
  - lib/ghee/api/users.rb
170
+ - lib/ghee/api/watchers.rb
162
171
  - lib/ghee/connection.rb
163
172
  - lib/ghee/resource_proxy.rb
164
173
  - lib/ghee/state_methods.rb
165
174
  - lib/ghee/version.rb
166
175
  - spec/fyeah.jpg
167
176
  - spec/ghee/api/authorizations_spec.rb
177
+ - spec/ghee/api/collaborators_spec.rb
168
178
  - spec/ghee/api/downloads_spec.rb
169
179
  - spec/ghee/api/events_spec.rb
170
180
  - spec/ghee/api/gists_spec.rb
@@ -209,6 +219,7 @@ summary: Access Github in ruby.
209
219
  test_files:
210
220
  - spec/fyeah.jpg
211
221
  - spec/ghee/api/authorizations_spec.rb
222
+ - spec/ghee/api/collaborators_spec.rb
212
223
  - spec/ghee/api/downloads_spec.rb
213
224
  - spec/ghee/api/events_spec.rb
214
225
  - spec/ghee/api/gists_spec.rb