gh 0.13.0 → 0.13.1

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gh/error.rb +2 -2
  3. data/lib/gh/response.rb +1 -1
  4. data/lib/gh/version.rb +1 -1
  5. metadata +6 -94
  6. data/.gitignore +0 -4
  7. data/.travis.yml +0 -19
  8. data/Gemfile +0 -6
  9. data/README.md +0 -117
  10. data/Rakefile +0 -6
  11. data/gh.gemspec +0 -28
  12. data/spec/cache_spec.rb +0 -28
  13. data/spec/custom_limit_spec.rb +0 -23
  14. data/spec/error_spec.rb +0 -55
  15. data/spec/gh_spec.rb +0 -32
  16. data/spec/instrumentation_spec.rb +0 -30
  17. data/spec/lazy_loader_spec.rb +0 -63
  18. data/spec/link_follower_spec.rb +0 -24
  19. data/spec/merge_commit_spec.rb +0 -24
  20. data/spec/normalizer_spec.rb +0 -319
  21. data/spec/pagination_spec.rb +0 -32
  22. data/spec/parallel_spec.rb +0 -95
  23. data/spec/payloads/.yml +0 -3
  24. data/spec/payloads/repos/rkh/gh/contents/README.md_per_page_100.yml +0 -15
  25. data/spec/payloads/repos/rkh/test-project-1.yml +0 -23
  26. data/spec/payloads/repos/sinatra/sinatra/issues/56/comments.yml +0 -36
  27. data/spec/payloads/repos/sinatra/sinatra/issues/comments/383214.yml +0 -21
  28. data/spec/payloads/repos/sinatra/sinatra/pulls/56.yml +0 -23
  29. data/spec/payloads/repos/travis-repos/test-project-1.yml +0 -21
  30. data/spec/payloads/repos/travis-repos/test-project-1/git/commits/ca3c0a44ec1d9bf8557d2653aa1b79fcc9ff5f5d.yml +0 -23
  31. data/spec/payloads/repos/travis-repos/test-project-1/git/refs/pull/1.yml +0 -20
  32. data/spec/payloads/repos/travis-repos/test-project-1/pulls/1.yml +0 -24
  33. data/spec/payloads/users/rkh.yml +0 -22
  34. data/spec/payloads/users/rkh/repos.yml +0 -52
  35. data/spec/payloads/users/rkh/repos_page_2&per_page=100.yml +0 -49
  36. data/spec/payloads/users/rkh/repos_page_2.yml +0 -54
  37. data/spec/payloads/users/rkh/repos_page_2_per_page_100.yml +0 -49
  38. data/spec/payloads/users/rkh/repos_page_3.yml +0 -57
  39. data/spec/payloads/users/rkh/repos_page_4.yml +0 -56
  40. data/spec/payloads/users/rkh/repos_page_5.yml +0 -28
  41. data/spec/payloads/users/rkh/repos_per_page_100.yml +0 -121
  42. data/spec/payloads/users/rkh_per_page_100.yml +0 -21
  43. data/spec/payloads/users/rtomayko.yml +0 -21
  44. data/spec/payloads/users/svenfuchs.yml +0 -21
  45. data/spec/payloads/users/travis-repos.yml +0 -21
  46. data/spec/pull_request_hook.json +0 -181
  47. data/spec/remote_spec.rb +0 -48
  48. data/spec/response_spec.rb +0 -19
  49. data/spec/spec_helper.rb +0 -88
  50. data/spec/stack_spec.rb +0 -5
  51. data/spec/token_check_spec.rb +0 -27
  52. data/spec/wrapper_spec.rb +0 -5
