Class: Kamaze::Project::Tools::Gemspec::Packer
- Inherits:
-
Packager
- Object
- Observable
- BaseTool
- Packager
- Packager
- Kamaze::Project::Tools::Gemspec::Packer
- Defined in:
- lib/kamaze/project/tools/gemspec/packer.rb
Overview
Provides a ready to use interface based on rubyc (aka ruby-packer)
Defined Under Namespace
Classes: Command
Instance Attribute Summary collapse
-
#compiler ⇒ Object
Binary (executable) used to pack the project.
- #observer_peers ⇒ Hash|nil included from Concern::Observable readonly protected
Instance Method Summary collapse
-
#command_for(packable) ⇒ Command
protected
Get command for (packing) a given packable.
-
#config ⇒ Hash
Get host config, retrieved from
RbConfig::CONFIG. - #mutable_attributes ⇒ Object
-
#pack(packable) ⇒ Pathname
Pack given packable.
-
#packables ⇒ Array<Pathname>
Get buildable (relative path).
- #setup ⇒ Object protected
Constructor Details
This class inherits a constructor from Kamaze::Project::Tools::Packager
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Kamaze::Project::Tools::Packager
Instance Attribute Details
#compiler ⇒ Object
Binary (executable) used to pack the project
22 23 24 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 22 def compiler @compiler end |
#observer_peers ⇒ Hash|nil (readonly, protected) Originally defined in module Concern::Observable
Instance Method Details
#command_for(packable) ⇒ Command (protected)
Get command for (packing) a given packable
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 74 def command_for(packable) Dir.chdir(pwd) do Command.new do |command| command.executable = compiler command.src_dir = package_dirs.fetch(:src) command.tmp_dir = package_dirs.fetch(:tmp) command.bin_dir = Pathname.new(specification.bin_dir) command.packable = packable end end end |
#config ⇒ Hash
Get host config, retrieved from RbConfig::CONFIG
41 42 43 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 41 def config (RbConfig::CONFIG.map { |k, v| [k.to_sym, v] }).to_h end |
#mutable_attributes ⇒ Object
53 54 55 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 53 def mutable_attributes super + [:compiler] end |
#pack(packable) ⇒ Pathname
Pack given packable
49 50 51 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 49 def pack(packable) prepare.tap { command_for(packable).execute } end |
#packables ⇒ Array<Pathname>
Get buildable (relative path)
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 27 def packables specification.executables.map do |executable| # @formatter:off package_dirs.fetch(:bin) .join(executable) .to_s.gsub(%r{^./}, '') .yield_self { |path| ::Pathname.new(path) } # @formatter:on end end |
#setup ⇒ Object (protected)
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 59 def setup super self.package_labels = [:src, :tmp, :bin] self.purgeables = [:bin] self.package_name = '%<os>s/%<arch>s' % { os: config.fetch(:host_os), arch: config.fetch(:host_cpu) } end |