class Jekyll::Copyr::Copier

Constants

DEFAULTS

Public Class Methods

new(config = {}) click to toggle source
# File lib/jekyll-copyr/copier.rb, line 10
def initialize(config = {})
  if config.is_a?(Hash)
    @config = Utils.deep_merge_hashes DEFAULTS, config
  else
    @config = nil
    Jekyll.logger.warn "Copyr:", "Expected a hash but got #{config.inspect}"
    Jekyll.logger.warn "", "Files will not be copied for this site."
  end
  @enabled = @config["enabled"]
  @tasks = @config["tasks"].map { |task_hash| Task.new task_hash }
end

Public Instance Methods

process_post_write() click to toggle source
# File lib/jekyll-copyr/copier.rb, line 22
def process_post_write
  return unless @enabled == true

  @tasks.each { |task| process task }
end

Private Instance Methods

process(task) click to toggle source
# File lib/jekyll-copyr/copier.rb, line 30
def process(task)
  FileUtils.mkdir_p task.to
  FileUtils.cp_r task.from, task.to
end