Sha256: cf09b736242ea15224e697e2e61f579a28361ffebf82283290e7baf5bb9434e8

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

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

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

module Bonsai
  @@root_dir = nil
  @@config = { :enable_logging => true }

  class << self
    def root_dir
      @@root_dir || Dir.pwd
    end
  
    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 
    end
  
    def configure(&block)
      yield @@config
    end
    
    def version
      File.read("#{File.dirname(__FILE__)}/../VERSION")
    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 :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

2 entries across 2 versions & 1 rubygems

Version Path
bonsai-1.0.1 lib/bonsai.rb
bonsai-1.0.0 lib/bonsai.rb