class SameBoat::Crew
Public Class Methods
new(file_path)
click to toggle source
# File lib/same_boat/crew.rb, line 3 def initialize(file_path) @file_path = file_path end
Private Class Methods
git?()
click to toggle source
# File lib/same_boat/crew.rb, line 30 def git? @_git ||= !!`which git` end
Public Instance Methods
name()
click to toggle source
# File lib/same_boat/crew.rb, line 11 def name @file_path end
present()
click to toggle source
# File lib/same_boat/crew.rb, line 7 def present git? ? git_commit_hash : file_hash end
Private Instance Methods
file_hash()
click to toggle source
# File lib/same_boat/crew.rb, line 21 def file_hash Digest::MD5.hexdigest(File.read(@file_path, 2**7)) end
git?()
click to toggle source
# File lib/same_boat/crew.rb, line 25 def git? self.class.git? end
git_commit_hash()
click to toggle source
# File lib/same_boat/crew.rb, line 17 def git_commit_hash `git log #{@file_path} | head -n 1 | cut -d ' ' -f2` end