Class: Todidnt::GitHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/todidnt/git_history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitHistory

Returns a new instance of GitHistory.



6
7
8
9
10
# File 'lib/todidnt/git_history.rb', line 6

def initialize
  @history = []
  @blames = {}
  @unmatched_deletions = []
end

Instance Attribute Details

#blamesObject

Returns the value of attribute blames.



4
5
6
# File 'lib/todidnt/git_history.rb', line 4

def blames
  @blames
end

Instance Method Details

#timeline!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/todidnt/git_history.rb', line 12

def timeline!
  # TODO: It would probably be better/simpler to just Marshal the
  # GitHistory object itself.
  if Cache.exists?(:history)
    puts "Found cached history..."

    cache = Cache.load(:history)

    @history = cache.data[:history]
    @blames = cache.data[:blames]
    @unmatched_deletions = cache.data[:unmatched_deletions]

    last_commit = cache.data[:last_commit]
  end

  new_commit = analyze(last_commit)
  if new_commit != last_commit
    # If there's any new history, update the cache.
    to_cache = {
      last_commit: new_commit,
      history: @history,
      blames: @blames,
      unmatched_deletions: @unmatched_deletions
    }

    Cache.save(:history, to_cache)
  end

  if @unmatched_deletions.length > 0
    puts "Warning: there are some unmatched TODO deletions."
  end

  bucket
end