Class: Tester::Checker
- Inherits:
-
Object
- Object
- Tester::Checker
- Defined in:
- lib/tester/checker.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#last_hash ⇒ Object
Returns the value of attribute last_hash.
Instance Method Summary collapse
- #head ⇒ Object
- #if_updated(&block) ⇒ Object
-
#initialize(branch) ⇒ Checker
constructor
A new instance of Checker.
- #update ⇒ Object
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
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
3 4 5 |
# File 'lib/tester/checker.rb', line 3 def branch @branch end |
#last_hash ⇒ Object
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
#head ⇒ Object
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 |
#update ⇒ Object
19 20 21 |
# File 'lib/tester/checker.rb', line 19 def update `git fetch origin && git reset --hard origin/#{branch}` end |