Class: Kamaze::Project::Tools::Packager::Filesystem
- Defined in:
- lib/kamaze/project/tools/packager/filesystem.rb
Overview
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).
Defined Under Namespace
Classes: Operator
Instance Attribute Summary collapse
-
#package_basedir ⇒ Pathname
Get packaging dir (root directory).
-
#package_labels ⇒ Object
writeonly
Labels for packaging stages.
-
#package_name ⇒ Object
Name given to the package.
-
#purgeables ⇒ Object
writeonly
Labels for purgeables dirs (during prepare).
-
#source_files ⇒ Array<Pathname>
Get source files.
- #verbose ⇒ Boolean protected
-
#working_dir ⇒ Pathname
(also: #pwd)
Get (original) working dir.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Filesystem
constructor
A new instance of Filesystem.
- #method_missing(method, *args, &block) ⇒ Object
- #mutable_attribute?(attr) ⇒ Boolean
- #mutable_attributes ⇒ Object
-
#mute_attributes!(attributes) ⇒ self
protected
Pass some attributes to protected.
-
#operator ⇒ Kamaze::Project::Tools::Packager::Filesystem::Operator
protected
Get operator.
-
#package_dir ⇒ Pathname
Get package dir identified by its name.
-
#package_dirs ⇒ Hash
Get (named) paths (as: src, tmp and bin).
-
#purgeable_dirs ⇒ Hash
Get purgeable (named) paths.
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
Constructor Details
#initialize {|_self| ... } ⇒ Filesystem
Returns a new instance of Filesystem.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
128 129 130 131 132 133 134 |
# 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 |
Instance Attribute Details
#package_basedir ⇒ Pathname
Get packaging dir (root directory)
83 84 85 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 83 def package_basedir ::Pathname.new(@package_basedir) end |
#package_labels=(value) ⇒ Object (writeonly)
Labels for packaging stages
52 53 54 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 52 def package_labels=(value) @package_labels = value end |
#package_name ⇒ Object
Name given to the package
47 48 49 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 47 def package_name @package_name end |
#purgeables=(value) ⇒ Object (writeonly)
Labels for purgeables dirs (during prepare)
57 58 59 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 57 def purgeables=(value) @purgeables = value end |
#source_files ⇒ Array<Pathname>
Get source files
124 125 126 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 124 def source_files @source_files.sort.map { |path| ::Pathname.new(path) } end |
#verbose ⇒ Boolean (protected)
163 164 165 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 163 def verbose @verbose end |
#working_dir ⇒ Pathname Also known as: pwd
Get (original) working dir
115 116 117 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 115 def working_dir ::Pathname.new(@working_dir) end |
Instance Method Details
#mutable_attribute?(attr) ⇒ Boolean
154 155 156 157 158 |
# 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 ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 |
# 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 |
#mute_attributes!(attributes) ⇒ self (protected)
Pass some attributes to protected
177 178 179 180 181 182 183 184 185 |
# 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 ⇒ Kamaze::Project::Tools::Packager::Filesystem::Operator (protected)
Get operator
168 169 170 171 172 |
# 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 |
#package_dir ⇒ Pathname
Get package dir identified by its name
90 91 92 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 90 def package_dir package_basedir.join(package_name) end |
#package_dirs ⇒ Hash
Get (named) paths (as: src, tmp and bin)
97 98 99 100 101 |
# 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 ⇒ Hash
Get purgeable (named) paths
106 107 108 109 110 |
# 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 |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
136 137 138 139 140 |
# 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 |