class Kamaze::Project::Tools::Gemspec::Packer
Provides a ready to use interface based on rubyc (aka ruby-packer)
Attributes
compiler[RW]
Binary (executable) used to pack the project
Public Instance Methods
config()
click to toggle source
Get host config, retrieved from “RbConfig::CONFIG“
@return [Hash]
# 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()
click to toggle source
Calls superclass method
Kamaze::Project::Tools::Gemspec::Packager#mutable_attributes
# File lib/kamaze/project/tools/gemspec/packer.rb, line 53 def mutable_attributes super + [:compiler] end
pack(packable)
click to toggle source
Pack given packable
@param [String] packable @return [Pathname]
# File lib/kamaze/project/tools/gemspec/packer.rb, line 49 def pack(packable) prepare.tap { command_for(packable).execute } end
packables()
click to toggle source
Get buildable (relative path)
@return [Array<Pathname>]
# 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
Protected Instance Methods
command_for(packable)
click to toggle source
Get command for (packing) a given packable
@param [String] packable @return [Command]
# 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
setup()
click to toggle source
Calls superclass method
Kamaze::Project::Tools::Gemspec::Packager#setup
# 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