class Middleman::Application

def self.cache

Returns:
  • (Middleman::Util::Cache) - The cache

Other tags:
    Private: -
def self.cache
  @_cache ||= ::Tilt::Cache.new
end

def self.helpers(*extensions, &block)

Returns:
  • (void) -
def self.helpers(*extensions, &block)
  class_eval(&block)   if block_given?
  include(*extensions) if extensions.any?
end

def self.root

Returns:
  • (String) -
def self.root
  ENV['MM_ROOT'] || Dir.pwd
end

def self.root_path

Pathname-addressed root
def self.root_path
  Pathname(root)
end

def _hooks

Middleman expects the same list of hooks for class and instance hooks:
https://github.com/apotonick/hooks/blob/master/lib/hooks/instance_hooks.rb#L10
Hooks clones _hooks from the class to the instance.
def _hooks
  self.class._hooks
end

def build?

Returns:
  • (Boolean) - If we're in build mode
def build?
  config[:environment] == :build
end

def development?

Returns:
  • (Boolean) - If we're in dev mode
def development?
  config[:environment] == :development
end

def initialize(&block)

Initialize the Middleman project
def initialize(&block)
  # Clear the static class cache
  cache.clear
  # Setup the default values from calls to set before initialization
  self.class.config.load_settings(self.class.superclass.config.all_settings)
  if Object.const_defined?(:Encoding)
    Encoding.default_internal = config[:encoding]
    Encoding.default_external = config[:encoding]
  end
  # Evaluate a passed block if given
  instance_exec(&block) if block_given?
  config[:source] = ENV['MM_SOURCE'] if ENV['MM_SOURCE']
  super
end

def logger

Reference to Logger singleton
def logger
  ::Middleman::Logger.singleton
end

def source_dir

Returns:
  • (String) -
def source_dir
  File.join(root, config[:source])
end

def to_s

if the object is huge or has cyclic references, like this.
messages, which can take a long time (minutes at full CPU)
where Ruby will call to_s/inspect while printing exception
Work around this bug: http://bugs.ruby-lang.org/issues/4521
def to_s
  "#<Middleman::Application:0x#{object_id}>"
end