class Courseware::Cache
Public Class Methods
new(config)
click to toggle source
# File lib/courseware/cache.rb, line 4 def initialize(config) @config = config unless @config[:nocache] clone update end end
Public Instance Methods
clear()
click to toggle source
# File lib/courseware/cache.rb, line 26 def clear FileUtils.rm_rf @config[:cachedir] end
clone()
click to toggle source
# File lib/courseware/cache.rb, line 13 def clone templates = File.join(@config[:cachedir], 'templates') FileUtils.mkdir_p(@config[:cachedir]) unless File.exists? @config[:cachedir] system('git', 'clone', @config[:templates], templates) unless File.exists? templates end
update()
click to toggle source
# File lib/courseware/cache.rb, line 20 def update $logger.debug "Updating template cache..." git('templates', 'pull', '--quiet', 'origin', 'master') git('templates', 'reset', '--quiet', '--hard', 'HEAD') end
Private Instance Methods
git(repo, *args)
click to toggle source
# File lib/courseware/cache.rb, line 31 def git(repo, *args) worktree = File.join(@config[:cachedir], repo) gitdir = File.join(worktree, '.git') system('git', '--git-dir', gitdir, '--work-tree', worktree, *args) end