github_api 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -80,14 +80,14 @@ module Github
80
80
  # <tt>:name</tt> - Optional string
81
81
  #
82
82
  # = Examples
83
- # github = Github.new :oauth_token => '...'
83
+ # github = Github.new oauth_token: '...'
84
84
  # github.orgs.edit 'github',
85
- # "billing_email" => "support@github.com",
86
- # "blog" => "https://github.com/blog",
87
- # "company" => "GitHub",
88
- # "email" => "support@github.com",
89
- # "location" => "San Francisco",
90
- # "name" => "github"
85
+ # "billing_email": "support@github.com",
86
+ # "blog": "https://github.com/blog",
87
+ # "company": "GitHub",
88
+ # "email": "support@github.com",
89
+ # "location": "San Francisco",
90
+ # "name": "github"
91
91
  #
92
92
  def edit(org_name, params={})
93
93
  assert_presence_of org_name
@@ -25,7 +25,7 @@ module Github
25
25
  #
26
26
  # Examples:
27
27
  # github = Github.new
28
- # github.collaborators.collaborator?('user', 'repo', 'collaborator')
28
+ # github.repos.collaborators.collaborator?('user', 'repo', 'collaborator')
29
29
  #
30
30
  def collaborator?(user_name, repo_name, collaborator, params={})
31
31
  set :user => user_name, :repo => repo_name
@@ -2,6 +2,11 @@
2
2
 
3
3
  module Github
4
4
  class Repos::PubSubHubbub < API
5
+ OPTIONS = {
6
+ :headers => {
7
+ CONTENT_TYPE => 'application/x-www-form-urlencoded'
8
+ }
9
+ }
5
10
 
6
11
  # Subscribe to existing topic/event through pubsubhubbub
7
12
  #
@@ -22,7 +27,7 @@ module Github
22
27
  normalize! params
23
28
  _merge_action!("subscribe", topic, callback, params)
24
29
 
25
- post_request("/hub", params)
30
+ post_request("/hub", params, OPTIONS)
26
31
  end
27
32
 
28
33
  # Unsubscribe from existing topic/event through pubsubhubbub
@@ -44,7 +49,7 @@ module Github
44
49
  normalize! params
45
50
  _merge_action!("unsubscribe", topic, callback, params)
46
51
 
47
- post_request("/hub", params)
52
+ post_request("/hub", params, OPTIONS)
48
53
  end
49
54
 
50
55
  # Subscribe repository to service hook through pubsubhubbub
@@ -4,7 +4,7 @@ module Github
4
4
  module VERSION
5
5
  MAJOR = 0
6
6
  MINOR = 8
7
- PATCH = 5
7
+ PATCH = 6
8
8
  BUILD = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Github::Issues, '#create' do
5
+ describe Github::Issues, '#edit' do
6
6
  let(:user) { 'peter-murach' }
7
7
  let(:repo) { 'github' }
8
8
  let(:issue_id) { 1347 }
@@ -25,17 +25,17 @@ describe Github::Issues::Labels, '#remove' do
25
25
  end
26
26
 
27
27
  it "should remove label successfully" do
28
- subject.remove user, repo, issue_id, label_id
28
+ subject.remove user, repo, issue_id, :label_name => label_id
29
29
  a_delete(request_path).should have_been_made
30
30
  end
31
31
 
32
32
  it "should return the resource" do
33
- labels = subject.remove user, repo, issue_id, label_id
33
+ labels = subject.remove user, repo, issue_id, :label_name => label_id
34
34
  labels.first.should be_a Hashie::Mash
35
35
  end
36
36
 
37
37
  it "should get the label information" do
38
- labels = subject.remove user, repo, issue_id, label_id
38
+ labels = subject.remove user, repo, issue_id, :label_name => label_id
39
39
  labels.first.name.should == 'bug'
40
40
  end
41
41
  end
@@ -52,7 +52,7 @@ describe Github::Issues::Labels, '#remove' do
52
52
  end
53
53
 
54
54
  it_should_behave_like 'request failure' do
55
- let(:requestable) { subject.remove user, repo, issue_id, label_id }
55
+ let(:requestable) { subject.remove user, repo, issue_id, :label_name => label_id }
56
56
  end
57
57
 
