Class: Kamaze::Project::Tools::Packager::Filesystem
- Defined in:
- lib/kamaze/project/tools/packager/filesystem.rb,
lib/kamaze/project/tools/packager.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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 56 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
122 123 124 125 126 127 128 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 122 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)
77 78 79 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 77 def package_basedir ::Pathname.new(@package_basedir) end |
#package_labels=(value) ⇒ Object (writeonly)
Labels for packaging stages
46 47 48 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 46 def package_labels=(value) @package_labels = value end |
#package_name ⇒ Object
Name given to the package
41 42 43 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 41 def package_name @package_name end |
#purgeables=(value) ⇒ Object (writeonly)
Labels for purgeables dirs (during prepare)
51 52 53 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 51 def purgeables=(value) @purgeables = value end |
#source_files ⇒ Array<Pathname>
Get source files
118 119 120 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 118 def source_files @source_files.sort.map { |path| ::Pathname.new(path) } end |
#verbose ⇒ Boolean (protected)
157 158 159 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 157 def verbose @verbose end |
#working_dir ⇒ Pathname Also known as: pwd
Get (original) working dir
109 110 111 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 109 def working_dir ::Pathname.new(@working_dir) end |
Instance Method Details
#mutable_attribute?(attr) ⇒ Boolean
148 149 150 151 152 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 148 def mutable_attribute?(attr) attr = attr.to_s.gsub(/=$?/, '').to_sym mutable_attributes.include?(attr) end |
#mutable_attributes ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 136 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
171 172 173 174 175 176 177 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 171 def mute_attributes!(attributes) attributes.each do |m| self.singleton_class.class_eval { protected "#{m}=" } end self end |
#operator ⇒ Kamaze::Project::Tools::Packager::Filesystem::Operator (protected)
Get operator
162 163 164 165 166 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 162 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
84 85 86 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 84 def package_dir package_basedir.join(package_name) end |
#package_dirs ⇒ Hash
Get (named) paths (as: src, tmp and bin)
91 92 93 94 95 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 91 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
100 101 102 103 104 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 100 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
130 131 132 133 134 |
# File 'lib/kamaze/project/tools/packager/filesystem.rb', line 130 def respond_to_missing?(method, include_private = false) return true if operator.respond_to?(method, include_private) super(method, include_private) end |