Sha256: 967c434c534b04ab47bcdf9073361e9f96077b98d7457503a310325d62419645

Contents?: true

Size: 939 Bytes

Versions: 1

Compression:

Stored size: 939 Bytes

Contents

module  GitWakaTime
  class CommitedFile
    attr_reader :name, :dependent_commit, :git
    attr_accessor :time_in_seconds
    def initialize(args)
      @git = args[:git]
      @name = args[:name]
      @parent_commit = args[:parent_commit]
      @time_in_seconds = 0
      @find_dependent = args[:dependent] || true

      write_dependent_commit(name) if @find_dependent
    end

    def to_s
      format('    %-40s %-40s %-20s'.blue ,
             ChronicDuration.output(time_in_seconds.to_f),
             name,
             (dependent_commit.sha[0..8] if @dependent_commit)
             )
    end

    private

    def write_dependent_commit(name)
      commit = load_dependent_commit(name)
      @dependent_commit = Commit.new(@git, commit , false) if commit
    end

    def load_dependent_commit(name)
      @git.log(100).until(@parent_commit.date.to_s).object(name)[1]
    rescue Git::GitExecuteError
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitwakatime-0.0.1 lib/gitwakatime/commited_file.rb