class WaxTasks::Config

Attributes

collections[R]

Public Class Methods

new(config) click to toggle source
# File lib/wax_tasks/config.rb, line 8
def initialize(config)
  @config         = config
  @collections    = process_collections
end

Public Instance Methods

collections_dir() click to toggle source
# File lib/wax_tasks/config.rb, line 25
def collections_dir
  @config.dig 'collections_dir'
end
ext() click to toggle source

Contructs permalink extension from site `permalink` variable

@return [String] the end of the permalink, either '/' or '.html'

# File lib/wax_tasks/config.rb, line 33
def ext
  case @config.dig 'permalink'
  when 'pretty' || '/'
    '/'
  else
    '.html'
  end
end
find_collection(name) click to toggle source
# File lib/wax_tasks/config.rb, line 72
def find_collection(name)
  collection = @collections.find { |c| c.name == name }
  raise WaxTasks::Error::InvalidCollection, "Cannot find requested collection '#{name}'" if collection.nil?

  collection
end
process_collections() click to toggle source
# File lib/wax_tasks/config.rb, line 44
def process_collections
  if @config.key? 'collections'
    @config['collections'].map do |k, v|
      WaxTasks::Collection.new(k, v, source, collections_dir, ext)
    end
  else
    []
  end
end
self() click to toggle source
# File lib/wax_tasks/config.rb, line 13
def self
  @config
end
source() click to toggle source
# File lib/wax_tasks/config.rb, line 19
def source
  @config.dig 'source'
end