Class: RGitHook::PostReceivePack
- Inherits:
-
Object
- Object
- RGitHook::PostReceivePack
- 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
- #each ⇒ Object
- #each_with_index ⇒ Object
-
#initialize(string = nil) ⇒ PostReceivePack
constructor
A new instance of PostReceivePack.
- #map ⇒ Object
-
#refs ⇒ Object
Returns an Array of Strings naming refs.
- #sendmail ⇒ Object
- #to_html ⇒ Object
- #to_s ⇒ Object
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
#each ⇒ Object
34 35 36 |
# File 'lib/rgithook/githook.rb', line 34 def each @updates.each {|u| yield u} end |
#each_with_index ⇒ Object
38 39 40 |
# File 'lib/rgithook/githook.rb', line 38 def each_with_index @updates.each_with_index {|u| yield u} end |
#map ⇒ Object
42 43 44 |
# File 'lib/rgithook/githook.rb', line 42 def map @updates.map {|u| yield u} end |
#refs ⇒ Object
Returns an Array of Strings naming refs
29 30 31 |
# File 'lib/rgithook/githook.rb', line 29 def refs map {|update| update.ref} end |
#sendmail ⇒ Object
46 47 48 49 50 |
# File 'lib/rgithook/githook.rb', line 46 def sendmail each do |refupdate| refupdate.sendmail end end |
#to_html ⇒ Object
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_s ⇒ Object
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 |