58
58
  end # remove
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Orgs, '#edit' do
6
+ let(:org) { 'github' }
7
+ let(:request_path) { "/orgs/#{org}" }
8
+ let(:body) { fixture("orgs/org.json") }
9
+ let(:status) { 200 }
10
+ let(:inputs) {
11
+ { :billing_email => 'support@github.com',
12
+ :blog => "https://github.com/blog",
13
+ :company => "GitHub",
14
+ :email => "support@github.com",
15
+ :location => "San Francisco",
16
+ :name => "github"
17
+ }
18
+ }
19
+
20
+ before {
21
+ stub_patch(request_path).with(inputs).
22
+ to_return(:body => body, :status => status,
23
+ :headers => {:content_type => "application/json; charset=utf-8"})
24
+ }
25
+
26
+ after { reset_authentication_for(subject) }
27
+
28
+ context "resource edited successfully" do
29
+
30
+ it "should fail to edit without 'user/repo' parameters" do
31
+ expect { subject.edit }.to raise_error(ArgumentError)
32
+ end
33
+
34
+ it "should edit the resource" do
35
+ subject.edit org
36
+ a_patch(request_path).with(inputs).should have_been_made
37
+ end
38
+
39
+ it "should return resource" do
40
+ organisation = subject.edit org
41
+ organisation.should be_a Hashie::Mash
42
+ end
43
+
44
+ it "should be able to retrieve information" do
45
+ organisation = subject.edit org
46
+ organisation.name.should == 'github'
47
+ end
48
+ end
49
+
50
+ it_should_behave_like 'request failure' do
51
+ let(:requestable) { subject.edit org }
52
+ end
53
+
54
+ end # edit
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Orgs, '#get' do
6
+ let(:org) { 'github' }
7
+ let(:request_path) { "/orgs/#{org}" }
8
+ let(:body) { fixture('orgs/org.json') }
9
+ let(:status) { 200 }
10
+
11
+ before {
12
+ stub_get(request_path).to_return(:body => body, :status => status,
13
+ :headers => {:content_type => "application/json; charset=utf-8"})
14
+ }
15
+
16
+ after { reset_authentication_for(subject) }
17
+
18
+ context "resource found" do
19
+ it "should fail to get resource without org name" do
20
+ expect { subject.get }.to raise_error(ArgumentError)
21
+ end
22
+
23
+ it "should get the resource" do
24
+ subject.get org
25
+ a_get(request_path).should have_been_made
26
+ end
27
+
28
+ it "should get org information" do
29
+ organisation = subject.get org
30
+ organisation.id.should == 1
31
+ organisation.login.should == 'github'
32
+ end
33
+
34
+ it "should return mash" do
35
+ organisation = subject.get org
36
+ organisation.should be_a Hashie::Mash
37
+ end
38
+ end
39
+
40
+ it_should_behave_like 'request failure' do
41
+ let(:requestable) { subject.get org }
42
+ end
43
+
44
+ end # get
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Github::Orgs, '#list' do
6
+ let(:user) { 'peter-murach' }
7
+ let(:body) { fixture('orgs/orgs.json') }
8
+ let(:status) { 200 }
9
+
10
+ before {
11
+ stub_get(request_path).to_return(:body => body, :status => status,
12
+ :headers => {:content_type => "application/json; charset=utf-8"})
13
+ }
14
+
15
+ after { reset_authentication_for(subject) }
16
+
17
+ context "resource found for a user" do
18
+ let(:request_path) { "/users/#{user}/orgs" }
19
+
20
+ it "should get the resources" do
21
+ subject.list :user => user
22
+ a_get(request_path).should have_been_made
23
+ end
24
+
25
+ it_should_behave_like 'an array of resources' do
26
+ let(:requestable) { subject.list :user => user }
27
+ end
28
+
29
+ it "should get org information" do
30
+ orgs = subject.list :user => user
31
+ orgs.first.login.should == 'github'
32
+ end
33
+
34
+ it "should yield to a block" do
35
+ yielded = []
36
+ result = subject.list(:user => user) { |obj| yielded << obj }
37
+ yielded.should == result
38
+ end
39
+
40
+ it_should_behave_like 'request failure' do
41
+ let(:requestable) { subject.list :user => user }
42
+ end
43
+ end
44
+
45
+ context "resource found for an au user" do
46
+ let(:request_path) { "/user/orgs" }
47
+
48
+ before do
49
+ subject.oauth_token = OAUTH_TOKEN
50
+ stub_get(request_path).
51
+ with(:query => { :access_token => OAUTH_TOKEN }).
52
+ to_return(:body => fixture('orgs/orgs.json'), :status => status,
53
+ :headers => {:content_type => "application/json; charset=utf-8"})
54
+ end
55
+
56
+ it "should get the resources" do
57
+ subject.list
58
+ a_get(request_path).with(:query => { :access_token => OAUTH_TOKEN }).
59
+ should have_been_made
60
+ end
61
+ end
62
+
63
+ end # list
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Github::Orgs, 'integration' do
4
+
5
+ after { reset_authentication_for subject }
6
+
7
+ it_should_behave_like 'api interface'
8
+
9
+ its(:members) { should be_a Github::Orgs::Members }
10
+
11
+ its(:teams) { should be_a Github::Orgs::Teams }
12
+
13
+ end # Github::Orgs
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-27 00:00:00.000000000Z
12
+ date: 2013-01-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie
16
- requirement: &2152614200 !ruby/object:Gem::Requirement
16
+ requirement: &2152507880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152614200
24
+ version_requirements: *2152507880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &2152612800 !ruby/object:Gem::Requirement
27
+ requirement: &2152438200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152612800
35
+ version_requirements: *2152438200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &2152611660 !ruby/object:Gem::Requirement
38
+ requirement: &2152437500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152611660
46
+ version_requirements: *2152437500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: oauth2
49
- requirement: &2152610920 !ruby/object:Gem::Requirement
49
+ requirement: &2152436880 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2152610920
57
+ version_requirements: *2152436880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &2152610000 !ruby/object:Gem::Requirement
60
+ requirement: &2152436280 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.5.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2152610000
68
+ version_requirements: *2152436280
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &2152609360 !ruby/object:Gem::Requirement
71
+ requirement: &2152435780 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152609360
79
+ version_requirements: *2152435780
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: cucumber
82
- requirement: &2152608580 !ruby/object:Gem::Requirement
82
+ requirement: &2152435260 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152608580
90
+ version_requirements: *2152435260
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &2152607380 !ruby/object:Gem::Requirement
93
+ requirement: &2152434700 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.9.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2152607380
101
+ version_requirements: *2152434700
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: vcr
104
- requirement: &2152594440 !ruby/object:Gem::Requirement
104
+ requirement: &2152434220 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 2.3.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *2152594440
112
+ version_requirements: *2152434220
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: simplecov
115
- requirement: &2152578140 !ruby/object:Gem::Requirement
115
+ requirement: &2152433700 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.7.1
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *2152578140
123
+ version_requirements: *2152433700
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: guard
126
- requirement: &2152577520 !ruby/object:Gem::Requirement
126
+ requirement: &2152433180 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *2152577520
134
+ version_requirements: *2152433180
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: guard-rspec
137
- requirement: &2152576620 !ruby/object:Gem::Requirement
137
+ requirement: &2152432620 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *2152576620
145
+ version_requirements: *2152432620
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: guard-cucumber
148
- requirement: &2152575420 !ruby/object:Gem::Requirement
148
+ requirement: &2152432040 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *2152575420
156
+ version_requirements: *2152432040
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rake
159
- requirement: &2152573780 !ruby/object:Gem::Requirement
159
+ requirement: &2152414660 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *2152573780
167
+ version_requirements: *2152414660
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: bundler
170
- requirement: &2152572380 !ruby/object:Gem::Requirement
170
+ requirement: &2152414180 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,7 +175,7 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *2152572380
178
+ version_requirements: *2152414180
179
179
  description: ! ' Ruby wrapper that supports all of the GitHub API v3 methods(nearly
