class JekyllBuildEbook::Config

Constants

DEFAULTS
REQUIRED_FIELDS

Attributes

data[R]

Public Class Methods

new(site_config) click to toggle source
# File lib/jekyll-build-ebook/config.rb, line 14
def initialize(site_config)
  @data = {
    'file_name'  => site_config['title'],
    'identifier' => site_config['url'].nil? ? SecureRandom.uuid : "#{site_config['url']}#{site_config['base_url']}",
    'title'      => site_config['title'],
    'language'   => site_config['language'] || site_config['lang'],
    'creator'    => case site_config['author']
                    when String
                      site_config['author']
                    when Hash
                      site_config['author']['name']
                    else
                      nil
                    end,
  }.merge(site_config['ebook'])

  REQUIRED_FIELDS.each do |field|
    raise InvalidConfigError, "#{field} is required" if data[field].nil?
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/jekyll-build-ebook/config.rb, line 35
def [](key)
  data[key]
end
destination_path(ext: 'epub') click to toggle source
# File lib/jekyll-build-ebook/config.rb, line 39
def destination_path(ext: 'epub')
  "#{File.join(data['destination'], data['file_name'])}.#{ext}"
end