Sha256: 9a56a3978ba4d5f0159747b38cf034c46c4ee22fe5a10b5eb63faad085c03db5

Contents?: true

Size: 1.47 KB

Versions: 6

Compression:

Stored size: 1.47 KB

Contents

require 'rubygems'
require 'fileutils'
require 'logger'

$LOAD_PATH << "#{File.dirname(__FILE__)}/bonsai"

module Bonsai
  class << self
    attr_accessor :root_dir, :config
  
    def root_dir=(path)
      unless is_a_bonsai?(path)
        log "no bonsai site found - are you in the right directory?" 
        exit 0
      end
      
      @root_dir = path
      
      Exporter.path = "#{path}/output"
      Page.path = "#{path}/content"
      Template.path = "#{path}/templates"
    end
    
    def log(message)
      puts message if config[:enable_logging]
    end
  
    def config
      @config || { :enable_logging => true }
    end
    
    def version
      File.read("#{File.dirname(__FILE__)}/../VERSION")
    end
    
    def site
      YAML::load(File.read("#{Bonsai.root_dir}/site.yml")) || {}
    rescue ArgumentError
      Bonsai.log "Badly formatted site.yml"
    end
    
    private
    def is_a_bonsai?(path)
      File.directory?("#{path}/content") && File.directory?("#{path}/public") && File.directory?("#{path}/templates")
    end
  end
  
  autoload :Page,               "page"
  autoload :Console,            "console"
  autoload :Sitemap,            "sitemap"
  autoload :Exporter,           "exporter"
  autoload :Template,           "template"
  autoload :Generate,           "generate"
  autoload :Navigation,         "navigation"
  autoload :PagePresenter,      "page_presenter"
  autoload :StaticPassThrough,  "webserver"
  autoload :DevelopmentServer,  "webserver"
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bonsai-1.3.2 lib/bonsai.rb
bonsai-1.3.1 lib/bonsai.rb
bonsai-1.3.0 lib/bonsai.rb
bonsai-1.2.0 lib/bonsai.rb
bonsai-1.1.6 lib/bonsai.rb
bonsai-1.1.5 lib/bonsai.rb