Class: RGitHook::PostReceivePack

Inherits:
Object
  • Object
show all
Defined in:
lib/rgithook/githook.rb

Overview

PostReceivePack es el pack que se recive al hacer un push Un mismo pack puede tener actualizacioens para diferentes branches

Instance Method Summary collapse

Constructor Details

#initialize(string = nil) ⇒ PostReceivePack

Returns a new instance of PostReceivePack.



6
7
8
9
10
11
12
# File 'lib/rgithook/githook.rb', line 6

def initialize(string = nil)
  string ||= STDIN.read
  @heads, @updates = string.split("\n"), []
  @heads.each { |head| @updates << RefUpdate.new(head) }
  require 'rubygems'
  require 'tmail'
end

Instance Method Details

#eachObject



34
35
36
# File 'lib/rgithook/githook.rb', line 34

def each
  @updates.each {|u| yield u}
end

#each_with_indexObject



38
39
40
# File 'lib/rgithook/githook.rb', line 38

def each_with_index 
  @updates.each_with_index {|u| yield u}
end

#mapObject



42
43
44
# File 'lib/rgithook/githook.rb', line 42

def map
  @updates.map {|u| yield u}
end

#refsObject

Returns an Array of Strings naming refs



29
30
31
# File 'lib/rgithook/githook.rb', line 29

def refs
  map {|update| update.ref}    
end

#sendmailObject



46
47
48
49
50
# File 'lib/rgithook/githook.rb', line 46

def sendmail
  each do |refupdate|
    refupdate.sendmail
  end
end

#to_htmlObject



14
15
16
# File 'lib/rgithook/githook.rb', line 14

def to_html
  "<div>\n#{map{|e|e.to_html}.join}\n</div>"
end

#to_sObject



18
19
20
21
22
23
24
25
26
# File 'lib/rgithook/githook.rb', line 18

def to_s
  text = "Se han recibido #{@heads.size} actualizaciones\n"
  each_with_index do |update,index| 
    text << format("Actualización %d\n", index+1)
    text << update.to_s
    text << format("\n")
  end
  text
end