Sha256: edd2ad78c8066b185cc3f79433bf86bd5787c5cde179d2810c04232ce98554ad

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

require 'noumenon/configuration'
require 'noumenon/template'
require 'noumenon/core'

module Noumenon
  class TemplateNotFoundError < StandardError; end
  
  class << self
    # Returns a configured Noumenon application. Intended for use in a Rack configuration:
    #
    # Example:
    #
    #   require 'noumenon'
    #   Noumenon::Core.set :content_repository_path, "/srv/sites/example.org"
    #
    #   run Noumenon.boot
    def boot
      Rack::Builder.new do
        Dir.glob(File.join(Noumenon.config.dependencies_path, "themes/*/assets")).each do |path|
          theme = path.split("/")[-2]
          url = "/themes/#{theme}"
          
          map(url) { run Rack::File.new(path) }
        end
        
        map("/") { run Core.new }
      end
    end
    
    # Provides access to the configuration of this application.
    #
    # If passed a block then the current configuration will be yielded in the form
    # of a Noumenon::Configuration instance, allowing it to be changed.
    #
    #     Noumenon.config do |c|
    #       c.theme = "example_theme"
    #     end
    #
    def config
      @config ||= Configuration.new
      yield @config if block_given?
      @config
    end
    alias :configure :config
    
    # Set the application configuration
    #
    # Should be provided with something that implements the same interface as Noumenon::Configuration.
    def config=(config)
      @config = config
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
noumenon-0.0.2 lib/noumenon.rb
noumenon-0.0.1 lib/noumenon.rb