Module: Middleman
- Defined in:
- lib/middleman-core.rb,
lib/middleman-core/cli.rb,
lib/middleman-core/util.rb,
lib/middleman-core/logger.rb,
lib/middleman-core/sitemap.rb,
lib/middleman-core/version.rb,
lib/middleman-core/profiling.rb,
lib/middleman-core/extensions.rb,
lib/middleman-core/load_paths.rb,
lib/middleman-core/meta_pages.rb,
lib/middleman-core/application.rb,
lib/middleman-core/configuration.rb,
lib/middleman-core/renderers/erb.rb,
lib/middleman-core/sitemap/store.rb,
lib/middleman-core/preview_server.rb,
lib/middleman-core/renderers/haml.rb,
lib/middleman-core/renderers/less.rb,
lib/middleman-core/renderers/sass.rb,
lib/middleman-core/renderers/slim.rb,
lib/middleman-core/renderers/liquid.rb,
lib/middleman-core/renderers/stylus.rb,
lib/middleman-core/sitemap/resource.rb,
lib/middleman-core/sitemap/queryable.rb,
lib/middleman-core/renderers/asciidoc.rb,
lib/middleman-core/renderers/kramdown.rb,
lib/middleman-core/renderers/markdown.rb,
lib/middleman-core/renderers/redcarpet.rb,
lib/middleman-core/core_extensions/data.rb,
lib/middleman-core/core_extensions/request.rb,
lib/middleman-core/core_extensions/routing.rb,
lib/middleman-core/meta_pages/sitemap_tree.rb,
lib/middleman-core/renderers/coffee_script.rb,
lib/middleman-core/meta_pages/config_setting.rb,
lib/middleman-core/core_extensions/extensions.rb,
lib/middleman-core/sitemap/extensions/ignores.rb,
lib/middleman-core/sitemap/extensions/on_disk.rb,
lib/middleman-core/sitemap/extensions/proxies.rb,
lib/middleman-core/meta_pages/sitemap_resource.rb,
lib/middleman-core/core_extensions/file_watcher.rb,
lib/middleman-core/sitemap/extensions/redirects.rb,
lib/middleman-core/sitemap/extensions/traversal.rb,
lib/middleman-core/core_extensions/show_exceptions.rb,
lib/middleman-core/core_extensions/external_helpers.rb,
lib/middleman-core/sitemap/extensions/request_endpoints.rb,
lib/middleman-core/core_extensions/rendering.rb
Overview
Rendering extension
Defined Under Namespace
Modules: Cli, Configuration, CoreExtensions, Extensions, Features, MetaPages, PreviewServer, Profiling, Renderers, Sitemap, Templates, Util Classes: Application, Extension, Logger
Constant Summary collapse
- VERSION =
Current Version
'3.2.0'
- EXTENSION_FILE =
Where to look in gems for extensions to auto-register
File.join("lib", "middleman_extension.rb")
Class Method Summary collapse
-
.load_extensions_in_path ⇒ Object
Automatically load extensions from available RubyGems which contain the EXTENSION_FILE.
-
.locate_root(cwd = Pathname.new(Dir.pwd)) ⇒ Object
Recursive method to find config.rb.
-
.rubygems_latest_specs ⇒ Array
Backwards compatible means of finding all the latest gemspecs available on the system.
- .setup_load_paths ⇒ Object
-
.spec_has_file?(spec, path) ⇒ Boolean
Where a given Gem::Specification has a specific file.
Class Method Details
.load_extensions_in_path ⇒ Object
Automatically load extensions from available RubyGems which contain the EXTENSION_FILE
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/middleman-core/extensions.rb', line 63 def load_extensions_in_path require "rubygems" extensions = rubygems_latest_specs.select do |spec| spec_has_file?(spec, EXTENSION_FILE) end extensions.each do |spec| require spec.name end end |
.locate_root(cwd = Pathname.new(Dir.pwd)) ⇒ Object
Recursive method to find config.rb
48 49 50 51 52 |
# File 'lib/middleman-core/load_paths.rb', line 48 def locate_root(cwd = Pathname.new(Dir.pwd)) return cwd.to_s if (cwd + 'config.rb').exist? return false if cwd.root? locate_root(cwd.parent) end |
.rubygems_latest_specs ⇒ Array
Backwards compatible means of finding all the latest gemspecs available on the system
80 81 82 83 84 85 86 87 |
# File 'lib/middleman-core/extensions.rb', line 80 def rubygems_latest_specs # If newer Rubygems if ::Gem::Specification.respond_to? :latest_specs ::Gem::Specification.latest_specs(true) else ::Gem.source_index.latest_specs end end |
.setup_load_paths ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/middleman-core/load_paths.rb', line 7 def setup_load_paths @_is_setup ||= begin # Only look for config.rb if MM_ROOT isn't set if !ENV["MM_ROOT"] && found_path = locate_root ENV["MM_ROOT"] = found_path end is_bundler_setup = false # If we've found the root, try to setup Bundler if ENV["MM_ROOT"] root_gemfile = File.('Gemfile', ENV["MM_ROOT"]) ENV['BUNDLE_GEMFILE'] ||= root_gemfile if !File.exists?(ENV['BUNDLE_GEMFILE']) git_gemfile = Pathname.new(__FILE__)..parent.parent.parent + "Gemfile" ENV['BUNDLE_GEMFILE'] = git_gemfile.to_s end if File.exists?(ENV['BUNDLE_GEMFILE']) is_bundler_setup = true require 'bundler/setup' end end # Automatically discover extensions in RubyGems require "middleman-core/extensions" if is_bundler_setup Bundler.require else ::Middleman.load_extensions_in_path end true end end |
.spec_has_file?(spec, path) ⇒ Boolean
Where a given Gem::Specification has a specific file. Used to discover extensions.
96 97 98 99 |
# File 'lib/middleman-core/extensions.rb', line 96 def spec_has_file?(spec, path) full_path = File.join(spec.full_gem_path, path) File.exists?(full_path) end |