Class: Mumukit::Sync::Store::Github::GuideExport

Inherits:
Operation
  • Object
show all
Defined in:
lib/mumukit/sync/store/github/guide_export.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Operation

#ensure_post_commit_hook!, #run!, #with_local_repo

Constructor Details

#initialize(options) ⇒ GuideExport

Returns a new instance of GuideExport.



6
7
8
9
10
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 6

def initialize(options)
  super(options)
  @guide_resource_h = options[:document]
  @author_email = options[:author_email]
end

Instance Attribute Details

#author_emailObject

Returns the value of attribute author_email.



4
5
6
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 4

def author_email
  @author_email
end

#botObject

Returns the value of attribute bot.



4
5
6
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 4

def bot
  @bot
end

#guide_resource_hObject

Returns the value of attribute guide_resource_h.



4
5
6
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 4

def guide_resource_h
  @guide_resource_h
end

Instance Method Details

#before_run_in_local_repoObject



20
21
22
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 20

def before_run_in_local_repo
  bot.ensure_exists! repo, guide_resource_h[:private]
end

#can_run?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 16

def can_run?
  bot.authenticated?
end

#repoObject



12
13
14
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 12

def repo
  @repo ||= Mumukit::Auth::Slug.parse(guide_resource_h[:slug])
end

#run_in_local_repo(dir, local_repo) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/mumukit/sync/store/github/guide_export.rb', line 24

def run_in_local_repo(dir, local_repo)
  clear_repo local_repo
  GuideWriter.new(dir, log).write_guide! guide_resource_h
  local_repo.add(all: true)
  local_repo.commit("Mumuki Export on #{Time.now}", commit_options)
  local_repo.push
rescue Git::GitExecuteError => e
  puts "Could not export guide #{guide_resource_h[:slug]} to git #{e}"
end