lib/octopi/blob.rb in octopi-0.1.0 vs lib/octopi/blob.rb in octopi-0.2.1
- old
+ new
@@ -1,21 +1,25 @@
+require File.join(File.dirname(__FILE__), "resource")
module Octopi
class Blob < Base
+ attr_accessor :text, :data, :name, :sha, :size, :mode, :mime_type
include Resource
set_resource_name "blob"
resource_path "/blob/show/:id"
- def self.find(user, repo, sha, path=nil)
- user = user.login if user.is_a? User
- repo = repo.name if repo.is_a? Repository
- self.class.validate_args(sha => :sha, user => :user, path => :file)
+ def self.find(options={})
+ ensure_hash(options)
+ user, repo = gather_details(options)
+ sha = options[:sha]
+ path = options[:path]
+
+ self.validate_args(sha => :sha, user => :user)
+
if path
- super [user,repo,sha,path]
+ super [user, repo, sha, path]
else
- blob = ANONYMOUS_API.get_raw(path_for(:resource),
- {:id => [user,repo,sha].join('/')})
- new(ANONYMOUS_API, {:text => blob})
+ Api.api.get_raw(path_for(:resource), {:id => [user, repo, sha].join('/')})
end
end
end
end