Module: Wildcloud::Git::Protocol

Includes:
EventMachine::Protocols::LineText2
Defined in:
lib/wildcloud/git/protocol.rb

Instance Method Summary collapse

Instance Method Details

#handle_auth(data) ⇒ Object



35
36
37
38
39
# File 'lib/wildcloud/git/protocol.rb', line 35

def handle_auth(data)
  username, repository, action = data.split("|", 3)
  send_data(@core.authorize(username, repository, action))
  close_connection_after_writing
end

#handle_push(data) ⇒ Object



41
42
43
44
# File 'lib/wildcloud/git/protocol.rb', line 41

def handle_push(data)
  user, commit, ref, repository = data.split("|", 4)
  @core.publish({ :type => 'push', :user => user, :commit => commit, :ref => ref, :repository => repository })
end

#initialize(core) ⇒ Object



21
22
23
# File 'lib/wildcloud/git/protocol.rb', line 21

def initialize(core)
  @core = core
end

#receive_line(data) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/wildcloud/git/protocol.rb', line 25

def receive_line(data)
  type, data = data.split("|", 2)
  method = "handle_#{type}".to_sym
  if respond_to?(method)
    send(method, data)
  else
    close_connection
  end
end