Sha256: 00dc1aa8d54ab1d10a5ea6cbe683ebaa0f1a12a4cbd493af8e543f0d92b548f8
Contents?: true
Size: 1020 Bytes
Versions: 10
Compression:
Stored size: 1020 Bytes
Contents
require "pathname" require "forwardable" module Sitepress # Configures a site server, compiler, etc from a single configuration # file. Useful for static sites or anything that's running outside of # a framework like Rails. class Project # Default path of project configuration file. DEFAULT_CONFIG_FILE = "site.rb".freeze attr_reader :site def initialize(config_file: DEFAULT_CONFIG_FILE) @config_file = config_file end def compiler Compiler.new(site: site) end def server Server.new(site: site) end def site ConfigurationFile.new(path: @config_file).parse end end # Evaluates a configuration file to configure a site. class ConfigurationFile Context = Struct.new(:site) def initialize(path: Project::DEFAULT_CONFIG_FILE) @path = Pathname.new(path) end def parse(site: Sitepress::Site.new) site.tap do |s| Context.new(s).instance_eval File.read(@path), @path.to_s end end end end
Version data entries
10 entries across 10 versions & 1 rubygems