Sha256: e603bb0dc29d85e23f80fb3debc9c860f49a68f948429fde8b092189f6ea9a88
Contents?: true
Size: 856 Bytes
Versions: 11
Compression:
Stored size: 856 Bytes
Contents
# -*- encoding : utf-8 -*- require 'git_stats/hash_initializable' module GitStats module GitData class Blob include HashInitializable attr_reader :repo, :sha, :filename def lines_count @lines_count ||= binary? ? 0 : repo.run("git cat-file blob #{self.sha} | wc -l").to_i end def content @content ||= repo.run("git cat-file blob #{self.sha}") end def extension @ext ||= File.extname(filename) end def binary? repo.run("git cat-file blob #{self.sha} | grep -m 1 '^'").force_encoding('ISO-8859-1').encode('utf-8', replace: nil) =~ /Binary file/ end def to_s "#{self.class} #@sha #@filename" end def ==(other) [self.repo, self.sha, self.filename] == [other.repo, other.sha, other.filename] end end end end
Version data entries
11 entries across 11 versions & 1 rubygems