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_basedir[W]

Package dir (root directory)

Relative to current pwd

@type [String]

package_labels[W]

Labels for packaging stages

@type [Array<Symbol>]

package_name[RW]

Name given to the package

@type [String]

purgeables[W]

Labels for purgeables dirs (during prepare)

@type [Array<Symbol>]

source_files[W]

@type [Array<String|Pathname>]

verbose[RW]

@type [Boolean]

working_dir[W]

Working directory

@type [String]

Public Class Methods

new() { |self| ... } click to toggle source
# 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

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# 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
mutable_attribute?(attr) click to toggle source
# 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
mutable_attributes() click to toggle source
# 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
package_basedir() click to toggle source

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
package_dir() click to toggle source

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
package_dirs() click to toggle source

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
purgeable_dirs() click to toggle source

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
pwd()
Alias for: working_dir
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# 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
source_files() click to toggle source

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
working_dir() click to toggle source

Get (original) working dir

@return [Pathname]

# File lib/kamaze/project/tools/packager/filesystem.rb, line 115
def working_dir
  ::Pathname.new(@working_dir)
end
Also aliased as: pwd

Protected Instance Methods

mute_attributes!(attributes) click to toggle source

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
operator() click to toggle source

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