ghee 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,4 +4,5 @@ spec/.access_token
4
4
  spec/responses/
5
5
  spec/settings.yml
6
6
  pkg/
7
+ .rspec
7
8
 
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+
2
+ env:
3
+ - GH_USER=gheeci GH_REPO=ghee_test GH_ORG=ghee-org TOKEN=a4cbd4976070d1cac1cbdc01de3e105116a70e83
4
+
5
+ language: ruby
6
+
7
+ notifications:
8
+ email:
9
+ - rauh.ryan@gmail.com
10
+
11
+ rvm:
12
+ - 1.8.7
13
+ - 1.9.3
14
+
15
+ script: bundle exec rake spec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) Jonathan Hoyt
3
+ Copyright (c) Jonathan Hoyt, Ryan Rauh
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,6 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.
22
+
23
+
data/README.md CHANGED
@@ -3,8 +3,7 @@ Ghee
3
3
 
4
4
  This is an unofficial ruby client for the [GitHub API](http://developer.github.com/v3/). The end goal is a complete, simple, and intuitive ruby API for all things Github.
5
5
 
6
- Usage
7
- -----
6
+ # Usage
8
7
 
9
8
  Instantiate the client with basic auth:
10
9
 
@@ -19,7 +18,7 @@ Create an OAuth access token:
19
18
  user_name, password, scopes = "rauhryan", "secret", "repos, user"
20
19
  token = Ghee.create_token(user_name, password, scopes)
21
20
 
22
- ### Gists
21
+ ## Gists
23
22
 
24
23
  List a user's gists:
25
24
 
@@ -80,12 +79,14 @@ Delete a gist:
80
79
 
81
80
  gh.gists("1393990").destroy
82
81
 
83
- ### Repos
82
+ ## Repos
84
83
 
85
84
  Get a single repo:
86
85
 
87
86
  gh.repos("rauhryan", "ghee")
88
87
 
88
+ ### Hooks
89
+
89
90
  Get the hooks for a repo:
90
91
 
91
92
  gh.repos("rauhryan", "ghee").hooks
@@ -112,6 +113,26 @@ Destroy a hook for a repo:
112
113
 
113
114
  gh.repos("rauhryan", "ghee").hooks(1).destory
114
115
 
116
+ ### Downloads
117
+
118
+ Get the downloads for a repo:
119
+
120
+ gh.repos("rauhryan", "ghee").downloads
121
+
122
+ Get a single download for a repo:
123
+
124
+ gh.repos("rauhryan", "ghee").downloads(12)
125
+
126
+ Create a download for a repo:
127
+
128
+ gh.repos("rauhryan", "ghee").downloads.create("/path/to/file","description")
129
+
130
+ Destroy a download for a repo:
131
+
132
+ gh.repos("rauhryan", "ghee").downloads.destroy
133
+
134
+ ### Milestones
135
+
115
136
  Get the milestones for a repo:
116
137
 
117
138
  gh.repos("rauhryan", "ghee").milestones
@@ -137,6 +158,8 @@ Destroy a milestone for a repo:
137
158
 
138
159
  gh.repos("rauhryan", "ghee").milestones(1).destory
139
160
 
161
+ ### Issues
162
+
140
163
  Get the issues for a repo:
141
164
 
142
165
  gh.repos("rauhryan", "ghee").issues
@@ -166,6 +189,8 @@ Get the closed issues for a repo:
166
189
 
167
190
  gh.repos("rauhryan", "ghee").issues(12).closed
168
191
 
192
+ ### Comments
193
+
169
194
  Get the comments for an issue:
170
195
 
171
196
  gh.repos("rauhryan", "ghee").issues(12).comments
@@ -187,7 +212,7 @@ Destroy a comment for an issue
187
212
 
188
213
  gh.repos("rauhryan", "ghee").issues.comments(482910).destroy
189
214
 
190
- ### Orgs
215
+ ## Orgs
191
216
 
192
217
  Get a list of orgs for the current user:
193
218
 
@@ -239,7 +264,7 @@ Remove a member from a team:
239
264
 
240
265
  gh.orgs("huboard").teams(110234).members.remove("rauhryan")
241
266
 
242
- ### Teams
267
+ ## Teams
243
268
 
244
269
  Get a single team:
245
270
 
@@ -269,7 +294,7 @@ Remove a member from a team:
269
294
 
270
295
  gh.team(110234).members.remove("rauhryan")
271
296
 
272
- ### Users
297
+ ## Users
273
298
 
274
299
  Get a single user:
275
300
 
@@ -316,13 +341,13 @@ Get a list of orgs for a specific user:
316
341
 
317
342
  > Notes: see above for all the available api methods for orgs
318
343
 
319
- ### Events
344
+ ## Events
320
345
 
321
346
  List public events:
322
347
 
323
348
  gh.events
324
349
 
325
- ### Pagination
350
+ ## Pagination
326
351
 
327
352
  Ghee fully supports pagination for anything that returns a list, for
328
353
  example repo issues.
@@ -338,7 +363,7 @@ Ghee also provides a convienence method for all the pages
338
363
 
339
364
  gh.repos("rauhryan","huboard").issues.all #=> return all the pages
340
365
 
341
- ### Filtering parameters
366
+ ## Filtering parameters
342
367
 
343
368
  Many of the api calls allow you to pass in additional paramters to
344
369
  filter and sort your data, for example issues provide
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require "bundler/gem_tasks"
3
3
  require "rspec/core/rake_task"
4
4
  desc "Run the specs"
5
5
  RSpec::Core::RakeTask.new do |t|
6
- t.rspec_opts = %w(-fs --color)
6
+ #t.rspec_opts = %w(-fs --color)
7
7
  end
8
8
 
9
9
  task :default => :spec
data/ghee.gemspec CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency 'multi_json'
24
24
  s.add_runtime_dependency 'yajl-ruby'
25
25
  s.add_development_dependency 'rake'
26
+ s.add_development_dependency 'json'
26
27
  s.add_development_dependency 'rspec', '~>2.0'
27
28
  s.add_development_dependency 'webmock'
28
29
  s.add_development_dependency 'vcr'
@@ -0,0 +1,57 @@
1
+ class Ghee
2
+ module API
3
+ module Repos
4
+ module Downloads
5
+ class Proxy < ::Ghee::ResourceProxy
6
+
7
+ # Creates
8
+ #
9
+ # return json
10
+ #
11
+ def create(file_path, description="")
12
+ params = {
13
+ :name => File.basename(file_path),
14
+ :size => File.size(file_path),
15
+ :description => description
16
+ }
17
+ download = connection.post(path_prefix, params).body
18
+ s3 = Faraday.new(:url => download["s3_url"]) do |builder|
19
+ builder.request :multipart
20
+ builder.request :url_encoded
21
+
22
+ builder.adapter :net_http
23
+ end
24
+ upload = {
25
+ :key => download["path"],
26
+ :acl => download["acl"],
27
+ :success_action_status => 201,
28
+ :Filename => download["name"],
29
+ :AWSAccessKeyId => download["accesskeyid"],
30
+ :Policy => download["policy"],
31
+ :Signature => download["signature"],
32
+ :"Content-Type" => download["mime_type"],
33
+ :file => Faraday::UploadIO.new(file_path, download["mime_type"])
34
+ }
35
+ s3.post("/",upload).status == 201
36
+ return download
37
+ end
38
+
39
+ # Destroys
40
+ #
41
+ # return boolean
42
+ #
43
+ def destroy
44
+ connection.delete(path_prefix).status == 204
45
+ end
46
+ end
47
+ end
48
+
49
+ class Proxy < ::Ghee::ResourceProxy
50
+ def downloads(id=nil)
51
+ prefix = id ? "#{path_prefix}/downloads/#{id}" :"#{path_prefix}/downloads"
52
+ Ghee::API::Repos::Downloads::Proxy.new(connection, prefix)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,107 @@
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
+ # The Commits module handles repo commit endpoints
14
+ #
15
+ module Commits
16
+ class Proxy < ::Ghee::ResourceProxy
17
+ include Ghee::CUD
18
+ end
19
+ end
20
+
21
+ # The Git module handles all of the raw git data endpoints
22
+ #
23
+ module Git
24
+
25
+ # The Blobs module handles all of the blob methods
26
+ #
27
+ module Blobs
28
+ class Proxy < ::Ghee::ResourceProxy
29
+ include Ghee::CUD
30
+ end
31
+ end
32
+
33
+ # The Tags module handles all of the tag methods
34
+ #
35
+ module Tags
36
+ class Proxy < ::Ghee::ResourceProxy
37
+ include Ghee::CUD
38
+ end
39
+ end
40
+
41
+ # The Commits module handles all of the commit methods
42
+ #
43
+ module Commits
44
+ class Proxy < ::Ghee::ResourceProxy
45
+ include Ghee::CUD
46
+ end
47
+ end
48
+
49
+ # The Trees module handles all of the commit methods
50
+ #
51
+ module Trees
52
+ class Proxy < ::Ghee::ResourceProxy
53
+ include Ghee::CUD
54
+ end
55
+ end
56
+
57
+ # The Refs module handles all of the commit methods
58
+ #
59
+ module Refs
60
+ class Proxy < ::Ghee::ResourceProxy
61
+ include Ghee::CUD
62
+ end
63
+ end
64
+
65
+ class Proxy < ::Ghee::ResourceProxy
66
+
67
+ # Get the blob by a provided sha
68
+ #
69
+ def blobs(sha=nil, params={})
70
+ params = sha if sha.is_a?Hash
71
+ prefix = (!sha.is_a?(Hash) and sha) ? "#{path_prefix}/blobs/#{sha}" : "#{path_prefix}/blobs"
72
+ Ghee::API::Repos::Git::Blobs::Proxy.new(connection, prefix, params)
73
+ end
74
+
75
+ # Get a commit by the sha
76
+ #
77
+ def commits(sha=nil, params={})
78
+ params = sha if sha.is_a?Hash
79
+ prefix = (!sha.is_a?(Hash) and sha) ? "#{path_prefix}/commits/#{sha}" : "#{path_prefix}/commits"
80
+ Ghee::API::Repos::Git::Commits::Proxy.new(connection, prefix, params)
81
+ end
82
+
83
+ # Get refs for the repo
84
+ #
85
+ def refs(ref=nil)
86
+ prefix = ref ? "#{path_prefix}/refs/#{ref}" : "#{path_prefix}/refs"
87
+ Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)
88
+ end
89
+
90
+ # Get tree by a given sha
91
+ #
92
+ def trees(sha=nil)
93
+ prefix = sha ? "#{path_prefix}/trees/#{sha}" : "#{path_prefix}/trees"
94
+ Ghee::API::Repos::Git::Trees::Proxy.new(connection, prefix)
95
+ end
96
+
97
+ # Get a tag by a given sha
98
+ #
99
+ def tags(sha=nil)
100
+ prefix = sha ? "#{path_prefix}/tags/#{sha}" : "#{path_prefix}/tags"
101
+ Ghee::API::Repos::Git::Tags::Proxy.new(connection, prefix)
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -54,6 +54,12 @@ class Ghee
54
54
  end
