Class: Swoop::TimeMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/swoop/time_machine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, options) ⇒ TimeMachine

Returns a new instance of TimeMachine.



9
10
11
12
13
14
# File 'lib/swoop/time_machine.rb', line 9

def initialize(project, options)
  @project = project
  @tags = options[:tags] || 8
  @weeks = options[:weeks] || 0
  @filter = options[:filter]
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/swoop/time_machine.rb', line 7

def project
  @project
end

Instance Method Details

#project_pathObject



16
17
18
# File 'lib/swoop/time_machine.rb', line 16

def project_path
  @project_path ||= @project.path
end

#travel {|project, current_branch, Time.now| ... } ⇒ Object

Yields:

  • (project, current_branch, Time.now)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/swoop/time_machine.rb', line 20

def travel
  current_branch = git.current_branch

  logs.each do |t|
    log = t.log.first
    git.checkout(log.sha)
    yield(project, t.name, log.date)
  end

  git.branches[current_branch].checkout
  yield(project, current_branch, Time.now)
end