Class: EacTemplates::Sources::Directory

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

Constant Summary

Constants included from FsObject

FsObject::PATH_FOR_SEARCH_PREFIX

Instance Method Summary collapse

Methods included from FsObject

#found?, #path, #path_for_search_prefix

Methods inherited from Abstract::Directory

#build_child, #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

#children_basenamesHash<Pathname, Symbol>

Returns:

  • (Hash<Pathname, Symbol>)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/eac_templates/sources/directory.rb', line 13

def children_basenames
  r = {}
  real_paths.each do |real_path|
    real_path.children.each do |child|
      next if r.key?(child.basename)

      r[child.basename] = real_path_type(child)
    end
  end
  r
end

#real_path_type(path) ⇒ Pathname

Returns:

  • (Pathname)


26
27
28
29
30
31
32
33
34
# File 'lib/eac_templates/sources/directory.rb', line 26

def real_path_type(path)
  if path.file?
    :file
  elsif path.directory?
    :directory
  else
    raise "Path \"#{path}\" is not a file nor a directory"
  end
end