Class: Tester::Checker

Inherits:
Object
  • Object
show all
Defined in:
lib/tester/checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch) ⇒ Checker

Returns a new instance of Checker.



6
7
8
# File 'lib/tester/checker.rb', line 6

def initialize(branch)
  @branch = branch
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



3
4
5
# File 'lib/tester/checker.rb', line 3

def branch
  @branch
end

#last_hashObject

Returns the value of attribute last_hash.



4
5
6
# File 'lib/tester/checker.rb', line 4

def last_hash
  @last_hash
end

Instance Method Details

#headObject



23
24
25
# File 'lib/tester/checker.rb', line 23

def head
  `git rev-parse origin/#{branch}`.chomp
end

#if_updated(&block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/tester/checker.rb', line 10

def if_updated(&block)
  update
  hash = head
  if KVS['HEAD'] != hash
    block.call(hash)
    KVS['HEAD'] = self.last_hash = hash
  end
end

#updateObject



19
20
21
# File 'lib/tester/checker.rb', line 19

def update
  `git fetch origin && git reset --hard origin/#{branch}`
end