55
55
  end
56
56
 
57
+ module Events
58
+ class Proxy < ::Ghee::ResourceProxy
59
+
60
+ end
61
+ end
62
+
57
63
  # Gists::Proxy inherits from Ghee::Proxy and
58
64
  # enables defining methods on the proxy object
59
65
  #
@@ -81,15 +87,26 @@ class Ghee
81
87
  response.body
82
88
  end
83
89
 
90
+ # Returns issue comments for an issue or all of the comments
91
+ # for a repo
84
92
  def comments(id=nil)
85
93
  prefix = id ? "#{path_prefix}/comments/#{id}" : "#{path_prefix}/comments"
86
94
  Ghee::API::Issues::Comments::Proxy.new(connection,prefix)
87
95
  end
88
96
 
97
+ # Returns all of the labels for repo
98
+ #
89
99
  def labels
90
100
  Ghee::API::Issues::Labels::Proxy.new(connection, "#{path_prefix}/labels")
91
101
  end
92
102
 
103
+ # Returns issue events for a repo or issue number
104
+ #
105
+ def events(id=nil)
106
+ prefix = id ? "#{path_prefix}/events/#{id}" : "#{path_prefix}/events"
107
+ Ghee::API::Issues::Events::Proxy.new(connection,prefix)
108
+ end
109
+
93
110
  end
