Class: MakeArchive
- Inherits:
-
Jekyll::Generator
- Object
- Jekyll::Generator
- MakeArchive
- Defined in:
- make_archive.rb
Overview
Makes tar or zip file based on _config.yml entry
Instance Method Summary collapse
-
#generate(site) ⇒ void
Method prescribed by the Jekyll plugin lifecycle.
-
#initialize(config) ⇒ MakeArchive
constructor
A new instance of MakeArchive.
Constructor Details
#initialize(config) ⇒ MakeArchive
Returns a new instance of MakeArchive.
18 19 20 21 |
# File 'make_archive.rb', line 18 def initialize(config) super(config) @log = LoggerFactory.new.create_logger('make_archive', config, :warn, $stderr) end |
Instance Method Details
#generate(site) ⇒ void
This method returns an undefined value.
Method prescribed by the Jekyll plugin lifecycle.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'make_archive.rb', line 26 def generate(site) @live_reload = site.config['livereload'] archive_config = site.config['make_archive'] return if archive_config.nil? archive_config.each do |config| @archive_name = config['archive_name'] # Relative to _site abort 'Error: archive_name was not specified in _config.yml.' if @archive_name.nil? if @archive_name.end_with? '.zip' @archive_type = :zip elsif @archive_name.end_with? '.tar' @archive_type = :tar else abort "Error: archive must be zip or tar; #{@archive_name} is of an unknown archive type." end @archive_files = config['files'].compact abort 'Error: archive files were not specified in _config.yml.' if @archive_files.nil? delete_archive = config['delete'] @force_delete = delete_archive.nil? ? !@live_reload : delete_archive @log.info "@archive_name=#{@archive_name}; @live_reload=#{@live_reload}; @force_delete=#{@force_delete}; @archive_files=#{@archive_files}" doit site.source site.keep_files << @archive_name end end |