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,
lib/kamaze/project/tools/gemspec.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
21 22 23 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 21 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
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 76 def command_for(packable) bin_dir = ::Pathname.new(specification.bin_dir) 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 = bin_dir command.packable = packable end end end |
#config ⇒ Hash
Get host config, retrieved from RbConfig::CONFIG
38 39 40 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 38 def config (RbConfig::CONFIG.map { |k, v| [k.to_sym, v] }).to_h end |
#mutable_attributes ⇒ Object
55 56 57 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 55 def mutable_attributes super + [:compiler] end |
#pack(packable) ⇒ Pathname
Pack given packable
46 47 48 49 50 51 52 53 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 46 def pack(packable) bin_dir = ::Pathname.new(specification.bin_dir) prepare command_for(packable).execute bin_dir.join(packable) end |
#packables ⇒ Array<Pathname>
Get buildable (relative path)
26 27 28 29 30 31 32 33 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 26 def packables specification.executables.map do |executable| package_dirs.fetch(:bin) .join(executable) .to_s.gsub(%r{^./}, '') .yield_self { |path| ::Pathname.new(path) } end end |
#setup ⇒ Object (protected)
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/kamaze/project/tools/gemspec/packer.rb', line 61 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 |