# 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
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
Compares blobs by name
# File lib/grit/blob.rb, line 121 def <=>(other) name <=> other.name end
# File lib/grit/blob.rb, line 111 def basename File.basename(name) end
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
# File lib/grit_ext/blob.rb, line 11 def data GritExt.encode! old_data end
Pretty object inspection
# File lib/grit/blob.rb, line 116 def inspect %Q{#<Grit::Blob "#{@id}">} end
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
# File lib/grit_ext/blob.rb, line 7 def name GritExt.encode! old_name end
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