94
111
  end
95
112
  end
@@ -78,6 +78,16 @@ class Ghee
78
78
  Ghee::API::Repos::Hooks::Proxy.new(connection, prefix, params)
79
79
  end
80
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
+
81
91
  end
82
92
 
83
93
  # Get repos
@@ -21,7 +21,7 @@ class Ghee
21
21
 
22
22
  super('https://api.github.com') do |builder|
23
23
  builder.use Faraday::Request::JSON
24
- builder.use Faraday::Response::ParseJson
24
+ builder.use FaradayMiddleware::ParseJson
25
25
  builder.adapter Faraday.default_adapter
26
26
  end
27
27
 
@@ -94,15 +94,15 @@ class Ghee
94
94
  def parse_link_header(header)
95
95
  return @total = subject.size, @pagination = {} if header.nil?
96
96
  require 'cgi'
97
- pattern = /<(?<link>.*)>;\s+rel="(?<rel>.*)"/
97
+ pattern = /<(.*)>;\s+rel="(.*)"/
98
98
  matches = {}
99
99
  header.split(',').each do |m|
100
100
  match = pattern.match m
101
- uri = URI.parse(match[:link])
101
+ uri = URI.parse(match[1])
102
102
  uri_params = CGI.parse(uri.query)
103
103
  page = uri_params["page"].first.to_i
104
104
  per_page = uri_params["per_page"] ? uri_params["per_page"].first.to_i : 30
105
- matches[match[:rel].to_sym] = {:link => match[:link], :page => page, :per_page => per_page}
105
+ matches[match[2].to_sym] = {:link => match[1], :page => page, :per_page => per_page}
106
106
  end
107
107
  @pagination = matches
108
108
  end
data/lib/ghee/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  class Ghee
3
- VERSION = "0.7.1"
3
+ VERSION = "0.8.0"
4
4
  end
