Sha256: 465da82841fe8ab5f56d1670c6c71f1aab825a18e4410bc08631345995a5dc70
Contents?: true
Size: 650 Bytes
Versions: 5
Compression:
Stored size: 650 Bytes
Contents
module GitLocal class Object attr_reader :path class NotFound < StandardError end def initialize(path) @path = path end def name path.rindex("/") ? path[path.rindex("/") + 1..-1] : path end def read(max_lines = nil) return contents if max_lines.nil? File.foreach(path).first(max_lines).join rescue StandardError raise NotFound end def sha Digest::SHA1.hexdigest("blob " + contents.length.to_s + "\0" + contents) end def size File.size(path).to_f / 2**20 end private def contents @contents ||= File.read(path) end end end
Version data entries
5 entries across 5 versions & 1 rubygems