class Git::Object::AbstractObject
Attributes
Public Class Methods
Source
# File lib/git/object.rb, line 18 def initialize(base, objectish) @base = base @objectish = objectish.to_s @contents = nil @trees = nil @size = nil @sha = nil end
Public Instance Methods
Source
# File lib/git/object.rb, line 71 def archive(file = nil, opts = {}) @base.lib.archive(@objectish, file, opts) end
creates an archive of this object (tree)
Source
# File lib/git/object.rb, line 41 def contents(&block) if block_given? @base.lib.cat_file_contents(@objectish, &block) else @contents ||= @base.lib.cat_file_contents(@objectish) end end
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.
Source
# File lib/git/object.rb, line 49 def contents_array self.contents.split("\n") end
Source
# File lib/git/object.rb, line 62 def diff(objectish) Git::Diff.new(@base, @objectish, objectish) end
Source
# File lib/git/object.rb, line 57 def grep(string, path_limiter = nil, opts = {}) opts = {:object => sha, :path_limiter => path_limiter}.merge(opts) @base.lib.grep(string, opts) end
Source
# File lib/git/object.rb, line 66 def log(count = 30) Git::Log.new(@base, count).object(@objectish) end
Source
# File lib/git/object.rb, line 27 def sha @sha ||= @base.lib.rev_parse(@objectish) end
Source
# File lib/git/object.rb, line 31 def size @size ||= @base.lib.cat_file_size(@objectish) end