class Kamaze::Project::Tools::Packager::Filesystem
Filesystem
description used during packaging
Filesystem
has an Operator
, which is intended to manipulate described files and directories. Package has a name, see “package_name“, package name SHOULD be constitued with two (path) parts. Package dirs are labeled, as a default, only “:src“ is provided. Labels are used to constitute the complete directory path (relative to “pwd“).
Attributes
Package dir (root directory)
Relative to current pwd
@type [String]
Labels for packaging stages
@type [Array<Symbol>]
Name given to the package
@type [String]
Labels for purgeables dirs (during prepare)
@type [Array<Symbol>]
@type [Array<String|Pathname>]
@type [Boolean]
Working directory
@type [String]
Public Class Methods
# File lib/kamaze/project/tools/packager/filesystem.rb, line 62 def initialize @package_basedir = 'build' @package_name = 'sample/package' @working_dir = Dir.pwd @package_labels = [:src] @verbose = true @operator = self.operator yield self if block_given? @source_files ||= [] @purgeables ||= [] mute_attributes!(mutable_attributes) end
Public Instance Methods
# File lib/kamaze/project/tools/packager/filesystem.rb, line 128 def method_missing(method, *args, &block) if respond_to_missing?(method) operator.public_send(method, *args, &block) else super end end
# File lib/kamaze/project/tools/packager/filesystem.rb, line 154 def mutable_attribute?(attr) attr = attr.to_s.gsub(/=$?/, '').to_sym mutable_attributes.include?(attr) end
# File lib/kamaze/project/tools/packager/filesystem.rb, line 142 def mutable_attributes [ :verbose, :purgeables, :working_dir, :source_files, :package_basedir, :package_name, :package_labels ].sort end
Get packaging dir (root directory)
@return [Pathname]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 83 def package_basedir ::Pathname.new(@package_basedir) end
Get package dir identified by its name
@return [Pathname]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 90 def package_dir package_basedir.join(package_name) end
Get (named) paths (as: src, tmp and bin)
@return [Hash]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 97 def package_dirs @package_labels.map do |k| [k, package_dir.join(k.to_s)] end.to_h end
Get purgeable (named) paths
@return [Hash]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 106 def purgeable_dirs @purgeables.map do |k| [k, package_dirs[k]] if package_dirs[k] end.to_h end
# File lib/kamaze/project/tools/packager/filesystem.rb, line 136 def respond_to_missing?(method, include_private = false) return true if operator.respond_to?(method, include_private) super(method, include_private) end
Get source files
@return [Array<Pathname>]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 124 def source_files @source_files.sort.map { |path| ::Pathname.new(path) } end
Get (original) working dir
@return [Pathname]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 115 def working_dir ::Pathname.new(@working_dir) end
Protected Instance Methods
Pass some attributes to protected
@return [self]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 177 def mute_attributes!(attributes) attributes.each do |m| # rubocop:disable Style/AccessModifierDeclarations self.singleton_class.class_eval { protected "#{m}=" } # rubocop:enable Style/AccessModifierDeclarations end self end
Get operator
@return [Kamaze::Project::Tools::Packager::Filesystem::Operator]
# File lib/kamaze/project/tools/packager/filesystem.rb, line 168 def operator const_class = self.class.const_get(:Operator) const_class.new(self, verbose: verbose) end