ghee 0.13.18 → 0.13.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/Rakefile +11 -0
- data/ghee.gemspec +1 -0
- data/lib/ghee.rb +2 -0
- data/lib/ghee/api/commit_comments.rb +34 -0
- data/lib/ghee/api/commit_statuses.rb +35 -0
- data/lib/ghee/api/commits.rb +5 -36
- data/lib/ghee/resource_proxy.rb +5 -2
- data/lib/ghee/version.rb +1 -1
- data/spec/ghee/api/commits_spec.rb +87 -0
- data/spec/ghee/api/gists_spec.rb +6 -1
- data/spec/ghee/api/users_spec.rb +4 -10
- data/spec/ghee/memory_cache_spec.rb +1 -1
- data/spec/settings.yml.sample +4 -4
- data/spec/spec_helper.rb +2 -2
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d2b5546ab688edb5fe7e4fa5bebb079366e45e7
|
4
|
+
data.tar.gz: 6b38d8e4cf6d37e26c65ec9a4233e885c1776cd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47b84b662152d68b76dde9f920fa51a5e1ecc7a449b179159af8e6a0f7d7eb812b61a2c2bc791f20ec4b082fbd50ed83d50ccb9692dc3a0d5b46636f56718e3d
|
7
|
+
data.tar.gz: 423b4281d1235820c6a46c8c1443b87b566519e7cf927f6ca016a16c53c6c243751c4e2b8481aa696849056d171589273d5bc59bdc96d74cd0d63558949c8036
|
data/README.md
CHANGED
@@ -798,10 +798,20 @@ In order for VCR to make and cache the actual calls to the Github API you will n
|
|
798
798
|
|
799
799
|
This file is ignored by git (see .gitignore) so you can commit any changes you make to the gem without having to worry about your user/token/pass/org being released into the wild.
|
800
800
|
|
801
|
+
Before you run the api test suite:
|
802
|
+
|
803
|
+
Fork [Ghee-Test](https://github.com/rauhryan/ghee_test)
|
804
|
+
Set the settings.yml repo key to ghee_test
|
805
|
+
On ghee_test:
|
806
|
+
- Enable issue tracking on (your username)/ghee
|
807
|
+
- Create a Public Gist and Star it
|
808
|
+
- Create an issue with the title "Seeded"
|
809
|
+
- Create a comment on a commit line
|
810
|
+
|
801
811
|
Now run the test suite:
|
802
812
|
|
803
813
|
bundle
|
804
|
-
bundle exec rake
|
814
|
+
bundle exec rake api
|
805
815
|
|
806
816
|
CONTRIBUTE
|
807
817
|
----------
|
data/Rakefile
CHANGED
@@ -9,7 +9,18 @@ end
|
|
9
9
|
task :default => :spec
|
10
10
|
task :test => :spec
|
11
11
|
|
12
|
+
desc "Run the api specs"
|
13
|
+
RSpec::Core::RakeTask.new do |t|
|
14
|
+
t.name = :api
|
15
|
+
t.pattern = "spec/ghee/api/*_spec.rb"
|
16
|
+
end
|
17
|
+
|
12
18
|
desc "Open an irb session with library"
|
13
19
|
task :console do
|
14
20
|
sh "irb -I lib -r ghee"
|
15
21
|
end
|
22
|
+
|
23
|
+
desc "clean out VCR responses"
|
24
|
+
task :clean do
|
25
|
+
sh "rm -rf spec/responses"
|
26
|
+
end
|
data/ghee.gemspec
CHANGED
data/lib/ghee.rb
CHANGED
@@ -19,6 +19,8 @@ require 'ghee/api/hooks'
|
|
19
19
|
require 'ghee/api/collaborators'
|
20
20
|
require 'ghee/api/forks'
|
21
21
|
require 'ghee/api/commits'
|
22
|
+
require 'ghee/api/commit_comments'
|
23
|
+
require 'ghee/api/commit_statuses'
|
22
24
|
require 'ghee/api/keys'
|
23
25
|
require 'ghee/api/watchers'
|
24
26
|
require 'ghee/api/emails'
|
@@ -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
|
+
class Proxy < ::Ghee::ResourceProxy
|
13
|
+
|
14
|
+
def comments(id=nil, &block)
|
15
|
+
prefix = build_prefix id, "comments"
|
16
|
+
Ghee::API::Repos::Commits::Comments::Proxy.new connection, prefix, id, &block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
module Commits
|
20
|
+
class Proxy < ::Ghee::ResourceProxy
|
21
|
+
def comments(id=nil, &block)
|
22
|
+
prefix = build_prefix id, "comments"
|
23
|
+
Ghee::API::Repos::Commits::Comments::Proxy.new connection, prefix, id, &block
|
24
|
+
end
|
25
|
+
end
|
26
|
+
module Comments
|
27
|
+
class Proxy < ::Ghee::ResourceProxy
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,35 @@
|
|
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
|
+
module Commits
|
13
|
+
class Proxy < ::Ghee::ResourceProxy
|
14
|
+
undef_method "patch"
|
15
|
+
undef_method "destroy"
|
16
|
+
undef_method "create"
|
17
|
+
|
18
|
+
def statuses(id=nil, &block)
|
19
|
+
prefix = build_prefix id, "statuses"
|
20
|
+
Ghee::API::Repos::Commits::Statuses::Proxy.new connection, prefix, id, &block
|
21
|
+
end
|
22
|
+
def status(&block)
|
23
|
+
prefix = build_prefix nil, "status"
|
24
|
+
Ghee::API::Repos::Commits::Statuses::Proxy.new connection, prefix, id, &block
|
25
|
+
end
|
26
|
+
end
|
27
|
+
module Statuses
|
28
|
+
class Proxy < ::Ghee::ResourceProxy
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/lib/ghee/api/commits.rb
CHANGED
@@ -10,38 +10,6 @@ class Ghee
|
|
10
10
|
#
|
11
11
|
module Repos
|
12
12
|
|
13
|
-
module Commits
|
14
|
-
class Proxy < ::Ghee::ResourceProxy
|
15
|
-
|
16
|
-
def comments
|
17
|
-
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
13
|
# Repos::Proxy inherits from Ghee::Proxy and
|
46
14
|
# enables defining methods on the proxy object
|
47
15
|
#
|
@@ -51,11 +19,12 @@ class Ghee
|
|
51
19
|
end
|
52
20
|
def commits(sha=nil, &block)
|
53
21
|
prefix = build_prefix sha, "commits"
|
54
|
-
Commits::Proxy.new(connection, prefix, sha, &block)
|
22
|
+
Ghee::API::Repos::Commits::Proxy.new(connection, prefix, sha, &block)
|
55
23
|
end
|
56
|
-
|
57
|
-
|
58
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
module Commits
|
27
|
+
class Proxy < ::Ghee::ResourceProxy
|
59
28
|
end
|
60
29
|
end
|
61
30
|
end
|
data/lib/ghee/resource_proxy.rb
CHANGED
@@ -13,7 +13,7 @@ class Ghee
|
|
13
13
|
include Ghee::CUD
|
14
14
|
|
15
15
|
# Make connection and path_prefix readable
|
16
|
-
attr_reader :connection, :path_prefix, :params
|
16
|
+
attr_reader :connection, :path_prefix, :params, :id
|
17
17
|
|
18
18
|
# Expose pagination data
|
19
19
|
attr_reader :current_page, :total, :pagination
|
@@ -31,7 +31,10 @@ class Ghee
|
|
31
31
|
# path_prefix - String
|
32
32
|
#
|
33
33
|
def initialize(connection, path_prefix, params = {}, &block)
|
34
|
-
|
34
|
+
if !params.is_a?Hash
|
35
|
+
@id = params
|
36
|
+
params = {}
|
37
|
+
end
|
35
38
|
@connection, @path_prefix, @params = connection, URI.escape(path_prefix), params
|
36
39
|
@block = block if block
|
37
40
|
subject if block
|
data/lib/ghee/version.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
describe Ghee::API::Repos::Commits do
|
5
|
+
subject { Ghee.new(GH_AUTH) }
|
6
|
+
|
7
|
+
def should_be_a_commit(commit)
|
8
|
+
commit.has_key?('sha').should == true
|
9
|
+
commit.has_key?('commit').should == true
|
10
|
+
end
|
11
|
+
|
12
|
+
def should_be_a_commit_comment(comment)
|
13
|
+
comment.has_key?('body').should == true
|
14
|
+
comment.has_key?('body_text').should == true
|
15
|
+
comment.has_key?('body_html').should == true
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
describe 'repo(user,repo)#commits' do
|
20
|
+
it 'return a list of commits' do
|
21
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})commits") do
|
22
|
+
commits = subject.repos(GH_USER, GH_REPO).commits
|
23
|
+
should_be_a_commit(commits.first)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context '#commits#status' do
|
28
|
+
before :all do
|
29
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})commits") do
|
30
|
+
commits = subject.repos(GH_USER, GH_REPO).commits
|
31
|
+
@commit = commits.first
|
32
|
+
end
|
33
|
+
end
|
34
|
+
let(:commit){ @commit }
|
35
|
+
|
36
|
+
it 'adds a status to the commit' do
|
37
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})statuses") do
|
38
|
+
sha = commit['sha']
|
39
|
+
state = {state: "pending"}
|
40
|
+
status = subject.repos(GH_USER, GH_REPO).commits(sha).statuses.create state
|
41
|
+
|
42
|
+
status['state'].should == 'pending'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'gets a list of statuses' do
|
47
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})commits(sha)statuses") do
|
48
|
+
sha = commit['sha']
|
49
|
+
statuses = subject.repos(GH_USER, GH_REPO).commits(sha).statuses
|
50
|
+
|
51
|
+
statuses.length.should > 0
|
52
|
+
statuses.first['state'].should == 'pending'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'gets combined statuses' do
|
57
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})commits(sha)status") do
|
58
|
+
sha = commit['sha']
|
59
|
+
status = subject.repos(GH_USER, GH_REPO).commits(sha).status
|
60
|
+
|
61
|
+
status['state'].should == 'pending'
|
62
|
+
status.has_key?('total_count').should == true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'repo(user,repo)#comments' do
|
69
|
+
before :all do
|
70
|
+
VCR.use_cassette "repos(#{GH_USER},#{GH_REPO})comments.seed" do
|
71
|
+
comments = subject.repos(GH_USER, GH_REPO).comments
|
72
|
+
if comments.empty?
|
73
|
+
sha = subject.repos(GH_USER, GH_REPO).commits.first['sha']
|
74
|
+
subject.repos(GH_USER, GH_REPO).commits(sha).comments.create({
|
75
|
+
body: "SEED a commit just in case"
|
76
|
+
})
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
it 'return a list of commit comments' do
|
81
|
+
VCR.use_cassette("repos(#{GH_USER},#{GH_REPO})comments") do
|
82
|
+
comments = subject.repos(GH_USER, GH_REPO).comments
|
83
|
+
should_be_a_commit_comment(comments.first)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/spec/ghee/api/gists_spec.rb
CHANGED
@@ -37,7 +37,12 @@ describe Ghee::API::Gists do
|
|
37
37
|
VCR.use_cassette('gists.public') do
|
38
38
|
gists = subject.gists.public
|
39
39
|
gists.size.should > 0
|
40
|
-
|
40
|
+
gist = gists.first
|
41
|
+
|
42
|
+
gist['url'].should include('https://api.github.com/gists/')
|
43
|
+
gist['created_at'].should_not be_nil
|
44
|
+
gist['files'].should be_instance_of(Hash)
|
45
|
+
gist['files'].size.should > 0
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
data/spec/ghee/api/users_spec.rb
CHANGED
@@ -25,25 +25,19 @@ describe Ghee::API::Users do
|
|
25
25
|
VCR.use_cassette('user') do
|
26
26
|
user = subject.user
|
27
27
|
user['type'].should == 'User'
|
28
|
-
user['email'].should_not be_nil
|
29
28
|
user['created_at'].should_not be_nil
|
30
29
|
user['html_url'].should include('https://github.com/')
|
31
|
-
user['name'].should be_instance_of(String)
|
32
30
|
user['login'].size.should > 0
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
|
-
# not sure how to write this test so that it doesn't mess
|
37
|
-
# up users info, so I'm just going to take the bio and add
|
38
|
-
# a space to the end of it
|
39
34
|
describe "#patch" do
|
40
35
|
it "should patch the user" do
|
41
36
|
VCR.use_cassette('user.patch') do
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
after_user['bio'].should == "#{before_user['bio']} "
|
37
|
+
user = subject.user
|
38
|
+
user.has_key?("name").should == true
|
39
|
+
user.has_key?("email").should == true
|
40
|
+
user.has_key?("company").should == true
|
47
41
|
end
|
48
42
|
end
|
49
43
|
end
|
data/spec/settings.yml.sample
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
access_token: your_access_token
|
2
|
-
username:
|
3
|
-
password:
|
4
|
-
repo: test_repo_that_you_setup
|
5
|
-
org:
|
2
|
+
username: github_username
|
3
|
+
password: github_pass (optional)
|
4
|
+
repo: test_repo_that_you_setup (recommend forking rauhryan/ghee)
|
5
|
+
org: any_organization_you_belong_to
|
data/spec/spec_helper.rb
CHANGED
@@ -6,9 +6,9 @@ require 'vcr'
|
|
6
6
|
require 'ghee'
|
7
7
|
require 'uuidtools'
|
8
8
|
|
9
|
-
VCR.
|
9
|
+
VCR.configure do |c|
|
10
10
|
c.cassette_library_dir = File.expand_path('../responses', __FILE__)
|
11
|
-
c.
|
11
|
+
c.hook_into :webmock
|
12
12
|
c.default_cassette_options = {:record => :once}
|
13
13
|
c.allow_http_connections_when_no_cassette = true
|
14
14
|
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.13.
|
4
|
+
version: 0.13.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Rauh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -207,6 +207,20 @@ dependencies:
|
|
207
207
|
- - ">="
|
208
208
|
- !ruby/object:Gem::Version
|
209
209
|
version: '0'
|
210
|
+
- !ruby/object:Gem::Dependency
|
211
|
+
name: pry-byebug
|
212
|
+
requirement: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
type: :development
|
218
|
+
prerelease: false
|
219
|
+
version_requirements: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
210
224
|
description: A complete, simple, and intuitive ruby API for all things Github.
|
211
225
|
email:
|
212
226
|
- rauh.ryan@gmail.com
|
@@ -228,6 +242,8 @@ files:
|
|
228
242
|
- lib/ghee.rb
|
229
243
|
- lib/ghee/api/authorizations.rb
|
230
244
|
- lib/ghee/api/collaborators.rb
|
245
|
+
- lib/ghee/api/commit_comments.rb
|
246
|
+
- lib/ghee/api/commit_statuses.rb
|
231
247
|
- lib/ghee/api/commits.rb
|
232
248
|
- lib/ghee/api/contents.rb
|
233
249
|
- lib/ghee/api/downloads.rb
|
@@ -256,6 +272,7 @@ files:
|
|
256
272
|
- lib/ghee/version.rb
|
257
273
|
- spec/ghee/api/authorizations_spec.rb
|
258
274
|
- spec/ghee/api/collaborators_spec.rb
|
275
|
+
- spec/ghee/api/commits_spec.rb
|
259
276
|
- spec/ghee/api/contents_spec.rb
|
260
277
|
- spec/ghee/api/downloads_spec.rb.ignore
|
261
278
|
- spec/ghee/api/events_spec.rb
|
@@ -303,6 +320,7 @@ summary: Access Github in ruby.
|
|
303
320
|
test_files:
|
304
321
|
- spec/ghee/api/authorizations_spec.rb
|
305
322
|
- spec/ghee/api/collaborators_spec.rb
|
323
|
+
- spec/ghee/api/commits_spec.rb
|
306
324
|
- spec/ghee/api/contents_spec.rb
|
307
325
|
- spec/ghee/api/downloads_spec.rb.ignore
|
308
326
|
- spec/ghee/api/events_spec.rb
|