Class: Courseware::Cache
- Inherits:
-
Object
- Object
- Courseware::Cache
- Defined in:
- lib/courseware/cache.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #clone ⇒ Object
-
#initialize(config) ⇒ Cache
constructor
A new instance of Cache.
- #update ⇒ Object
Constructor Details
#initialize(config) ⇒ Cache
Returns a new instance of Cache.
4 5 6 7 8 9 10 11 |
# File 'lib/courseware/cache.rb', line 4 def initialize(config) @config = config unless @config[:nocache] clone update end end |
Instance Method Details
#clear ⇒ Object
26 27 28 |
# File 'lib/courseware/cache.rb', line 26 def clear FileUtils.rm_rf @config[:cachedir] end |
#clone ⇒ Object
13 14 15 16 17 18 |
# 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 ⇒ Object
20 21 22 23 24 |
# 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 |