Sha256: a4825426c3cce62faf674ee05c0fdb7a2598d9619b627511a0d1a1993e13d064

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require 'ostruct'

module Awestruct
  class Site < OpenStruct

    attr_reader :dir
    attr_reader :output_dir

    attr_reader   :layouts
    attr_accessor :pages

    def initialize(dir)
      super({ :base_url=>'http://localhost:4242' })

      @dir = dir
      @output_dir = File.join( dir, '_site' )

      @pages   = []
      @layouts = {}
    end

    def has_page?(path)
      ! pages.find{|e| e.path == path}.nil?
    end

    def output_path(path, ext=nil)
      path = File.join( @output_dir, path[ @dir.size..-1] )
      unless ( ext.nil? )
        path = File.join( File.dirname( path ), File.basename( path, ext ) )
      end
      path 
    end

    def url_path(path, ext=nil)
      url_path = output_path( path, ext )[ @output_dir.size .. -1 ]
    end

    def apply_plugins
      Dir[ File.join( @dir, '_plugins', '*.rb' ) ].each do |rb_path|
        site_root = @dir
        output_root = @output_dir
        begin
          eval File.read( rb_path )
        rescue => e
          puts e
          puts e.backtrace
        end
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
awestruct-0.0.4 lib/awestruct/site.rb
awestruct-0.0.3 lib/awestruct/site.rb
awestruct-0.0.2 lib/awestruct/site.rb
awestruct-0.0.1 lib/awestruct/site.rb