180
180
  200). It''s build in a modular way, that is, you can either instantiate the whole
181
181
  api wrapper Github.new or use parts of it e.i. Github::Repos.new if working solely
@@ -240,12 +240,16 @@ files:
240
240
  - features/cassettes/issues/events/list_issue.yml
241
241
  - features/cassettes/issues/events/list_repo.yml
242
242
  - features/cassettes/issues/get.yml
243
+ - features/cassettes/issues/labels/add.yml
243
244
  - features/cassettes/issues/labels/create.yml
244
245
  - features/cassettes/issues/labels/delete.yml
245
246
  - features/cassettes/issues/labels/get.yml
246
247
  - features/cassettes/issues/labels/list_issue.yml
247
248
  - features/cassettes/issues/labels/list_milestone.yml
248
249
  - features/cassettes/issues/labels/list_repo.yml
250
+ - features/cassettes/issues/labels/remove_all.yml
251
+ - features/cassettes/issues/labels/remove_one.yml
252
+ - features/cassettes/issues/labels/replace.yml
249
253
  - features/cassettes/issues/labels/update.yml
250
254
  - features/cassettes/issues/list/repo.yml
251
255
  - features/cassettes/issues/list/user.yml
@@ -284,6 +288,8 @@ files:
284
288
  - features/cassettes/repos/contents/get.yml
285
289
  - features/cassettes/repos/contents/readme.yml
286
290
  - features/cassettes/repos/create.yml
291
+ - features/cassettes/repos/forks/list.yml
292
+ - features/cassettes/repos/forks/list_sort.yml
287
293
  - features/cassettes/repos/get.yml
288
294
  - features/cassettes/repos/languages.yml
289
295
  - features/cassettes/repos/list.yml
@@ -325,6 +331,7 @@ files:
325
331
  - features/pull_requests.feature
326
332
  - features/README.rdoc
327
333
  - features/repos/contents.feature
334
+ - features/repos/forks.feature
328
335
  - features/repos/statuses.feature
329
336
  - features/repos.feature
330
337
  - features/say.feature
@@ -633,9 +640,12 @@ files:
633
640
  - spec/github/issues/milestones_spec.rb
634
641
  - spec/github/mime_type_spec.rb
635
642
  - spec/github/normalizer_spec.rb
643
+ - spec/github/orgs/edit_spec.rb
644
+ - spec/github/orgs/get_spec.rb
645
+ - spec/github/orgs/list_spec.rb
636
646
  - spec/github/orgs/members_spec.rb
647
+ - spec/github/orgs/orgs_spec.rb
637
648
  - spec/github/orgs/teams_spec.rb
638
- - spec/github/orgs_spec.rb
639
649
  - spec/github/page_iterator_spec.rb
640
650
  - spec/github/page_links_spec.rb
641
651
  - spec/github/paged_request_spec.rb