module Kamaze::Project::Tools::Packager::Filesystem::Operator::Utils
Utilities related to files/paths manipulations
Protected Instance Methods
ls(dir)
click to toggle source
List entries
@param [String] dir @return [Array<Pathname>]
# File lib/kamaze/project/tools/packager/filesystem/operator/utils.rb, line 58 def ls(dir) # @formatter:off Pathname.new(dir).entries .map { |path| ::Pathname.new(path) } .delete_if { |path| ['.', '..'].include?(path.basename.to_s) } # @formatter:on end
map_dirs(paths)
click to toggle source
Extract directories from given paths
@param [Array<String>] paths @return [Array<Pathname>]
# File lib/kamaze/project/tools/packager/filesystem/operator/utils.rb, line 70 def map_dirs(paths) # @formatter:off paths.map { |path| ::Pathname.new(path) } .map(&:dirname) .delete_if { |path| ['.', '..'].include?(path.basename.to_s) } .uniq.sort # @formatter:on end
purge(dir, options = {})
click to toggle source
Purge a directory
@param [Pathname] dir @return [Pathname]
# File lib/kamaze/project/tools/packager/filesystem/operator/utils.rb, line 28 def purge(dir, options = {}) options = { verbose: true }.merge(options) dir = Pathname.new(dir) if dir.exist? ls(dir).each do |entry| rm_rf(dir.join(entry), **options) end end dir end
skel_dirs(basedir, entries, options = {})
click to toggle source
Make dirs from given basedir using entries (filepaths)
@param [String|Pathname] basedir @param [Array<>] entries @param [Hash] options
@return [Pathname]
# File lib/kamaze/project/tools/packager/filesystem/operator/utils.rb, line 48 def skel_dirs(basedir, entries, options = {}) Pathname.new(basedir).tap do map_dirs(entries).each { |dir| mkdir_p(basedir.join(dir), **options) } end end
utils_methods()
click to toggle source
@return [Array<Symbol>]
# File lib/kamaze/project/tools/packager/filesystem/operator/utils.rb, line 80 def utils_methods FileUtils.public_methods - self.public_methods end