class Middleman::Application
def self.cache
-
(Middleman::Util::Cache)
- The cache
Other tags:
- Private: -
def self.cache @_cache ||= ::Middleman::Util::Cache.new end
def build?; environment == :build; end
-
(Boolean)
- If we're in build mode
def build?; environment == :build; end
def defaults
-
(Hash)
- Hash of default values
Other tags:
- Private: -
def defaults @defaults ||= {} end
def development?; environment == :development; end
-
(Boolean)
- If we're in dev mode
def development?; environment == :development; end
def full_path(path)
-
(String)
- Path with index file if necessary
Parameters:
-
path
(String
) -- Request path
Other tags:
- Private: -
def full_path(path) resource = sitemap.find_resource_by_destination_path(path) if !resource # Try it with /index.html at the end indexed_path = File.join(path.sub(%r{/$}, ''), index_file) resource = sitemap.find_resource_by_destination_path(indexed_path) end if resource '/' + resource.destination_path else '/' + Middleman::Util.normalize_path(path) end end
def helpers(*extensions, &block)
-
(void)
-
def helpers(*extensions, &block) class_eval(&block) if block_given? include(*extensions) if extensions.any? end
def initialize(&block)
def initialize(&block) # Clear the static class cache cache.clear # Setup the default values from calls to set before initialization self.class.superclass.defaults.each { |k,v| set(k,v) } # Evaluate a passed block if given instance_exec(&block) if block_given? set :source, ENV["MM_SOURCE"] if ENV["MM_SOURCE"] super end
def root_path
def root_path @_root_path ||= Pathname.new(root) end
def set(key, value=nil, &block)
-
(void)
-
Parameters:
-
value
() -- Default value
-
key
(Symbol
) -- Unique key name
def set(key, value=nil, &block) @defaults ||= {} @defaults[key] = value @inst.set(key, value, &block) if @inst end
def set(key, value=nil, &block)
-
(void)
-
Parameters:
-
value
() -- Attribute value
-
key
(Symbol
) -- Name of the attribue
def set(key, value=nil, &block) setter = "#{key}=".to_sym self.class.send(:attr_accessor, key) if !respond_to?(setter) value = block if block_given? send(setter, value) end
def settings
-
(Middleman::Application)
-
def settings self end
def source_dir
-
(String)
-
def source_dir File.join(root, source) end
def to_s
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