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
search(name)
click to toggle source
# File lib/wax_tasks/config.rb, line 56 def search(name) search_config = @config.dig 'search', name raise WaxTasks::Error::InvalidConfig if search_config.nil? raise WaxTasks::Error::InvalidConfig unless search_config.dig('collections').is_a? Hash search_config['collections'] = search_config['collections'].map do |k, v| fields = v.fetch('fields', []) fields << 'content' if v.fetch('content', false) find_collection(k).tap { |c| c.search_fields = fields } end search_config 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