Permalink
Browse files

Add .branches method to Repository object.

  • Loading branch information...
1 parent 385ce1d commit a37a352bd11b6859aa95419cbd0698f510051028 @runpaint committed Apr 24, 2009
Showing with 22 additions and 1 deletion.
  1. +1 −1 lib/octopi.rb
  2. +17 −0 lib/octopi/branch.rb
  3. +4 −0 lib/octopi/repository.rb
View
@@ -181,7 +181,7 @@ def trace(oper, url, params)
end
end
- %w{error base resource user tag repository issue file_object blob commit}.
+ %w{error base resource user tag repository issue file_object blob commit branch}.
each{|f| require "#{File.dirname(__FILE__)}/octopi/#{f}"}
end
View
@@ -0,0 +1,17 @@
+module Octopi
+ class Branch < Base
+ include Resource
+ set_resource_name "branch", "branches"
+
+ resource_path "/repos/show/:id"
+
+ def self.find(user, repo)
+ user = user.login if user.is_a? User
+ repo = repo.name if repo.is_a? Repository
+ self.validate_args(user => :user, repo => :repo)
+ find_plural([user,repo,'branches'], :resource){
+ |i| {:name => i.first, :hash => i.last }
+ }
+ end
+ end
+end
View
@@ -6,6 +6,10 @@ class Repository < Base
find_path "/repos/search/:query"
resource_path "/repos/show/:id"
+ def branches
+ Branch.find(self.owner, self.name)
+ end
+
def tags
Tag.find(self.owner, self.name)
end

0 comments on commit a37a352

Please sign in to comment.