data/lib/ghee.rb CHANGED
@@ -11,6 +11,8 @@ require 'ghee/api/repos'
11
11
  require 'ghee/api/issues'
12
12
  require 'ghee/api/milestones'
13
13
  require 'ghee/api/orgs'
14
+ require 'ghee/api/git_data'
15
+ require 'ghee/api/downloads'
14
16
 
15
17
  class Ghee
16
18
  attr_reader :connection
data/spec/fyeah.jpg ADDED
Binary file
@@ -3,7 +3,15 @@ require 'spec_helper'
3
3
  describe Ghee::API::Authorizations do
4
4
  subject { Ghee.new(GH_AUTH) }
5
5
 
6
- describe "#authorizations" do
6
+ describe "#authorizations#list" do
7
+ it "should return a list of auths" do
8
+ VCR.use_cassette "authorizations" do
9
+ auth = subject.authorizations
10
+ auth.size().should > 0
11
+ end
12
+ end
13
+ end
14
+ describe "#authorizations", :if => false do
7
15
 
8
16
  context "with a test authorization" do
9
17
  before :all do
@@ -22,12 +30,6 @@ describe Ghee::API::Authorizations do
22
30
  end
23
31
  end
24
32
 
25
- it "should return a list of auths" do
26
- VCR.use_cassette "authorizations" do
27
- auth = subject.authorizations
28
- auth.size().should > 0
29
- end
30
- end
31
33
 
32
34
  it "should patch an auth" do
33
35
  VCR.use_cassette "authorization(id).patch" do
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ghee::API::Repos::Downloads do
4
+ subject { Ghee.new(GH_AUTH).repos(GH_USER,GH_REPO) }
5
+
6
+
7
+ describe "#repos(login,name)#downloads" do
8
+ context "with a test download" do
9
+ before :all do
10
+ VCR.use_cassette "repos(login,name).downloads.create.test" do
11
+ @download = subject.downloads.create(File.expand_path("../../../fyeah.jpg",__FILE__),"This is a test of the downloads api")
12
+ @download.should_not be_nil
13
+ end
14
+ end
15
+ let(:test_download) {@download}
16
+ after :all do
17
+ VCR.use_cassette "repos(login,name).downloads.delete" do
18
+ subject.downloads(test_download["id"]).destroy
19
+ end
20
+ end
21
+
22
+ it "should return a list of downloads" do
23
+ VCR.use_cassette "repos#downloads#all" do
24
+ downloads = subject.downloads
25
+ downloads.size.should > 0
26
+ downloads.first["download_count"].should_not be_nil
27
+ end
28
+ end
29
+ it "should return a single download" do
30
+ VCR.use_cassette "repos#downloads#by_id" do
31
+ download = subject.downloads test_download["id"]
32
+ download.should_not be_nil
33
+ download["download_count"].should_not be_nil
34
+ end
35
+ end
36
+
37
+ it "should have uploaded a file" do
38
+ test_download["id"].should_not be_nil
39
+ test_download["name"].should_not be_nil
40
+ test_download["mime_type"].should_not be_nil
41
+ test_download["policy"].should_not be_nil
42
+ test_download["signature"].should_not be_nil
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+
49
+
@@ -0,0 +1,134 @@
1
+ require 'spec_helper'
2
+ require 'time'
3
+
4
+ describe Ghee::API::Repos::Git do
5
+ subject { Ghee.new(GH_AUTH).repos(GH_USER,GH_REPO) }
6
+
7
+ def should_be_a_blob(blob)
8
+ blob["content"].should_not be_nil
9
+ blob["encoding"].should_not be_nil
10
+ end
11
+
12
+ def should_be_a_commit(commit)
13
+ # assert its a commit
14
+ commit["sha"].should_not be_nil
15
+ end
16
+
17
+ def should_be_a_tree(tree)
18
+ tree["sha"].should_not be_nil
19
+ tree["tree"].size.should > 0
20
+ end
21
+
22
+ def should_be_a_ref(ref)
23
+ ref["ref"].should_not be_nil
24
+ ref["url"].should_not be_nil
25
+ ref["object"].should_not be_nil
26
+ end
27
+
28
+ def should_be_a_tag(tag)
29
+ tag["sha"].should_not be_nil
30
+ tag["tag"].should_not be_nil
31
+ tag["message"].should_not be_nil
32
+ tag["tagger"].should_not be_nil
33
+ end
34
+
35
+ describe "#repos()#commits" do
36
+ it "should return an array of commits" do
37
+ VCR.use_cassette "#repos()#commits" do
38
+ commits = subject.commits
39
+ commits.size.should > 0
40
+ should_be_a_commit commits.first
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "#repos(login,name)#git" do
46
+ describe "#tags" do
47
+ context "with a test tags" do
48
+ before :all do
49
+ VCR.use_cassette "repos()#git#tags#create" do
50
+ @test_tag = subject.git.tags.create({
51
+ :tag => "test_tag_#{rand(100)}",
52
+ :object => subject.commits.first["sha"],
53
+ :type => "commit",
54
+ :message => "creating a tag with the api",
55
+ :tagger => {
56
+ :name => "Ryan Rauh",
57
+ :email => "rauh.ryan@gmail.com",
58
+ :date => Time.now.iso8601
59
+ }
60
+
61
+ });
62
+ @test_tag.should_not be_nil
63
+ end
64
+ end
65
+ let(:test_tag) {@test_tag}
66
+
67
+ it "should return a tag" do
68
+ VCR.use_cassette "repos()#git#tags#sha" do
69
+ tag = subject.git.tags(test_tag["sha"])
70
+ should_be_a_tag tag
71
+ end
72
+ end
73
+ end
74
+ end
75
+ describe "#blobs" do
76
+ context "with a test blob" do
77
+ before :all do
78
+ VCR.use_cassette "repos()#git#blobs#create" do
79
+ @test_blob = subject.git.blobs.create({
80
+ :content => "Oh hello!",
81
+ :encoding => "utf-8"
82
+ });
83
+ @test_blob.should_not be_nil
84
+ end
85
+ end
86
+ let(:test_blob) {@test_blob}
87
+
88
+ it "should return a blob" do
89
+ VCR.use_cassette "repos()#git#blobs#sha" do
90
+ blob = subject.git.blobs(test_blob["sha"])
91
+ should_be_a_blob blob
92
+ end
93
+ end
94
+ end
95
+ end
96
+ describe "#refs" do
97
+ it "should return all the refs" do
98
+ VCR.use_cassette "repos()#git#refs" do
99
+ refs = subject.git.refs
100
+ refs.size.should > 0
101
+ should_be_a_ref refs.first
102
+ end
103
+ end
104
+ end
105
+ context "with a test commit" do
106
+ before :all do
107
+ VCR.use_cassette "repos()#commits#first" do
108
+ # create a commit
109
+ @test_commit = subject.commits.first
110
+ end
111
+ end
112
+ let(:test_commit) {@test_commit}
113
+
114
+ describe "#trees" do
115
+ it "should return a tree for the commit sha" do
116
+ VCR.use_cassette "repos()#git#trees:sha" do
117
+ tree = subject.git.trees test_commit["sha"]
118
+ tree.should_not be_nil
119
+ end
120
+ end
121
+ end
122
+
123
+ describe "#commits" do
124
+ it "should return a commit" do
125
+ VCR.use_cassette "repos()#git#commit#sha" do
126
+ commit = subject.git.commits(test_commit["sha"])
127
+ should_be_a_commit commit
128
+ end
129
+ end
130
+ end
131
+ end
132
+ end
133
+ end
134
+
@@ -72,6 +72,20 @@ describe Ghee::API::Issues do
72
72
  end
