Class: EacTemplates::Modules::Base::Directory

Inherits:
Abstract::Directory show all
Includes:
FsObject
Defined in:
lib/eac_templates/modules/base/directory.rb

Instance Method Summary collapse

Methods included from FsObject

#self_ancestor

Methods inherited from Abstract::Directory

#child, #children

Methods inherited from Abstract::FsObject

#applier, #applier_class, assert, by_subpath, #category_module, #path_for_search, #path_for_search_prefix, #raise_not_found, #source_set, #type, #type_list

Instance Method Details

#apply(variables_source, target_path) ⇒ Object

Parameters:

  • variables_source (Object)
  • target_path (Pathname)


18
19
20
21
22
23
24
# File 'lib/eac_templates/modules/base/directory.rb', line 18

def apply(variables_source, target_path)
  target_path = target_path.to_pathname
  target_path.mkpath
  children.each do |child|
    child_apply(child, variables_source, target_path.join(child.basename))
  end
end

#build_child(child_basename, child_type) ⇒ EacTemplates::Modules::Base

Parameters:

  • child_basename (Pathname)
  • child_type (Symbol)

Returns:



30
# File 'lib/eac_templates/modules/base/directory.rb', line 30

delegate :build_child, to: :owner

#children_basenamesHash<Pathname, Symbol>

Returns:

  • (Hash<Pathname, Symbol>)


33
34
35
36
37
# File 'lib/eac_templates/modules/base/directory.rb', line 33

def children_basenames
  owner.ancestors.select(&:directory?).each_with_object({}) do |e, a|
    ancestor_children_names(e, a)
  end
end

#found?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/eac_templates/modules/base/directory.rb', line 40

def found?
  children.any?
end