Class: Jekyll::Copyr::Copier

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-copyr/copier.rb

Constant Summary collapse

DEFAULTS =
{ "enabled" => true, "tasks" => [] }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Copier

Returns a new instance of Copier.



10
11
12
13
14
15
16
17
18
19
20
# 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

Instance Method Details

#process_post_writeObject



22
23
24
25
26
# File 'lib/jekyll-copyr/copier.rb', line 22

def process_post_write
  return unless @enabled == true

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