Module: Middleman::CoreExtensions::Extensions::InstanceMethods
- Defined in:
- lib/middleman-core/core_extensions/extensions.rb
Overview
Instance methods
Instance Method Summary collapse
-
#activate(ext, options = {}, &block) ⇒ void
This method is available in the project’s ‘config.rb`.
-
#initialize ⇒ Object
Load features before starting server.
Instance Method Details
#activate(ext, options = {}, &block) ⇒ void
This method returns an undefined value.
This method is available in the project’s ‘config.rb`. It takes a underscore-separated symbol, finds the appropriate feature module and includes it.
activate :lorem
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/middleman-core/core_extensions/extensions.rb', line 108 def activate(ext, ={}, &block) ext_module = if ext.is_a?(Module) ext else ::Middleman::Extensions.load(ext.to_sym) end if ext_module.nil? logger.error "== Unknown Extension: #{ext}" else logger.debug "== Activating: #{ext}" self.class.register(ext_module, , &block) end end |
#initialize ⇒ Object
Load features before starting server
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/middleman-core/core_extensions/extensions.rb', line 124 def initialize super self.class.inst = self run_hook :before_configuration # Search the root of the project for required files $LOAD_PATH.unshift(root) # Check for and evaluate local configuration local_config = File.join(root, "config.rb") if File.exists? local_config logger.debug "== Reading: Local config" instance_eval File.read(local_config), local_config, 1 end if autoload_sprockets begin require "middleman-sprockets" activate(:sprockets) rescue LoadError end end run_hook :build_config if build? run_hook :development_config if development? run_hook :after_configuration logger.debug "Loaded extensions:" self.class.extensions.each do |ext| logger.debug "== Extension: #{ext}" end end |