Parent

Files

StaticMatic::Base

Attributes

configuration[RW]
current_page[R]
site_dir[R]
src_dir[R]

Public Class Methods

new(base_dir, configuration = Configuration.new) click to toggle source
# File lib/staticmatic/base.rb, line 18
def initialize(base_dir, configuration = Configuration.new)
  @configuration = configuration
  @current_page = nil
  @current_file_stack = []
  @base_dir = base_dir
  @src_dir = File.join(@base_dir, "src")
  @site_dir = File.join(@base_dir, "site")
  
  if File.exists?(File.join(@src_dir, "layouts", "application.haml"))
    puts "DEPRECATION: layouts/application.haml will be renamed to layouts/default.haml in 0.12.0"
    @default_layout = "application"
  else
    @default_layout = "default"
  end
  
  @scope = Object.new
  @scope.instance_variable_set("@staticmatic", self)
  
  load_configuration      
  configure_compass

  load_helpers
end

Public Instance Methods

base_dir() click to toggle source
# File lib/staticmatic/base.rb, line 63
def base_dir
  @base_dir
end
configure_compass() click to toggle source
# File lib/staticmatic/base.rb, line 94
def configure_compass
  Compass.configuration.project_path = @base_dir 

  compass_config_path = File.join(@base_dir, "config", "compass.rb")
  
  if File.exists?(compass_config_path)
    Compass.add_configuration(compass_config_path)         
  end

  configuration.sass_options.merge!(Compass.configuration.to_sass_engine_options)
end
current_file() click to toggle source
# File lib/staticmatic/base.rb, line 14
def current_file
  @current_file_stack[0] || ""
end
full_layout_path(name) click to toggle source
# File lib/staticmatic/base.rb, line 90
def full_layout_path(name)
  File.join(@src_dir, "layouts", "#{name}.haml")
end
layout_exists?(name) click to toggle source
# File lib/staticmatic/base.rb, line 82
def layout_exists?(name)
  File.exists? full_layout_path(name)
end
load_configuration() click to toggle source
# File lib/staticmatic/base.rb, line 42
def load_configuration
  configuration = StaticMatic::Configuration.new
  config_file = File.join(@base_dir, "config", "site.rb")

  if !File.exists?(config_file)
    config_file = File.join(@base_dir, "src", "configuration.rb")

    if File.exists?(config_file)
      puts "DEPRECATION: #{@base_dir}/src/configuration.rb will be moved to #{@base_dir}/config/site.rb in 0.12.0"
    end
  end
  
  if File.exists?(config_file)
    config = File.read(config_file)
    eval(config)
  end

  # Compass.sass_engine_options.merge!(configuration.sass_options)
  @configuration = configuration
end
run(command) click to toggle source
# File lib/staticmatic/base.rb, line 67
def run(command)
  puts "Site root is: #{@base_dir}"
  
  if %(build setup preview).include?(command)
    send(command)
  else
    puts "#{command} is not a valid StaticMatic command"
  end
end
template_directory?(path) click to toggle source
# File lib/staticmatic/base.rb, line 86
def template_directory?(path)
  File.directory?(File.join(@src_dir, 'pages', path))
end
template_exists?(name, dir = '') click to toggle source

TODO: DRY this _exists? section up

# File lib/staticmatic/base.rb, line 78
def template_exists?(name, dir = '')
  File.exists?(File.join(@src_dir, 'pages', dir, "#{name}.haml")) || File.exists?(File.join(@src_dir, 'stylesheets', "#{name}.sass")) || File.exists?(File.join(@src_dir, 'stylesheets', "#{name}.scss"))
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.