Class: Daun::RefsDiff
- Inherits:
-
Object
- Object
- Daun::RefsDiff
- Defined in:
- lib/daun/refs_diff.rb
Overview
Produce git refs differences before and after fetch
Instance Attribute Summary collapse
-
#added_remotes ⇒ Object
Returns the value of attribute added_remotes.
Instance Method Summary collapse
-
#added(type = nil) ⇒ Object
Returns all of the refs that have been added after the fetch.
-
#deleted(type = nil) ⇒ Object
Returns all of the refs that have been deleted after the fetch.
-
#initialize(before, after) ⇒ RefsDiff
constructor
Creates a new instance of
RefsDiff. -
#updated(type = nil) ⇒ Object
Returns all of the refs that have been updated after the fetch.
Constructor Details
#initialize(before, after) ⇒ RefsDiff
Creates a new instance of RefsDiff.
11 12 13 14 |
# File 'lib/daun/refs_diff.rb', line 11 def initialize(before, after) @before = before @after = after end |
Instance Attribute Details
#added_remotes ⇒ Object
Returns the value of attribute added_remotes.
5 6 7 |
# File 'lib/daun/refs_diff.rb', line 5 def added_remotes @added_remotes end |
Instance Method Details
#added(type = nil) ⇒ Object
Returns all of the refs that have been added after the fetch. These are the refs
that exists in after but not before.
20 21 22 23 |
# File 'lib/daun/refs_diff.rb', line 20 def added(type = nil) keys = (@after.keys - @before.keys).collect(&:to_s) filter(keys, type) end |
#deleted(type = nil) ⇒ Object
Returns all of the refs that have been deleted after the fetch. These are the
refs that exists in before but not after
42 43 44 45 |
# File 'lib/daun/refs_diff.rb', line 42 def deleted(type = nil) keys = (@before.keys - @after.keys).collect(&:to_s) filter(keys, type) end |
#updated(type = nil) ⇒ Object
Returns all of the refs that have been updated after the fetch. Updated refs
are detected when refs exists in both before and after but is having a
different commit id in the Hash.
30 31 32 33 34 35 36 |
# File 'lib/daun/refs_diff.rb', line 30 def updated(type = nil) keys = (@after.keys + @before.keys) .group_by { |k| k } .select { |k, k_group| k_group.size > 1 && @before[k] != @after[k] } .keys.collect(&:to_s) filter(keys, type) end |