class Gash::Blob

A Blob represent a string:

blob = Gash::Blob.new(:content => "Some content")
blob # => "Some content"

Using SHA1

However, if you provide a SHA1 (and have a parent which is connected to a Gash-object) it will then load the content from the repo when needed:

blob = Gash::Blob.new(:sha1 => "1234" * 10, :parent => gash_OR_tree_connected_to_gash)
blob        # => #<Blob:1234123412341234123412341234123412341234>
blob.upcase # It's loaded when needed
#blob.load! # or forced with #load!
blob        # => "Content of the blob"

Tree#[]= automatically sets the parent to itself, so you don’t need to provide it then:

tree["FILE"] = Gash::Blob.new(:sha1 => a_sha1)

See also: Helpers, Tree

Attributes

content[RW]

Public Instance Methods

load!() click to toggle source

Loads the file from Git, unless it’s already been loaded.

# File lib/gash.rb, line 325
def load!
  @content ||= gash.send(:cat_file, @sha1)
end