class Linguist::FileBlob
‘data`, `path` and `size`.
like a Grit::Blob. It provides the basic interface: `name`,
A FileBlob is a wrapper around a File object to make it quack
def data
Public: Read file contents.
def data @data ||= File.read(@fullpath, :encoding => "ASCII-8BIT") end
def initialize(path, base_path = nil)
base_path - Optional base to relativize the path
path - A path String that exists on the file system.
Public: Initialize a new FileBlob from a path
def initialize(path, base_path = nil) @fullpath = path @path = base_path ? path.sub("#{base_path}/", '') : path end
def mode
Public: Read file permissions
def mode @mode ||= File.stat(@fullpath).mode.to_s(8) end
def size
Public: Get byte size
def size @size ||= File.size(@fullpath) end
def symlink?
def symlink? return @symlink if defined? @symlink @symlink = (File.symlink?(@fullpath) rescue false) end