73
73
  end
74
74
 
75
+ describe "#events" do
76
+ it "should return all the events for a given issue" do
77
+ VCR.use_cassette "#repo#issues(id)#events" do
78
+ events = subject.repos(GH_USER,GH_REPO).issues(test_issue["number"]).events
79
+ events.size.should > 0
80
+ end
81
+ end
82
+ it "should return all the events for the repo" do
83
+ VCR.use_cassette "#repo#issues#events" do
84
+ events = subject.repos(GH_USER,GH_REPO).issues.events
85
+ events.size.should > 0
86
+ end
87
+ end
88
+ end
75
89
  describe "#comments" do
76
90
  context "issue with comments " do
77
91
  before :all do
@@ -4,14 +4,16 @@ describe Ghee::API::Milestones do
4
4
  subject { Ghee.new(GH_AUTH) }
5
5
 
6
6
  def should_be_an_milestone(milestone)
7
- milestone["creator"]["login"].should_not be_nil
8
7
  milestone["title"].should_not be_nil
8
+ milestone["number"].should_not be_nil
9
+ milestone["open_issues"].should_not be_nil
10
+ milestone["closed_issues"].should_not be_nil
9
11
  end
10
12
 
11
13
  describe "#repos(login,name)#milestones" do
12
14
  it "should return repos milestones" do
13
15
  VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).milestones") do
14
- temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone" })
16
+ temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone #{rand(100)}" })
15
17
 
16
18
  milestones = subject.repos(GH_USER, GH_REPO).milestones
17
19
  milestones.size.should > 0
@@ -24,7 +26,7 @@ describe Ghee::API::Milestones do
24
26
  describe "#repos(login,name)#milestones#closed" do
25
27
  it "should return repos closed milestones" do
26
28
  VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).milestones.closed") do
27
- temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone" })
29
+ temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone #{rand(100)}" })
28
30
  subject.repos(GH_USER, GH_REPO).milestones(temp_milestone["number"]).close
29
31
 
30
32
  milestones = subject.repos(GH_USER, GH_REPO).milestones.closed
