diff --git a/ext/apt_pkg/configuration.cpp b/ext/apt_pkg/configuration.cpp index a27f561..75d87fd 100644 --- a/ext/apt_pkg/configuration.cpp +++ b/ext/apt_pkg/configuration.cpp @@ -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 * @@ -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, diff --git a/test/apt_pkg_configuration_test.rb b/test/apt_pkg_configuration_test.rb index 7438d8d..328d122 100644 --- a/test/apt_pkg_configuration_test.rb +++ b/test/apt_pkg_configuration_test.rb @@ -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