Skip to content

Commit

Permalink
Add Debian::AptPkg::Configuration.architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
spk committed Aug 26, 2023
1 parent 31e7fc0 commit 0d4b94c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ext/apt_pkg/configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#include "configuration.h"

/*
* call-seq: architecture() -> string
*
* Return the native architecture for this system.
*
* Debian::AptPkg::Configuration.architecture # => "amd64"
*
**/
static VALUE
architecture(VALUE self)
{
return rb_str_new2(_config->Find("APT::Architecture").c_str());
}

/*
* call-seq: architectures() -> array
*
Expand Down Expand Up @@ -170,6 +184,8 @@ init_apt_pkg_configuration()
VALUE rb_mDebianAptPkgConfiguration =
rb_define_module_under(rb_mDebianAptPkg, "Configuration");

rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "architecture",
RUBY_METHOD_FUNC(architecture), 0);
rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "architectures",
RUBY_METHOD_FUNC(architectures), 0);
rb_define_singleton_method(rb_mDebianAptPkgConfiguration,
Expand Down
6 changes: 6 additions & 0 deletions test/apt_pkg_configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
Debian::AptPkg.init
end

it 'architecture return a string' do
arch = Debian::AptPkg::Configuration.architecture
_(arch).must_be_instance_of String
_(arch).wont_be_empty
end

it 'architectures return an array' do
arches = Debian::AptPkg::Configuration.architectures
_(arches).must_be_instance_of Array
Expand Down

0 comments on commit 0d4b94c

Please sign in to comment.