@@ -42,7 +44,7 @@ describe Ghee::API::Milestones do
42
44
  describe "#repos(login,name)#milestones(1)" do
43
45
  it "should return an milestone by id" do
44
46
  VCR.use_cassette("repos(#{GH_USER},#{GH_REPO}).milestones(1)") do
45
- temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone" })
47
+ temp_milestone = subject.repos(GH_USER, GH_REPO).milestones.create({ :title => "Destroy test milestone #{rand(100)}" })
46
48
 
47
49
  milestone = subject.repos(GH_USER, GH_REPO).milestones(1)
48
50
  should_be_an_milestone(milestone)
@@ -56,7 +58,7 @@ describe Ghee::API::Milestones do
56
58
  VCR.use_cassette "milestones(id).destroy" do
57
59
  repo = subject.repos(GH_USER, GH_REPO)
58
60
  test_milestone = repo.milestones.create({
59
- :title => "Destroy test milestone"
61
+ :title => "Destroy test milestone #{rand(100)}"
60
62
  })
61
63
  should_be_an_milestone(test_milestone)
62
64
  subject.repos(GH_USER, GH_REPO).milestones(test_milestone["number"]).destroy.should be_true
@@ -100,4 +102,4 @@ describe Ghee::API::Milestones do
100
102
  end
101
103
  end
102
104
  end
103
- end
105
+ end
@@ -22,7 +22,6 @@ describe Ghee::API::Repos do
22
22
  it "should return issues for repo" do
23
23
  VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).issues") do
24
24
  issues = subject.repos(GH_USER, GH_REPO).issues
25
- puts issues.sort_by! { |r| r["title"]}.reverse
26
25
  issues.is_a?(Array).should be_true
27
26
  issues.size.should > 0
28
27
  issues.first["title"].should_not be_nil
@@ -31,54 +30,53 @@ describe Ghee::API::Repos do
31
30
  end
32
31
 
33
32
  describe "#labels" do
34
- it "should return all the labels" do
35
- VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels") do
36
- temp_label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "temp label")
33
+ context "" do
34
+ before :all do
35
+ VCR.use_cassette "#labels#create" do
36
+ @temp_label = subject.repos(GH_USER, GH_REPO).labels.create({:color => "efefef", :name => "#{(0...8).map{ ('a'..'z').to_a[rand(26)] }.join}"})
37
+ end
38
+ end
39
+ let(:test_label) {@temp_label}
40
+ after :all do
41
+ VCR.use_cassette "#labels#destroy" do
42
+ subject.repos(GH_USER, GH_REPO).labels(test_label['name']).destroy
43
+ end
44
+ end
45
+ it "should return all the labels" do
46
+ VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels") do
37
47
 
38
- labels = subject.repos(GH_USER, GH_REPO).labels
39
- labels.size.should > 0
40
- labels.first["color"].should_not be_nil
48
+ labels = subject.repos(GH_USER, GH_REPO).labels
49
+ labels.size.should > 0
50
+ labels.first["color"].should_not be_nil
41
51
 
42
- subject.repos(GH_USER, GH_REPO).labels(temp_label['name']).destroy
52
+ end
43
53
  end
44
- end
45
54
 
46
- it "should get a single label" do
47
- VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels(id)") do
48
- temp_label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "temp label")
55
+ it "should get a single label" do
56
+ VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels(id)") do
49
57
 
50
- label = subject.repos(GH_USER,GH_REPO).labels(temp_label["name"])
51
- label["color"].should == 'efefef'
52
- label["name"].should == 'temp label'
58
+ label = subject.repos(GH_USER,GH_REPO).labels(test_label["name"])
59
+ label["color"].should == 'efefef'
60
+ label["name"].should == test_label["name"]
53
61
 
54
- subject.repos(GH_USER, GH_REPO).labels(temp_label['name']).destroy
62
+ end
55
63
  end
56
- end
57
64
 
58
- it "should patch a label" do
59
- VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels.patched") do
60
- label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "patch label")
61
- label["color"].should == "efefef"
62
- label["url"].should include "labels/patch"
63
- label["name"].should == "patch label"
65
+ it "should patch a label" do
66
+ VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels.patched") do
67
+ name = "patch label #{rand(100)}"
68
+ label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => name)
69
+ label["color"].should == "efefef"
70
+ label["url"].should include "labels/patch"
64
71
 
65
- patched = subject.repos(GH_USER, GH_REPO).labels(label["name"]).patch(:color => "000000", :name => "patched label")
66
- patched["color"].should == "000000"
67
- patched["url"].should include "labels/patched"
68
- patched["name"].should == "patched label"
72
+ patched = subject.repos(GH_USER, GH_REPO).labels(label["name"]).patch(:color => "000000", :name => "patched label")
73
+ patched["color"].should == "000000"
74
+ patched["url"].should include "labels/patched"
69
75
 
