class Git::Object::AbstractObject

Attributes

mode[RW]
objectish[RW]
size[W]
type[RW]

Public Class Methods

new(base, objectish) click to toggle source
# File lib/git/object.rb, line 16
def initialize(base, objectish)
  @base = base
  @objectish = objectish.to_s
  @contents = nil
  @trees = nil
  @size = nil
  @sha = nil
end

Public Instance Methods

archive(file = nil, opts = {}) click to toggle source

creates an archive of this object (tree)

# File lib/git/object.rb, line 69
def archive(file = nil, opts = {})
  @base.lib.archive(@objectish, file, opts)
end
blob?() click to toggle source
# File lib/git/object.rb, line 75
def blob?; false; end
commit?() click to toggle source
# File lib/git/object.rb, line 77
def commit?; false; end
contents(&block) click to toggle source

Get the object’s contents. If no block is given, the contents are cached in memory and returned as a string. If a block is given, it yields an IO object (via IO::popen) which could be used to read a large file in chunks.

Use this for large files so that they are not held in memory.

# File lib/git/object.rb, line 39
def contents(&block)
  if block_given?
    @base.lib.object_contents(@objectish, &block)
  else
    @contents ||= @base.lib.object_contents(@objectish)
  end
end
contents_array() click to toggle source
# File lib/git/object.rb, line 47
def contents_array
  self.contents.split("\n")
end
diff(objectish) click to toggle source
# File lib/git/object.rb, line 60
def diff(objectish)
  Git::Diff.new(@base, @objectish, objectish)
end
grep(string, path_limiter = nil, opts = {}) click to toggle source
# File lib/git/object.rb, line 55
def grep(string, path_limiter = nil, opts = {})
  opts = {:object => sha, :path_limiter => path_limiter}.merge(opts)
  @base.lib.grep(string, opts)
end
log(count = 30) click to toggle source
# File lib/git/object.rb, line 64
def log(count = 30)
  Git::Log.new(@base, count).object(@objectish)
end
sha() click to toggle source
# File lib/git/object.rb, line 25
def sha
  @sha ||= @base.lib.revparse(@objectish)
end
size() click to toggle source
# File lib/git/object.rb, line 29
def size
  @size ||= @base.lib.object_size(@objectish)
end
tag?() click to toggle source
# File lib/git/object.rb, line 79
def tag?; false; end
to_s() click to toggle source
# File lib/git/object.rb, line 51
def to_s
  @objectish
end
tree?() click to toggle source
# File lib/git/object.rb, line 73
def tree?; false; end