class Mumukit::Sync::Store::Github::GuideExport

Attributes

author_email[RW]
bot[RW]
guide_resource_h[RW]

Public Class Methods

new(options) click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 7
def initialize(options)
  super(options)
  @guide_resource_h = options[:document]
  @author_email = options[:author_email]
end

Public Instance Methods

before_run_in_local_repo() click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 21
def before_run_in_local_repo
  bot.ensure_exists! repo, guide_resource_h[:private]
end
can_run?() click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 17
def can_run?
  bot.authenticated?
end
repo() click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 13
def repo
  @repo ||= Mumukit::Auth::Slug.parse(guide_resource_h[:slug])
end
run_in_local_repo(dir, local_repo) click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 25
def run_in_local_repo(dir, local_repo)
  clear_repo local_repo
  GuideWriter.new(dir).write_guide! guide_resource_h
  local_repo.add(all: true)
  local_repo.commit("Mumuki Export on #{Time.now}", commit_options)
  local_repo.push
rescue StandardError => e
  puts "Could not export guide #{guide_resource_h[:slug]} to git #{e}"
end

Private Instance Methods

clear_repo(local_repo) click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 42
def clear_repo(local_repo)
  local_repo.remove guide_schema.file_patterns
rescue Git::GitExecuteError => e
  puts 'Nothing to clean, repo seems to be empty'
end
commit_options() click to toggle source
# File lib/mumukit/sync/store/github/guide_export.rb, line 38
def commit_options
  author_email.present? ? {author: "#{author_email} <#{author_email}>"} : {}
end