70
- subject.repos(GH_USER, GH_REPO).labels(patched["name"]).destroy.should be_true
76
+ subject.repos(GH_USER, GH_REPO).labels(patched["name"]).destroy.should be_true
77
+ end
71
78
  end
72
- end
73
79
 
74
- it "should create a label" do
75
- VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).labels.create") do
76
- label = subject.repos(GH_USER, GH_REPO).labels.create(:color => "efefef", :name => "created label")
77
- label["color"].should == "efefef"
78
- label["url"].should include "labels/created"
79
- label["name"].should == "created label"
80
- subject.repos(GH_USER, GH_REPO).labels(label["name"]).destroy.should be_true
81
- end
82
80
  end
83
81
  end
84
82
  end
@@ -14,7 +14,7 @@ describe Ghee::API::Orgs::Teams do
14
14
  before :all do
15
15
  VCR.use_cassette "orgs.teams.create.test" do
16
16
  @test_team = subject.orgs(GH_ORG).teams.create({
17
- :name => "test_team"
17
+ :name => "#{(0...8).map{ ('a'..'z').to_a[rand(26)] }.join}"
18
18
  })
19
19
  @test_team.should_not be_nil
20
20
  end
@@ -25,7 +25,7 @@ describe Ghee::API::Orgs::Teams do
25
25
  before :all do
26
26
  VCR.use_cassette "orgs.teams.create.test_member" do
27
27
  @member_team = subject.orgs(GH_ORG).teams.create({
28
- :name => "test_team_with_members"
28
+ :name => "#{(0...8).map{ ('a'..'z').to_a[rand(26)] }.join}"
29
29
  })
30
30
  @member_team.should_not be_nil
31
31
  end
@@ -69,11 +69,11 @@ describe Ghee::API::Orgs::Teams do
69
69
 
70
70
  it "should patch the team" do
71
71
  VCR.use_cassette "orgs.teams.patch" do
72
+ name = "#{(0...8).map{ ('a'..'z').to_a[rand(26)] }.join}"
72
73
  team = subject.orgs(GH_ORG).teams(test_team['id']).patch({
73
- :name => "herpderp"
74
+ :name => name
74
75
  })
75
76
  should_be_a_team team
76
- team["name"].should == "herpderp"
77
77
  end
78
78
 
79
79
  end
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,11 @@ VCR.config do |c|
10
10
  c.stub_with :webmock
11
11
  c.default_cassette_options = {:record => :once}
12
12
  end
13
-
14
- settings = YAML.load_file(File.expand_path('../settings.yml', __FILE__))
15
- GH_AUTH = settings['access_token'] ? {:access_token => settings['access_token']} : {:basic_auth => {:user_name => settings['username'], :password => settings['password']}}
16
- GH_USER, GH_REPO, GH_ORG = settings['username'], settings['repo'], settings['org']
13
+ if File.exists? File.expand_path("../settings.yml", __FILE__)
14
+ settings = YAML.load_file(File.expand_path('../settings.yml', __FILE__))
15
+ GH_AUTH = settings['access_token'] ? {:access_token => settings['access_token']} : {:basic_auth => {:user_name => settings['username'], :password => settings['password']}}
16
+ GH_USER, GH_REPO, GH_ORG = settings['username'], settings['repo'], settings['org']
17
+ else
18
+ GH_AUTH = {:access_token => ENV["TOKEN"]}
19
+ GH_USER, GH_REPO, GH_ORG = ENV['GH_USER'], ENV['GH_REPO'], ENV['GH_ORG']
20
+ 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.7.1
4
+ version: 0.8.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-05 00:00:00.000000000Z
13
+ date: 2012-04-08 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
- requirement: &70106718506800 !ruby/object:Gem::Requirement
17
+ requirement: &70200201095860 !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: *70106718506800
25
+ version_requirements: *70200201095860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: faraday_middleware
28
- requirement: &70106718506220 !ruby/object:Gem::Requirement
28
+ requirement: &70200201095200 !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: *70106718506220
36
+ version_requirements: *70200201095200
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: multi_json
39
- requirement: &70106718505640 !ruby/object:Gem::Requirement
39
+ requirement: &70200201094540 !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: *70106718505640
47
+ version_requirements: *70200201094540
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: yajl-ruby
50
- requirement: &70106718505080 !ruby/object:Gem::Requirement
50
+ requirement: &70200201094040 !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: *70106718505080
58
+ version_requirements: *70200201094040
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rake
61
- requirement: &70106718504580 !ruby/object:Gem::Requirement
61
+ requirement: &70200201093440 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,21 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70106718504580
69
+ version_requirements: *70200201093440
70
+ - !ruby/object:Gem::Dependency
71
+ name: json
72
+ requirement: &70200201092740 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *70200201092740
70
81
  - !ruby/object:Gem::Dependency
