Sha256: 612fa34671336ee9284bd3ca9380feebe128efcb6ac955439d92105659b4a0d4

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 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({})

      @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

13 entries across 13 versions & 1 rubygems

Version Path
awestruct-0.1.8 lib/awestruct/site.rb
awestruct-0.1.7 lib/awestruct/site.rb
awestruct-0.1.6 lib/awestruct/site.rb
awestruct-0.1.5 lib/awestruct/site.rb
awestruct-0.1.4 lib/awestruct/site.rb
awestruct-0.1.3 lib/awestruct/site.rb
awestruct-0.1.2 lib/awestruct/site.rb
awestruct-0.1.1 lib/awestruct/site.rb
awestruct-0.1.0 lib/awestruct/site.rb
awestruct-0.0.9 lib/awestruct/site.rb
awestruct-0.0.8 lib/awestruct/site.rb
awestruct-0.0.6 lib/awestruct/site.rb
awestruct-0.0.5 lib/awestruct/site.rb