Class: Middleman::Sitemap::Extensions::Import::ImportPathDescriptor

Inherits:
Struct
  • Object
show all
Defined in:
middleman-core/lib/middleman-core/sitemap/extensions/import.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from


20
21
22
# File 'middleman-core/lib/middleman-core/sitemap/extensions/import.rb', line 20

def from
  @from
end

#renameProcObject

Returns the value of attribute renameProc

Returns:

  • (Object)

    the current value of renameProc


20
21
22
# File 'middleman-core/lib/middleman-core/sitemap/extensions/import.rb', line 20

def renameProc
  @renameProc
end

Instance Method Details

#execute_descriptor(app, resource_list) ⇒ Object


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'middleman-core/lib/middleman-core/sitemap/extensions/import.rb', line 21

def execute_descriptor(app, resource_list)
  new_resources = ::Middleman::Util.glob_directory(File.join(from, '**/*'))
                                   .reject { |path| File.directory?(path) }
                                   .map do |path|
    target_path = Pathname(path).relative_path_from(Pathname(from).parent).to_s

    ::Middleman::Sitemap::Resource.new(
      app.sitemap,
      renameProc.call(target_path, path),
      path
    )
  end

  resource_list.add!(*new_resources)
end