Class: Kamaze::Project::Tools::Packager::Filesystem::Operator
- Includes:
- Utils
- Defined in:
- lib/kamaze/project/tools/packager/filesystem/operator.rb,
lib/kamaze/project/tools/packager.rb
Overview
Filesystem operator (manipulator)
This class is intended to manipulate a Filesystem
.
Defined Under Namespace
Modules: Utils
Instance Attribute Summary collapse
- #fs ⇒ Kamaze::Project::Tools::Packager::Filesystem readonly
- #options ⇒ Hash readonly protected
Instance Method Summary collapse
-
#initialize(filesystem, options = {}) ⇒ Operator
constructor
A new instance of Operator.
-
#ls(dir) ⇒ Array<Pathname>
included
from Utils
protected
List entries.
-
#map_dirs(paths) ⇒ Array<Pathname>
included
from Utils
protected
Extract directories from given paths.
-
#prepare ⇒ self
Prepare package.
-
#prepare_srcdir ⇒ self
Prepare
src
dir. -
#purge(dir, options = {}) ⇒ Pathname
included
from Utils
protected
Purge a directory.
-
#purge_purgeables ⇒ self
Purge purgeables elements.
-
#skel_dirs(basedir, entries, options = {}) ⇒ Pathname
included
from Utils
protected
Make dirs from given basedir using entries (filepaths).
- #utils_methods ⇒ Array<Symbol> included from Utils protected
- #verbose? ⇒ Boolean
Constructor Details
#initialize(filesystem, options = {}) ⇒ Operator
Returns a new instance of Operator.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 25 def initialize(filesystem, = {}) @fs = filesystem @options = { verbose: true }.merge(.to_h) # Pass included methods to protected utils_methods.each do |m| if self.public_methods.include?(m) self.singleton_class.class_eval { protected m } end end end |
Instance Attribute Details
#fs ⇒ Kamaze::Project::Tools::Packager::Filesystem (readonly)
20 21 22 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 20 def fs @fs end |
#options ⇒ Hash (readonly, protected)
82 83 84 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 82 def @options end |
Instance Method Details
#ls(dir) ⇒ Array<Pathname> (protected) Originally defined in module Utils
List entries
#map_dirs(paths) ⇒ Array<Pathname> (protected) Originally defined in module Utils
Extract directories from given paths
#prepare ⇒ self
Prepare package
40 41 42 43 44 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 40 def prepare fs.package_dirs.each_value { |dir| mkdir_p(dir, ) } self.purge_purgeables.prepare_srcdir end |
#prepare_srcdir ⇒ self
Prepare src
dir
Source files are refreshed (deleted and copied again)
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 60 def prepare_srcdir src_dir = ::Pathname.new(fs.package_dirs.fetch(:src)) purge(src_dir, ) skel_dirs(src_dir, fs.source_files, ) fs.source_files.map do |path| origin = path.realpath # resolves symlinks cp(origin, src_dir.join(path), .merge(preserve: true)) end self end |
#purge(dir, options = {}) ⇒ Pathname (protected) Originally defined in module Utils
Purge a directory
#purge_purgeables ⇒ self
Purge purgeables elements
49 50 51 52 53 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 49 def purge_purgeables fs.purgeable_dirs.each_value { |dir| purge(dir, ) } self end |
#skel_dirs(basedir, entries, options = {}) ⇒ Pathname (protected) Originally defined in module Utils
Make dirs from given basedir using entries (filepaths)
#utils_methods ⇒ Array<Symbol> (protected) Originally defined in module Utils
#verbose? ⇒ Boolean
75 76 77 |
# File 'lib/kamaze/project/tools/packager/filesystem/operator.rb', line 75 def verbose? [:verbose] == true end |