Class: Rtfd::GithubHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/rtfd/github_handler.rb

Instance Method Summary collapse

Instance Method Details

#clone(repo) ⇒ Object



23
24
25
26
# File 'lib/rtfd/github_handler.rb', line 23

def clone repo
  $stdout.puts "Clonning #{repo.first}"
  system "cd #{Rtfd.repos_path}; rm -rf #{repo.first}; git clone #{repo[1]}; cd #{repo.first}; yard doc;"
end

#handle(params) ⇒ Object



3
4
5
6
7
8
# File 'lib/rtfd/github_handler.rb', line 3

def handle params
  payload = JSON.parse(params[:payload])
  $stdout.puts "I got some JSON from github: #{payload.inspect}"
  repo = Rtfd.repos.find{|repo| repo.first==payload['repository']['name'] and 'refs/heads/master'==payload['ref']}
  update repo, payload if repo
end

#pull(repo) ⇒ Object



18
19
20
21
# File 'lib/rtfd/github_handler.rb', line 18

def pull repo
  $stdout.puts "Pulling #{repo.first}"
  system "cd #{Rtfd.repos_path}/#{repo.first}; git pull; yard doc;"
end

#update(repo, payload) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rtfd/github_handler.rb', line 10

def update repo, payload
  if payload['forced'] or !Dir.exist?("#{Rtfd.repos_path}/#{repo.first}")
    clone repo
  else
    pull repo
  end
end