@@ -1,181 +0,0 @@
1
- {
2
- "action": "synchronize",
3
- "number": 1,
4
- "pull_request": {
5
- "_links": {
6
- "comments": {
7
- "href": "https://api.github.com/repos/travis-repos/test-project-1/issues/1/comments"
8
- },
9
- "html": {
10
- "href": "https://github.com/travis-repos/test-project-1/pull/1"
11
- },
12
- "review_comments": {
13
- "href": "https://api.github.com/repos/travis-repos/test-project-1/pulls/1/comments"
14
- },
15
- "self": {
16
- "href": "https://api.github.com/repos/travis-repos/test-project-1/pulls/1"
17
- }
18
- },
19
- "additions": 3,
20
- "base": {
21
- "label": "travis-repos:master",
22
- "ref": "master",
23
- "repo": {
24
- "clone_url": "https://github.com/travis-repos/test-project-1.git",
25
- "created_at": "2011-04-14T18:23:41Z",
26
- "description": "Test dummy repository for testing Travis CI",
27
- "fork": false,
28
- "forks": 6,
29
- "git_url": "git://github.com/travis-repos/test-project-1.git",
30
- "has_downloads": true,
31
- "has_issues": false,
32
- "has_wiki": false,
33
- "homepage": "http://travis-ci.org",
34
- "html_url": "https://github.com/travis-repos/test-project-1",
35
- "id": 1615549,
36
- "language": "Ruby",
37
- "mirror_url": null,
38
- "name": "test-project-1",
39
- "open_issues": 3,
40
- "owner": {
41
- "avatar_url": "https://secure.gravatar.com/avatar/dad32d44d4850d2bc9485ee115ab4227?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png",
42
- "gravatar_id": "dad32d44d4850d2bc9485ee115ab4227",
43
- "id": 864347,
44
- "login": "travis-repos",
45
- "url": "https://api.github.com/users/travis-repos"
46
- },
47
- "private": false,
48
- "pushed_at": "2012-04-11T15:50:22Z",
49
- "size": 140,
50
- "ssh_url": "git@github.com:travis-repos/test-project-1.git",
51
- "svn_url": "https://github.com/travis-repos/test-project-1",
52
- "updated_at": "2012-04-11T15:50:22Z",
53
- "url": "https://api.github.com/repos/travis-repos/test-project-1",
54
- "watchers": 8
55
- },
56
- "sha": "4a90c0ad9187c8735e1bcbf39a0291a21284994a",
57
- "user": {
58
- "avatar_url": "https://secure.gravatar.com/avatar/dad32d44d4850d2bc9485ee115ab4227?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png",
59
- "gravatar_id": "dad32d44d4850d2bc9485ee115ab4227",
60
- "id": 864347,
61
- "login": "travis-repos",
62
- "url": "https://api.github.com/users/travis-repos"
63
- }
64
- },
65
- "body": "please do not touch. we are using this pull request to generate fixtures for tests kthxbai",
66
- "changed_files": 2,
67
- "closed_at": null,
68
- "comments": 0,
69
- "commits": 3,
70
- "created_at": "2012-02-14T14:00:48Z",
71
- "deletions": 3,
72
- "diff_url": "https://github.com/travis-repos/test-project-1/pull/1.diff",
73
- "head": {
74
- "label": "rkh:master",
75
- "ref": "master",
76
- "repo": {
77
- "clone_url": "https://github.com/rkh/test-project-1.git",
78
- "created_at": "2012-02-13T15:17:57Z",
79
- "description": "Test dummy repository for testing Travis CI",
80
- "fork": true,
81
- "forks": 0,
82
- "git_url": "git://github.com/rkh/test-project-1.git",
83
- "has_downloads": true,
84
- "has_issues": false,
85
- "has_wiki": true,
86
- "homepage": "http://travis-ci.org",
87
- "html_url": "https://github.com/rkh/test-project-1",
88
- "id": 3431064,
89
- "language": "Ruby",
90
- "mirror_url": null,
91
- "name": "test-project-1",
92
- "open_issues": 0,
93
- "owner": {
94
- "avatar_url": "https://secure.gravatar.com/avatar/5c2b452f6eea4a6d84c105ebd971d2a4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
95
- "gravatar_id": "5c2b452f6eea4a6d84c105ebd971d2a4",
96
- "id": 30442,
97
- "login": "rkh",
98
- "url": "https://api.github.com/users/rkh"
99
- },
100
- "private": false,
101
- "pushed_at": "2012-04-13T11:02:59Z",
102
- "size": 116,
103
- "ssh_url": "git@github.com:rkh/test-project-1.git",
104
- "svn_url": "https://github.com/rkh/test-project-1",
105
- "updated_at": "2012-04-13T11:02:59Z",
106
- "url": "https://api.github.com/repos/rkh/test-project-1",
107
- "watchers": 1
108
- },
109
- "sha": "01eae10530ca65b51474b2d950365967ebdf3023",
110
- "user": {
111
- "avatar_url": "https://secure.gravatar.com/avatar/5c2b452f6eea4a6d84c105ebd971d2a4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
112
- "gravatar_id": "5c2b452f6eea4a6d84c105ebd971d2a4",
113
- "id": 30442,
114
- "login": "rkh",
115
- "url": "https://api.github.com/users/rkh"
116
- }
117
- },
118
- "html_url": "https://github.com/travis-repos/test-project-1/pull/1",
119
- "id": 826379,
120
- "issue_url": "https://github.com/travis-repos/test-project-1/issues/1",
121
- "mergeable": true,
122
- "mergeable_state": "clean",
123
- "merged": false,
124
- "merged_at": null,
125
- "merged_by": null,
126
- "number": 1,
127
- "patch_url": "https://github.com/travis-repos/test-project-1/pull/1.patch",
128
- "review_comments": 0,
129
- "state": "open",
130
- "title": "PLEASE DO NOT TOUCH THIS PULL REQUEST",
131
- "updated_at": "2012-04-13T13:35:24Z",
132
- "url": "https://api.github.com/repos/travis-repos/test-project-1/pulls/1",
133
- "user": {
134
- "avatar_url": "https://secure.gravatar.com/avatar/5c2b452f6eea4a6d84c105ebd971d2a4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
135
- "gravatar_id": "5c2b452f6eea4a6d84c105ebd971d2a4",
136
- "id": 30442,
137
- "login": "rkh",
138
- "url": "https://api.github.com/users/rkh"
139
- }
140
- },
141
- "repository": {
142
- "clone_url": "https://github.com/travis-repos/test-project-1.git",
143
- "created_at": "2011-04-14T18:23:41Z",
144
- "description": "Test dummy repository for testing Travis CI",
145
- "fork": false,
146
- "forks": 6,
147
- "git_url": "git://github.com/travis-repos/test-project-1.git",
148
- "has_downloads": true,
149
- "has_issues": false,
150
- "has_wiki": false,
151
- "homepage": "http://travis-ci.org",
152
- "html_url": "https://github.com/travis-repos/test-project-1",
153
- "id": 1615549,
154
- "language": "Ruby",
155
- "mirror_url": null,
156
- "name": "test-project-1",
157
- "open_issues": 3,
158
- "owner": {
159
- "avatar_url": "https://secure.gravatar.com/avatar/dad32d44d4850d2bc9485ee115ab4227?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-orgs.png",
160
- "gravatar_id": "dad32d44d4850d2bc9485ee115ab4227",
161
- "id": 864347,
162
- "login": "travis-repos",
163
- "url": "https://api.github.com/users/travis-repos"
164
- },
165
- "private": false,
166
- "pushed_at": "2012-04-11T15:50:22Z",
167
- "size": 140,
168
- "ssh_url": "git@github.com:travis-repos/test-project-1.git",
169
- "svn_url": "https://github.com/travis-repos/test-project-1",
170
- "updated_at": "2012-04-11T15:50:22Z",
171
- "url": "https://api.github.com/repos/travis-repos/test-project-1",
172
- "watchers": 8
173
- },
174
- "sender": {
175
- "avatar_url": "https://secure.gravatar.com/avatar/5c2b452f6eea4a6d84c105ebd971d2a4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png",
176
- "gravatar_id": "5c2b452f6eea4a6d84c105ebd971d2a4",
177
- "id": 30442,
178
- "login": "rkh",
179
- "url": "https://api.github.com/users/rkh"
180
- }
181
- }
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::Remote do
4
- it 'loads resources from github' do
5
- stub_request(:get, "https://api.github.com/foo").to_return(:body => '["foo"]')
6
- subject['foo'].to_s.should be == '["foo"]'
7
- end
8
-
9
- it 'sets headers correctly' do
10
- stub_request(:get, "https://api.github.com/foo").to_return(:headers => {'X-Foo' => 'bar'}, :body => '[]')
11
- subject['foo'].headers['x-foo'].should be == 'bar'
12
- end
13
-
14
- it 'raises an exception for missing resources' do
15
- stub_request(:get, "https://api.github.com/foo").to_return(:status => 404)
16
- expect { subject['foo'] }.to raise_error(GH::Error)
17
- end
18
-
19
- it 'includes the request payload in errors' do
20
- stub_request(:post, "https://api.github.com/foo").to_return(:status => 422)
21
- expect { subject.post('foo', :foo => "bar") }.to raise_error { |error| error.message.should =~ /\{\s*"foo":\s*"bar"\s*\}/ }
22
- end
23
-
24
- it 'parses the body' do
25
- stub_request(:get, "https://api.github.com/foo").to_return(:body => '{"foo":"bar"}')
26
- subject['foo']['foo'].should be == 'bar'
27
- end
28
-
29
- it 'sends http calls through the frontend' do
30
- wrapper = Class.new(GH::Wrapper).new
31
- wrapper.should_receive(:http).with(:get, "/foo", backend.headers).and_return GH::Response.new
32
- wrapper['foo']
33
- end
34
-
35
- it 'sends request calls through the frontend' do
36
- wrapper = Class.new(GH::Wrapper).new
37
- wrapper.should_receive(:request).with(:delete, "/foo").and_return GH::Response.new
38
- wrapper.delete '/foo'
39
- end
40
-
41
- describe :path_for do
42
- before { subject.setup("http://localhost/api/v3", {}) }
43
- example { subject.path_for("foo") .should be == "/api/v3/foo" }
44
- example { subject.path_for("/foo") .should be == "/api/v3/foo" }
45
- example { subject.path_for("/api/v3/foo") .should be == "/api/v3/foo" }
46
- example { subject.path_for("http://localhost/api/v3/foo") .should be == "/api/v3/foo" }
47
- end
48
- end
@@ -1,19 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe GH::Response do
5
- it 'parses content endpoints correctly' do
6
- GH['/repos/rkh/gh/contents/README.md']
7
- end
8
-
9
- it 'handles UTF-8 properly, even if encoded binary' do
10
- raw = '{"foo":"über cool sista året"}'
11
- raw.force_encoding 'binary' if raw.respond_to? :force_encoding
12
- response = GH::Response.new(raw)
13
- response['foo'].should be == 'über cool sista året'
14
- end
15
-
16
- # it 'handles broken encodings properly' do
17
- # GH::Response.new("{\"foo\":\"\xC3\"}")["foo"].should be == "\xC3"
18
- # end
19
- end
@@ -1,88 +0,0 @@
1
- require 'gh'
2
- require 'webmock/rspec'
3
- require 'yaml'
4
- require 'fileutils'
5
-
6
- RUBY_ENGINE = 'ruby' unless defined? RUBY_ENGINE
7
-
8
- module GH
9
- module TestHelpers
10
- def backend(layer = subject)
11
- return layer if layer.backend.nil? or layer.is_a? MockBackend
12
- backend layer.backend
13
- end
14
-
15
- def requests
16
- backend.requests
17
- end
18
-
19
- def data
20
- backend.data
21
- end
22
-
23
- def should_request(num = 1, &block)
24
- was = requests.count
25
- yield
26
- (requests.count - was).should be == num
27
- end
28
-
29
- def should_not_request(&block)
30
- should_request(0, &block)
31
- end
32
-
33
- end
34
-
35
- class MockBackend < Wrapper
36
- attr_accessor :data, :requests
37
-
38
- def setup(*)
39
- @data, @requests = {}, []
40
- super
41
- end
42
-
43
- def fetch_resource(key)
44
- key = path_for(key)
45
- key_fn = sanitize_filename(key)
46
- file = File.expand_path("../payloads/#{key_fn}.yml", __FILE__)
47
- @requests << key
48
- result = @data[key] ||= begin
49
- unless File.exist? file
50
- res = allow_http { super }
51
- FileUtils.mkdir_p File.dirname(file)
52
- File.write file, [res.headers, res.body].to_yaml
53
- end
54
-
55
- headers, body = YAML.load_file(file)
56
- Response.new(body, headers, frontend.full_url(key))
57
- end
58
-
59
- result = Response.new(result) unless result.is_a? Response
60
- result
61
- end
62
-
63
- def sanitize_filename(name)
64
- name.gsub(/[\?=&]/,"_")
65
- end
66
-
67
- def reset
68
- super
69
- @data.clear
70
- @requests.clear
71
- end
72
-
73
- private
74
-
75
- def allow_http
76
- WebMock.allow_net_connect!
77
- yield
78
- ensure
79
- WebMock.disable_net_connect!
80
- end
81
- end
82
- end
83
-
84
- RSpec.configure do |c|
85
- c.include GH::TestHelpers
86
- c.before { GH::DefaultStack.replace GH::Remote, GH::MockBackend }
87
- c.after { GH.reset }
88
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::Stack do
4
- it 'is specified'
5
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::TokenCheck do
4
- before do
5
- subject.client_id = 'foo'
6
- subject.client_secret = 'bar'
7
- subject.token = 'baz'
8
- end
9
-
10
- it 'adds client_id and client_secret to a request' do
11
- subject.backend.should_receive(:http).with(:head, "/applications/foo/tokens/baz?client_id=foo&client_secret=bar", "Authorization" => "Basic Zm9vOmJhcg==") do
12
- error = GH::Error.new
13
- error.info[:response_status] = 404
14
- raise error
15
- end
16
- expect { subject['/x'] }.to raise_error(GH::TokenInvalid)
17
- end
18
-
19
- it 'does not swallow other status codes' do
20
- subject.backend.should_receive(:http).with(:head, "/applications/foo/tokens/baz?client_id=foo&client_secret=bar", "Authorization" => "Basic Zm9vOmJhcg==") do
21
- error = GH::Error.new
22
- error.info[:response_status] = 500
23
- raise error
24
- end
25
- expect { subject['/x'] }.not_to raise_error(GH::TokenInvalid)
26
- end
27
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::Wrapper do
4
- it 'is specified'
5
- end