class Grit::Blob

Constants

DEFAULT_MIME_TYPE

Attributes

id[R]
mode[R]

Public Class Methods

blame(repo, commit, file) click to toggle source
# File lib/grit_ext/blob.rb, line 18
def blame(repo, commit, file)
  old_blame(repo, commit, file).map do |b,lines|
    [b, GritExt.encode!(lines.join('\n')).split('\n')]
  end
end
Also aliased as: old_blame
create(repo, atts) click to toggle source

Create an unbaked Blob containing just the specified attributes

+repo+ is the Repo
+atts+ is a Hash of instance variable data

Returns Grit::Blob (unbaked)

# File lib/grit/blob.rb, line 15
def self.create(repo, atts)
  self.allocate.create_initialize(repo, atts)
end
old_blame(repo, commit, file) click to toggle source
Alias for: blame

Public Instance Methods

<=>(other) click to toggle source

Compares blobs by name

# File lib/grit/blob.rb, line 121
def <=>(other)
  name <=> other.name
end
basename() click to toggle source
# File lib/grit/blob.rb, line 111
def basename
  File.basename(name)
end
create_initialize(repo, atts) click to toggle source

Initializer for ::create

+repo+ is the Repo
+atts+ is a Hash of instance variable data

Returns Grit::Blob (unbaked)

# File lib/grit/blob.rb, line 24
def create_initialize(repo, atts)
  @repo = repo
  atts.each do |k, v|
    instance_variable_set("@#{k}".to_sym, v)
  end
  self
end
data() click to toggle source
# File lib/grit_ext/blob.rb, line 11
def data
  GritExt.encode! old_data
end
Also aliased as: old_data
inspect() click to toggle source

Pretty object inspection

# File lib/grit/blob.rb, line 116
def inspect
  %Q{#<Grit::Blob "#{@id}">}
end
mime_type() click to toggle source

The mime type of this file (based on the filename)

Returns String

# File lib/grit/blob.rb, line 49
def mime_type
  guesses = MIME::Types.type_for(self.name) rescue []
  guesses.first ? guesses.first.simplified : DEFAULT_MIME_TYPE
end
name() click to toggle source
# File lib/grit_ext/blob.rb, line 7
def name
  GritExt.encode! old_name
end
Also aliased as: old_name
old_data() click to toggle source
Alias for: data
old_name() click to toggle source
Alias for: name
size() click to toggle source

The size of this blob in bytes

Returns Integer

# File lib/grit/blob.rb, line 35
def size
  @size ||= @repo.git.cat_file({:s => true}, id).chomp.to_i
end