Permalink
Browse files

working on raw git data support #blobs & #commits are half baked

  • Loading branch information...
1 parent fd9b56b commit 2a330a2524d1227b1f1dfacf9fc97062c1875363 @rauhryan rauhryan committed Apr 5, 2012
Showing with 115 additions and 1 deletion.
  1. +1 −0 lib/ghee.rb
  2. +54 −0 lib/ghee/api/git_data.rb
  3. +4 −0 lib/ghee/api/repos.rb
  4. +56 −0 spec/ghee/api/gitdata_spec.rb
  5. +0 −1 spec/ghee/api/repos_spec.rb
View
@@ -11,6 +11,7 @@
require 'ghee/api/issues'
require 'ghee/api/milestones'
require 'ghee/api/orgs'
+require 'ghee/api/git_data'
class Ghee
attr_reader :connection
View
@@ -0,0 +1,54 @@
+class Ghee
+
+ # API module encapsulates all of API endpoints
+ # implemented thus far
+ #
+ module API
+
+ # The Repos module handles all of the Github Repo
+ # API endpoints
+ #
+ module Repos
+
+ # The Git module handles all of the raw git data endpoints
+ #
+ module Git
+
+ # The Blobs module handles all of the blob methods
+ #
+ module Blobs
+ class Proxy < ::Ghee::ResourceProxy
+ include Ghee::CUD
+ end
+ end
+
+ # The Commits module handles all of the commit methods
+ #
+ module Commits
+ class Proxy < ::Ghee::ResourceProxy
+ include Ghee::CUD
+ end
+ end
+
+ class Proxy < ::Ghee::ResourceProxy
+
+ # Get the blob by a provided sha
+ #
+ def blobs(sha=nil, params={})
+ params = sha if sha.is_a?Hash
+ prefix = (!sha.is_a?(Hash) and sha) ? "#{path_prefix}/blobs/#{sha}" : "#{path_prefix}/blobs"
+ Ghee::API::Repos::Git::Blobs::Proxy.new(connection, prefix, params)
+ end
+
+ # Get a commit by the sha
+ #
+ def commits(sha=nil, params={})
+ params = sha if sha.is_a?Hash
+ prefix = (!sha.is_a?(Hash) and sha) ? "#{path_prefix}/commits/#{sha}" : "#{path_prefix}/commits"
+ Ghee::API::Repos::Git::Commits::Proxy.new(connection, prefix, params)
+ end
+ end
+ end
+ end
+ end
+end
View
@@ -78,6 +78,10 @@ def hooks(number=nil, params={})
Ghee::API::Repos::Hooks::Proxy.new(connection, prefix, params)
end
+ def git
+ Ghee::API::Repos::Git::Proxy.new(connection, "#{path_prefix}/git")
+ end
+
end
# Get repos
@@ -0,0 +1,56 @@
+require 'spec_helper'
+
+describe Ghee::API::Repos::Git do
+ subject { Ghee.new(GH_AUTH) }
+
+ def should_be_a_blob(blob)
+ blob["content"].should_not be_nil
+ blob["encoding"].should_not be_nil
+ end
+
+ def should_be_a_commit(commit)
+ # assert its a commit
+ end
+
+ describe "#repos(login,name)#git" do
+ describe "#blobs" do
+ context "with a test blob" do
+ before :all do
+ VCR.use_cassette "repos()#git#blobs#create" do
+ @test_blob = subject.repos(GH_USER, GH_REPO).git.blobs.create({
+ :content => "Oh hello!",
+ :encoding => "utf-8"
+ });
+ @test_blob.should_not be_nil
+ end
+ end
+ let(:test_blob) {@test_blob}
+
+ it "should return a blob" do
+ VCR.use_cassette "repos()#git#blobs#sha" do
+ blob = subject.repos(GH_USER, GH_REPO).git.blobs(test_blob["sha"])
+ should_be_a_blob blob
+ end
+ end
+ end
+ end
+ describe "#commits" do
+ context "with a test commit" do
+ before :all do
+ VCR.use_cassette "repos()#git#commits#create" do
+ # create a commit
+ end
+ end
+ let(:test_commit) {@test_commit}
+
+ it "should return a commit" do
+ VCR.use_cassette "repos()#git#commit#sha" do
+ #commit = subject.repos(GH_USER, GH_REPO).git.commits(test_commit["sha"])
+ #should_be_a_commit commit
+ end
+ end
+ end
+ end
+ end
+end
+
@@ -22,7 +22,6 @@ def should_be_a_repo(repo)
it "should return issues for repo" do
VCR.use_cassette("repo(#{GH_USER},#{GH_REPO}).issues") do
issues = subject.repos(GH_USER, GH_REPO).issues
- puts issues.sort_by! { |r| r["title"]}.reverse
issues.is_a?(Array).should be_true
issues.size.should > 0
issues.first["title"].should_not be_nil

0 comments on commit 2a330a2

Please sign in to comment.