Class: GitStats::GitData::Blob
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Inspector
#inspect, #pretty_print, #to_s
#initialize
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
12
13
14
|
# File 'lib/git_stats/git_data/blob.rb', line 12
def filename
@filename
end
|
#repo ⇒ Object
Returns the value of attribute repo.
12
13
14
|
# File 'lib/git_stats/git_data/blob.rb', line 12
def repo
@repo
end
|
#sha ⇒ Object
Returns the value of attribute sha.
12
13
14
|
# File 'lib/git_stats/git_data/blob.rb', line 12
def sha
@sha
end
|
Instance Method Details
#==(other) ⇒ Object
32
33
34
|
# File 'lib/git_stats/git_data/blob.rb', line 32
def ==(other)
[repo, sha, filename] == [other.repo, other.sha, other.filename]
end
|
#binary? ⇒ Boolean
26
27
28
29
30
|
# File 'lib/git_stats/git_data/blob.rb', line 26
def binary?
repo.run("git cat-file blob #{sha} | grep -m 1 '^'").dup
.force_encoding('ISO-8859-1').encode('utf-8', replace: nil)
.include?('Binary file')
end
|
#content ⇒ Object
18
19
20
|
# File 'lib/git_stats/git_data/blob.rb', line 18
def content
@content ||= repo.run("git cat-file blob #{sha}")
end
|
#extension ⇒ Object
22
23
24
|
# File 'lib/git_stats/git_data/blob.rb', line 22
def extension
@extension ||= File.extname(filename)
end
|
#lines_count ⇒ Object
14
15
16
|
# File 'lib/git_stats/git_data/blob.rb', line 14
def lines_count
@lines_count ||= binary? ? 0 : repo.run("git cat-file blob #{sha} | wc -l").to_i
end
|