71
82
  name: rspec
72
- requirement: &70106718504080 !ruby/object:Gem::Requirement
83
+ requirement: &70200201076300 !ruby/object:Gem::Requirement
73
84
  none: false
74
85
  requirements:
75
86
  - - ~>
@@ -77,10 +88,10 @@ dependencies:
77
88
  version: '2.0'
78
89
  type: :development
79
90
  prerelease: false
80
- version_requirements: *70106718504080
91
+ version_requirements: *70200201076300
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: webmock
83
- requirement: &70106718503600 !ruby/object:Gem::Requirement
94
+ requirement: &70200201075480 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ! '>='
@@ -88,10 +99,10 @@ dependencies:
88
99
  version: '0'
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *70106718503600
102
+ version_requirements: *70200201075480
92
103
  - !ruby/object:Gem::Dependency
93
104
  name: vcr
94
- requirement: &70106718502960 !ruby/object:Gem::Requirement
105
+ requirement: &70200201074620 !ruby/object:Gem::Requirement
95
106
  none: false
96
107
  requirements:
97
108
  - - ! '>='
@@ -99,10 +110,10 @@ dependencies:
99
110
  version: '0'
100
111
  type: :development
101
112
  prerelease: false
102
- version_requirements: *70106718502960
113
+ version_requirements: *70200201074620
103
114
  - !ruby/object:Gem::Dependency
104
115
  name: ZenTest
105
- requirement: &70106718502280 !ruby/object:Gem::Requirement
116
+ requirement: &70200201073820 !ruby/object:Gem::Requirement
106
117
  none: false
107
118
  requirements:
108
119
  - - ! '>='
@@ -110,10 +121,10 @@ dependencies:
110
121
  version: '0'
111
122
  type: :development
112
123
  prerelease: false
113
- version_requirements: *70106718502280
124
+ version_requirements: *70200201073820
114
125
  - !ruby/object:Gem::Dependency
115
126
  name: autotest-growl
116
- requirement: &70106718501440 !ruby/object:Gem::Requirement
127
+ requirement: &70200201073000 !ruby/object:Gem::Requirement
117
128
  none: false
118
129
  requirements:
119
130
  - - ! '>='
@@ -121,7 +132,7 @@ dependencies:
121
132
  version: '0'
122
133
  type: :development
123
134
  prerelease: false
124
- version_requirements: *70106718501440
135
+ version_requirements: *70200201073000
125
136
  description: A complete, simple, and intuitive ruby API for all things Github.
126
137
  email:
127
138
  - rauh.ryan@gmail.com
@@ -131,7 +142,7 @@ extra_rdoc_files: []
131
142
  files:
132
143
  - .autotest
133
144
  - .gitignore
134
- - .rspec
145
+ - .travis.yml
135
146
  - Gemfile
136
147
  - LICENSE
137
148
  - README.md
@@ -139,8 +150,10 @@ files:
139
150
  - ghee.gemspec
140
151
  - lib/ghee.rb
141
152
  - lib/ghee/api/authorizations.rb
153
+ - lib/ghee/api/downloads.rb
142
154
  - lib/ghee/api/events.rb
143
155
  - lib/ghee/api/gists.rb
156
+ - lib/ghee/api/git_data.rb
144
157
  - lib/ghee/api/issues.rb
145
158
  - lib/ghee/api/milestones.rb
146
159
  - lib/ghee/api/orgs.rb
@@ -150,9 +163,12 @@ files:
150
163
  - lib/ghee/resource_proxy.rb
151
164
  - lib/ghee/state_methods.rb
152
165
  - lib/ghee/version.rb
166
+ - spec/fyeah.jpg
153
167
  - spec/ghee/api/authorizations_spec.rb
168
+ - spec/ghee/api/downloads_spec.rb
154
169
  - spec/ghee/api/events_spec.rb
155
170
  - spec/ghee/api/gists_spec.rb
171
+ - spec/ghee/api/gitdata_spec.rb
156
172
  - spec/ghee/api/hooks_spec.rb
157
173
  - spec/ghee/api/issues_spec.rb
158
174
  - spec/ghee/api/milestones_spec.rb
@@ -191,9 +207,12 @@ signing_key:
191
207
  specification_version: 3
192
208
  summary: Access Github in ruby.
193
209
  test_files:
210
+ - spec/fyeah.jpg
194
211
  - spec/ghee/api/authorizations_spec.rb
212
+ - spec/ghee/api/downloads_spec.rb
195
213
  - spec/ghee/api/events_spec.rb
196
214
  - spec/ghee/api/gists_spec.rb
215
+ - spec/ghee/api/gitdata_spec.rb
197
216
  - spec/ghee/api/hooks_spec.rb
198
217
  - spec/ghee/api/issues_spec.rb
199
218
  - spec/ghee/api/milestones_spec.rb
data/.rspec DELETED
File without changes