class Mumukit::Sync::Store::Github::Operation

Attributes

bot[RW]

Public Class Methods

new(options) click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 5
def initialize(options)
  @bot = options[:bot]
  @web_hook_base_url = options[:web_hook_base_url]
end

Public Instance Methods

before_run_in_local_repo() click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 41
def before_run_in_local_repo
end
can_run?() click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 16
def can_run?
  true
end
ensure_post_commit_hook!() click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 37
def ensure_post_commit_hook!
  bot.register_post_commit_hook!(repo, @web_hook_base_url) if bot.authenticated? && @web_hook_base_url
end
run!() click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 20
def run!
  return unless can_run?

  puts "#{self.class.name} : running before run hook for repository #{repo}"
  before_run_in_local_repo

  result = nil
  with_local_repo do |dir, local_repo|
    puts "#{self.class.name} : running run hook for repository #{repo}"
    result = run_in_local_repo dir, local_repo
  end

  puts "#{self.class.name} : running after run hook repository #{repo}"
  ensure_post_commit_hook!
  result
end
run_in_local_repo(dir, local_repo) click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 44
def run_in_local_repo(dir, local_repo)
end
with_local_repo(&block) click to toggle source
# File lib/mumukit/sync/store/github/operation.rb, line 10
def with_local_repo(&block)
  Dir.mktmpdir("mumuki.#{self.class.name}") do |dir|
    bot.clone_into repo, dir, &block
  end
end