Sha256: 611ce1a7e7e4e29def730bf5a5306c5e7a6806279c7ad276f4608049a5da6ef7
Contents?: true
Size: 655 Bytes
Versions: 3
Compression:
Stored size: 655 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 => e 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
git_local-0.0.4 | lib/git_local/object.rb |
git_local-0.0.3 | lib/git_local/object.rb |
git_local-0.0.2 | lib/git_local/object.rb |