gh 0.13.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c7ceba15f857e76771348766e427455e1a0afef
4
- data.tar.gz: a84dc5b1a868f94fffd2b292a694113c9ff6498d
3
+ metadata.gz: dabc2d2ed05fc0c8dcb21a473ddf644950b5d78a
4
+ data.tar.gz: 7670fe47a26f12b8505510c85298e19393c58f1a
5
5
  SHA512:
6
- metadata.gz: b25d4048d51481be7db6c9d90bd99b3300aaf2bff0ca0fa40170791ff61e8ad81ffbb35fe951a5be066612e93245e81818e914871253077d510fc4833667b1a8
7
- data.tar.gz: 746d6c5fbc296383d5638b825333f426b83da70851e7ee0c458c27edfbd6f2eee885dda57288d2037a756d2cb7c0564f8a19a8eefe75e3f4f9da2b2943b23394
6
+ metadata.gz: ff85094deaf0eec9dc13dcb76bd87a0b9df6b23fc3be9c994e45be32c2d72d6c3b39aa395a4d21646d022fd9ba505361dc7425a34d6831fd46e831160bd8b0f0
7
+ data.tar.gz: 93760643a49d175139ad8875a1d76c0bed0d46f1cf74b03a2bb5e1116b1bf289f7c4a626e68076e5cb03cf9a831bf61de4024e1103c8384573cde8167bf5ae23
@@ -45,8 +45,8 @@ module GH
45
45
  def entry(key, value)
46
46
  value = "#{value.class}: #{value.message}" if Exception === value
47
47
  value = value.inspect unless String === value
48
- value = value.gsub(/[^\n]{80}/, "\\0\n").lines.map { |l| "\n #{l}" }.join.gsub(/\n+/, "\n")
49
- (key.to_s + ": ").ljust(12) + value
48
+ value.gsub!(/"Basic .+"|(client_(?:id|secret)=)[^&\s]+/, '\1[removed]')
49
+ (key.to_s + ": ").ljust(20) + value
50
50
  end
51
51
  end
52
52
 
@@ -26,7 +26,7 @@ module GH
26
26
  when respond_to(:to_str) then @body = body.to_str
27
27
  when respond_to(:to_hash) then @data = body.to_hash
28
28
  when respond_to(:to_ary) then @data = body.to_ary
29
- when nil then @data = {}
29
+ when nil, '' then @data = {}
30
30
  else raise ArgumentError, "cannot parse #{body.inspect}"
31
31
  end
32
32
 
@@ -1,4 +1,4 @@
1
1
  module GH
2
2
  # Public: Library version.
3
- VERSION = "0.13.0"
3
+ VERSION = "0.13.1"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-07 00:00:00.000000000 Z
11
+ date: 2014-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -129,13 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
- - .gitignore
133
- - .travis.yml
134
- - Gemfile
135
132
  - LICENSE
136
- - README.md
137
- - Rakefile
138
- - gh.gemspec
139
133
  - lib/gh.rb
140
134
  - lib/gh/cache.rb
141
135
  - lib/gh/case.rb
@@ -157,49 +151,9 @@ files:
157
151
  - lib/gh/token_check.rb
158
152
  - lib/gh/version.rb
159
153
  - lib/gh/wrapper.rb
160
- - spec/cache_spec.rb
161
- - spec/custom_limit_spec.rb
162
- - spec/error_spec.rb
163
- - spec/gh_spec.rb
164
- - spec/instrumentation_spec.rb
165
- - spec/lazy_loader_spec.rb
166
- - spec/link_follower_spec.rb
167
- - spec/merge_commit_spec.rb
168
- - spec/normalizer_spec.rb
169
- - spec/pagination_spec.rb
170
- - spec/parallel_spec.rb
171
- - spec/payloads/.yml
172
- - spec/payloads/repos/rkh/gh/contents/README.md_per_page_100.yml
173
- - spec/payloads/repos/rkh/test-project-1.yml
174
- - spec/payloads/repos/sinatra/sinatra/issues/56/comments.yml
175
- - spec/payloads/repos/sinatra/sinatra/issues/comments/383214.yml
176
- - spec/payloads/repos/sinatra/sinatra/pulls/56.yml
177
- - spec/payloads/repos/travis-repos/test-project-1.yml
178
- - spec/payloads/repos/travis-repos/test-project-1/git/commits/ca3c0a44ec1d9bf8557d2653aa1b79fcc9ff5f5d.yml
179
- - spec/payloads/repos/travis-repos/test-project-1/git/refs/pull/1.yml
180
- - spec/payloads/repos/travis-repos/test-project-1/pulls/1.yml
181
- - spec/payloads/users/rkh.yml
182
- - spec/payloads/users/rkh/repos.yml
183
- - spec/payloads/users/rkh/repos_page_2&per_page=100.yml
184
- - spec/payloads/users/rkh/repos_page_2.yml
185
- - spec/payloads/users/rkh/repos_page_2_per_page_100.yml
186
- - spec/payloads/users/rkh/repos_page_3.yml
187
- - spec/payloads/users/rkh/repos_page_4.yml
188
- - spec/payloads/users/rkh/repos_page_5.yml
189
- - spec/payloads/users/rkh/repos_per_page_100.yml
190
- - spec/payloads/users/rkh_per_page_100.yml
191
- - spec/payloads/users/rtomayko.yml
192
- - spec/payloads/users/svenfuchs.yml
193
- - spec/payloads/users/travis-repos.yml
194
- - spec/pull_request_hook.json
195
- - spec/remote_spec.rb
196
- - spec/response_spec.rb
197
- - spec/spec_helper.rb
198
- - spec/stack_spec.rb
199
- - spec/token_check_spec.rb
200
- - spec/wrapper_spec.rb
201
154
  homepage: http://gh.rkh.im/
