Sha256: 3eff668caa24a3d3c05852cb2fac46257da60e67cefc86b0900262921ba6f025
Contents?: true
Size: 1.29 KB
Versions: 3
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require 'eac_templates/variables/file' require 'eac_templates/variables/fs_object' module EacTemplates module Variables class Directory attr_reader :path def initialize(path) @path = path.is_a?(::Pathname) ? path : ::Pathname.new(path.to_s) end def apply(variables_source, directory) ::EacTemplates::Variables::FsObject.new(self, '.', directory, variables_source).apply end def child(subpath) child_path = ::File.join(path, subpath) return ::EacTemplates::Variables::File.new(child_path) if ::File.file?(child_path) return ::EacTemplates::Variables::Directory.new(child_path) if ::File.directory?(child_path) raise "Child \"#{subpath}\" from \"#{path}\" not found" end def children path.children.map do |path_child| child(path_child.basename.to_path) end end private def apply_fs_object(source_relative, target) if ::File.directory?(source_absolute(source_relative)) apply_directory(source_relative, target) elsif ::File.file?(source_absolute(source_relative)) end end def source_absolute(source_relative) ::File.expand_path(source_relative, path) end end end end
Version data entries
3 entries across 3 versions & 2 rubygems