Class: Middleman::CoreExtensions::Routing::PageDescriptor

Inherits:
Struct
  • Object
show all
Defined in:
lib/middleman-core/core_extensions/routing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#metadataObject

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



12
13
14
# File 'lib/middleman-core/core_extensions/routing.rb', line 12

def 
  @metadata
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



12
13
14
# File 'lib/middleman-core/core_extensions/routing.rb', line 12

def path
  @path
end

Instance Method Details

#execute_descriptor(app, resources) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/middleman-core/core_extensions/routing.rb', line 13

def execute_descriptor(app, resources)
  normalized_path = path.dup

  if normalized_path.is_a?(String) && !normalized_path.include?('*')
    # Normalize path
    normalized_path = ::Middleman::Util.normalize_path(normalized_path)
    if normalized_path.end_with?('/') || app.files.by_type(:source).watchers.any? { |w| (w.directory + Pathname(normalized_path)).directory? }
      normalized_path = ::File.join(normalized_path, app.config[:index_file])
    end
  end

  normalized_path = '/' + ::Middleman::Util.strip_leading_slash(normalized_path) if normalized_path.is_a?(String)

  resources
    .select { |r| ::Middleman::Util.path_match(normalized_path, "/#{r.path}") }
    .each { |r| r.(, true) }

  resources
end