From b44bc607ec11182d7dbf3cddfae50ece7cae1384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes=20Falc=C3=A3o?= Date: Fri, 7 Oct 2011 18:14:57 -0300 Subject: [PATCH] Enable gist listing --- lib/github/dsl.rb | 9 +++++++-- lib/github/models/gist.rb | 9 +++++++++ spec/github/github_spec.rb | 4 ++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 lib/github/models/gist.rb diff --git a/lib/github/dsl.rb b/lib/github/dsl.rb index 537bb69..505b78a 100644 --- a/lib/github/dsl.rb +++ b/lib/github/dsl.rb @@ -64,10 +64,15 @@ def organization_public_members(organization_name) h.map {|u| User.from_hash(u) } end + def gists(login) + h = json("/users/#{login}/gists") + h.map {|g| Gist.from_hash(g) } + end + private def json(path) HTTParty.get('https://api.github.com' << path).parsed_response end - end # Finders -end # GitHub + end +end diff --git a/lib/github/models/gist.rb b/lib/github/models/gist.rb new file mode 100644 index 0000000..d88b6aa --- /dev/null +++ b/lib/github/models/gist.rb @@ -0,0 +1,9 @@ +require 'github/models/base_model' + +module GitHub + class Gist < BaseModel + def owner + @owner ||= GitHub::User.new(@table[:user]) + end + end +end diff --git a/spec/github/github_spec.rb b/spec/github/github_spec.rb index 4779c44..3d07193 100644 --- a/spec/github/github_spec.rb +++ b/spec/github/github_spec.rb @@ -40,4 +40,8 @@ it "should be able to find a commit" do subject.should respond_to(:commit) end + + it "should be able to find gists of an user" do + subject.should respond_to(:gists) + end end