class Weaver::Weave

Handles .weave file

Attributes

pages[RW]

Public Class Methods

new(file, options = {}) click to toggle source
# File lib/weaver/weave.rb, line 7
def initialize(file, options = {})
  @pages = {}
  @file = file
  @global_settings = options

  @global_settings[:root] = @global_settings[:root] || '/'
  unless @global_settings[:root].end_with? '/'
    @global_settings[:root] = "#{@global_settings[:root]}/"
  end
  instance_eval(File.read(file), file)
end
register_page_type(symbol, class_constant) click to toggle source
# File lib/weaver/weave.rb, line 31
def register_page_type(symbol, class_constant)
  define_method symbol,
                (proc do |path = '', title = nil, options = {}, &block|
                  if title.nil?
                    title = path
                    path = ''
                  end

                  p = class_constant.new(title, @global_settings, options,
                                         &block)
                  @pages[path] = p
                end)
end

Public Instance Methods

include(file) click to toggle source
# File lib/weaver/weave.rb, line 23
def include(file)
  dir = File.dirname(@file)
  filename = File.join([dir, file])
  File.read(filename)
  load filename
end
set_global(key, value) click to toggle source
# File lib/weaver/weave.rb, line 19
def set_global(key, value)
  @global_settings[key] = value
end