202
- licenses: []
155
+ licenses:
156
+ - MIT
203
157
  metadata: {}
204
158
  post_install_message:
205
159
  rdoc_options: []
@@ -217,50 +171,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
171
  version: '0'
218
172
  requirements: []
219
173
  rubyforge_project:
220
- rubygems_version: 2.0.7
174
+ rubygems_version: 2.2.0
221
175
  signing_key:
222
176
  specification_version: 4
223
177
  summary: layered github client
224
- test_files:
225
- - spec/cache_spec.rb
226
- - spec/custom_limit_spec.rb
227
- - spec/error_spec.rb
228
- - spec/gh_spec.rb
229
- - spec/instrumentation_spec.rb
230
- - spec/lazy_loader_spec.rb
231
- - spec/link_follower_spec.rb
232
- - spec/merge_commit_spec.rb
233
- - spec/normalizer_spec.rb
234
- - spec/pagination_spec.rb
235
- - spec/parallel_spec.rb
236
- - spec/payloads/.yml
237
- - spec/payloads/repos/rkh/gh/contents/README.md_per_page_100.yml
238
- - spec/payloads/repos/rkh/test-project-1.yml
239
- - spec/payloads/repos/sinatra/sinatra/issues/56/comments.yml
240
- - spec/payloads/repos/sinatra/sinatra/issues/comments/383214.yml
241
- - spec/payloads/repos/sinatra/sinatra/pulls/56.yml
242
- - spec/payloads/repos/travis-repos/test-project-1.yml
243
- - spec/payloads/repos/travis-repos/test-project-1/git/commits/ca3c0a44ec1d9bf8557d2653aa1b79fcc9ff5f5d.yml
244
- - spec/payloads/repos/travis-repos/test-project-1/git/refs/pull/1.yml
245
- - spec/payloads/repos/travis-repos/test-project-1/pulls/1.yml
246
- - spec/payloads/users/rkh.yml
247
- - spec/payloads/users/rkh/repos.yml
248
- - spec/payloads/users/rkh/repos_page_2&per_page=100.yml
249
- - spec/payloads/users/rkh/repos_page_2.yml
250
- - spec/payloads/users/rkh/repos_page_2_per_page_100.yml
251
- - spec/payloads/users/rkh/repos_page_3.yml
252
- - spec/payloads/users/rkh/repos_page_4.yml
253
- - spec/payloads/users/rkh/repos_page_5.yml
254
- - spec/payloads/users/rkh/repos_per_page_100.yml
255
- - spec/payloads/users/rkh_per_page_100.yml
256
- - spec/payloads/users/rtomayko.yml
257
- - spec/payloads/users/svenfuchs.yml
258
- - spec/payloads/users/travis-repos.yml
259
- - spec/pull_request_hook.json
260
- - spec/remote_spec.rb
261
- - spec/response_spec.rb
262
- - spec/spec_helper.rb
263
- - spec/stack_spec.rb
264
- - spec/token_check_spec.rb
265
- - spec/wrapper_spec.rb
266
- has_rdoc:
178
+ test_files: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- pkg/*
4
- Gemfile.lock
@@ -1,19 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- - 1.9.3
6
- - 2.0.0
7
- - jruby-18mode
8
- - jruby-19mode
9
- - rbx-18mode
10
- - rbx-19mode
11
- - jruby-head
12
- - ree
13
- matrix:
14
- allow_failures:
15
- - rvm: jruby-18mode
16
- - rvm: jruby-19mode
17
- - rvm: jruby-head
18
- - rvm: rbx-18mode
19
- - rvm: rbx-19mode
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gh.gemspec
4
- gemspec
5
- gem 'rake'
6
- platform(:jruby) { gem 'jruby-openssl' }
data/README.md DELETED
@@ -1,117 +0,0 @@
1
- # GH - Layered GitHub API client
2
- [![Build Status](https://travis-ci.org/travis-ci/travis.png?branch=master)](https://travis-ci.org/travis-ci/travis)
3
-
4
- This is a highly flexible, layered, low-level GitHub client library, trying to get out of your way and let you get to the GitHub data as simple as possible. Unless you add layers, you will end up with Hashes and Arrays. The approach and API should be familiar from projects like Rack or Faraday.
5
-
6
- Simple example:
7
-
8
- ``` ruby
9
- require 'gh'
10
- puts GH['users/rkh']['name']
11
- ```
12
-
13
- This will by default use all the middleware that ships with GH, in the following order:
14
-
15
- * `GH::Remote` - sends HTTP requests to GitHub and parses the response
16
- * `GH::Normalizer` - renames fields consistenly, adds hypermedia links if possible
17
- * `GH::LazyLoader` - will load missing fields when accessed (handy for dealing with incomplete data without sending to many requests)
18
- * `GH::MergeCommit` - adds infos about merge commits to pull request payloads
19
- * `GH::LinkFollower` - will add content of hypermedia links as fields (lazyly), allows you to traverse relations
20
- * `GH::Pagination` - adds support for transparent pagination
21
- * `GH::Instrumentation` - let's you instrument `gh`
22
-
23
- The following middleware is not included by default:
24
-
25
- * `GH::Cache` - caches the responses (will use Rails cache if in Rails, in-memory cache otherwise)
26
-
27
- ## Main Entry Points
28
-
29
- Every layer has two main entry points:
30
-
31
- * `[key]` - loads data from GitHub
32
- * `load(data)` - takes data and applies modifications (handy for dealing with service hook payloads)
33
-
34
- These two methods are exposed by any instance of a layer and the `GH` constant.
35
-
36
- ## Using a Single Layer
37
-
38
- You can initialize and use any layer on its own:
39
-
40
- ``` ruby
41
- gh = GH::Remote.new
42
- puts gh['users/rkh']['name']
43
- ```
44
-
45
- Layers know which other layer they should usually wrap (`Remote` wraps no other layer, `LazyLoader` and `LinkFollower` wrap `Normalizer` by default, anything else wraps `Remote`), so you can initialize them right away:
46
-
47
- ``` ruby
48
- gh = GH::LazyLoader.new
49
- ```
50
-
51
- You can also pass the layer that should be wrapped as an argument:
52
-
53
- ``` ruby
54
- gh = GH::LazyLoader.new(GH::LinkFollower.new)
55
- ```
56
-
57
- ## Creating Your Own Stack
58
-
59
- For convinience a stack DSL is provided:
60
-
61
- ``` ruby
62
- # Same as GH::Normalizer.new(GH::Cache.new)
63
- gh = GH::Stack.build do
64
- use GH::Normalizer
65
- use GH::Cache
66
- end
67
-
68
- puts gh['users/rkh']['name']
69
- ```
70
-
71
- You can also create reusable `Stack` instances:
72
-
73
- ``` ruby
74
- stack = GH::Stack.new do
75
- use GH::Normalizer
76
- use GH::Cache
77
- end
78
-
79
- gh = stack.build username: 'rkh', password: 'abc123'
80
- puts gh['user']['name']
81
- ```
82
-
83
- One such instance (with the standard setup) can be accessed as `GH::DefaultStack`
84
-
85
- ## Scoping
86
-
87
- With the main goal to separate authentication from other logic, the `gh` library supports scopting:
88
-
89
- ``` ruby
90
- GH.with GH::LazyLoader.new do
91
- puts GH['users/rkh']['name']
92
- end
93
- ```
94
-
95
- That way, you could create a stack with, for instance, an [access token](http://developer.github.com/v3/oauth/):
96
-
97
- ``` ruby
98
- authenticated = GH::DefaultStack.build token: 'e72e16c7e42f292c6912e7710c838347ae178b4a'
99
-
100
- GH.with(authenticated) do
101
- # ...
102
- end
103
- ```
104
-
105
- Since this is rather common, you can pass options directly to `with`:
106
-
107
- ``` ruby
108
- GH.with(username: 'rkh', password: 'abc123') do
109
- # ...
110
- end
111
- ```
112
-
113
- Scoping is thread-safe.
114
-
115
- ## Is this production ready?
116
-
117
- I hope so, we use it in production for [Travis CI](http://travis-ci.org/). The work on this library has been funded by the [Travis Love Campaign](https://love.travis-ci.org/).
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
-
4
- RSpec::Core::RakeTask.new :default do |t|
5
- t.rspec_opts = ["-bcfd"]
6
- end
data/gh.gemspec DELETED
@@ -1,28 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "gh/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "gh"
7
- s.version = GH::VERSION
8
- s.authors = ["Konstantin Haase"]
9
- s.email = ["konstantin.mailinglists@googlemail.com"]
10
- s.homepage = "http://gh.rkh.im/"
11
- s.summary = %q{layered github client}
12
- s.description = %q{multi-layer client for the github api v3}
13
-
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
18
-
19
- s.add_development_dependency 'rspec'
20
- s.add_development_dependency 'webmock'
21
-
22
- s.add_runtime_dependency 'faraday', '~> 0.8'
23
- s.add_runtime_dependency 'backports'
24
- s.add_runtime_dependency 'multi_json', '~> 1.0'
25
- s.add_runtime_dependency 'addressable'
26
- s.add_runtime_dependency 'net-http-persistent', '>= 2.7'
27
- s.add_runtime_dependency 'net-http-pipeline'
28
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::Cache do
4
- before { subject.backend = GH::MockBackend.new }
5
-
6
- it 'send HTTP requests for uncached resources' do
7
- subject['users/rkh']['name'].should be == "Konstantin Haase"
8
- requests.count.should be == 1
9
- end
10
-
11
- it 'uses the cache for subsequent requests' do
12
- subject['users/rkh']['name'].should be == "Konstantin Haase"
13
- subject['users/svenfuchs']['name'].should be == "Sven Fuchs"
14
- subject['users/rkh']['name'].should be == "Konstantin Haase"
15
- requests.count.should be == 2
16
- end
17
-
18
- it 'cache is resettable' do
19
- subject['users/rkh']['name'].should be == "Konstantin Haase"
20
- subject['users/rkh']['name'].should be == "Konstantin Haase"
21
- requests.count.should be == 1
22
-
23
- subject.reset
24
- requests.count.should be == 0
25
- subject['users/rkh']['name'].should be == "Konstantin Haase"
26
- requests.count.should be == 1
27
- end
28
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::CustomLimit do
4
- before do
5
- subject.client_id = 'foo'
6
- subject.client_secret = 'bar'
7
- end
8
-
9
- it 'adds client_id and client_secret to a request' do
10
- headers = {
11
- "User-Agent" => "GH/#{GH::VERSION}",
12
- "Accept" => "application/vnd.github.v3+json,application/vnd.github.beta+json;q=0.5,application/json;q=0.1",
13
- "Accept-Charset" => "utf-8"
14
- }
15
-
16
- subject.
17
- should_receive(:http).
18
- with(:get, '/x?client_id=foo&client_secret=bar', headers).
19
- and_return(GH::Response.new)
20
-
21
- subject['/x']
22
- end
23
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe GH::Error do
4
- class SomeWrapper < GH::Wrapper
5
- double_dispatch
6
- def modify_hash(*)
7
- raise "foo"
8
- end
9
- end
10
-
11
- let(:exception) do
12
- begin
13
- SomeWrapper.new.load('foo' => 'bar')
14
- nil
15
- rescue Exception => error
16
- error
17
- end
18
- end
19
-
20
- it "wraps connection" do
21
- exception.should be_an(GH::Error)
22
- end
23
-
24
- it "exposes the original exception" do
25
- exception.error.should be_a(StandardError)
26
- end
27
-
28
- it 'keeps the payload around' do
29
- exception.payload.should be == {'foo' => 'bar'}
30
- end
31
-
32
- it 'works for long content' do
33
- error = GH::Error.new(nil, nil, 'foo' => 'a'*1000)
34
- expect { error.message }.not_to raise_error
35
- end
36
-
37
- it 'can be rescued by status code' do
38
- stub_request(:get, "https://api.github.com/missing").to_return(:status => 404)
39
-
40
- expect do
41
- begin
42
- GH['missing']
43
- rescue GH::Error(:response_status => 404)
44
- end
45
- end.not_to raise_error
46
-
47
-
48
- expect do
49
- begin
50
- GH['missing']
51
- rescue GH::Error(:response_status => 500)
52
- end
53
- end.to raise_error(GH::Error)
54
- end
55
- end