aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-27 20:32:14 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-27 20:32:14 +0000
commitecd5d1acd291c12fae455af07beee30dc8bdfe71 (patch)
treeee6d6a8f9c510eece5456b3e2dc7c9a97d01e460
parenta946b1294459be25bf65bcb9c9b6839117f11caf (diff)
downloadpaludis-ecd5d1acd291c12fae455af07beee30dc8bdfe71.tar.gz
paludis-ecd5d1acd291c12fae455af07beee30dc8bdfe71.tar.xz
Add PackageDatabase.better_repository. From Richard Brown.
-rw-r--r--ruby/package_database.cc21
-rw-r--r--ruby/package_database_TEST.rb4
2 files changed, 25 insertions, 0 deletions
diff --git a/ruby/package_database.cc b/ruby/package_database.cc
index 429b51c..3f828bb 100644
--- a/ruby/package_database.cc
+++ b/ruby/package_database.cc
@@ -124,6 +124,25 @@ namespace
}
}
+ VALUE
+ package_database_better_repository(VALUE self, VALUE name1, VALUE name2)
+ {
+ try
+ {
+ PackageDatabase::Pointer * self_ptr;
+ Data_Get_Struct(self, PackageDatabase::Pointer, self_ptr);
+
+ return rb_str_new2(stringify((*self_ptr)->better_repository(
+ RepositoryName(STR2CSTR(name1)),
+ RepositoryName(STR2CSTR(name2))
+ )).c_str());
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_package_database()
{
c_package_database = rb_define_class_under(master_class(), "PackageDatabase", rb_cObject);
@@ -138,6 +157,8 @@ namespace
RUBY_FUNC_CAST(&package_database_repositories), 0);
rb_define_method(c_package_database, "fetch_repository",
RUBY_FUNC_CAST(&package_database_fetch_repository), 1);
+ rb_define_method(c_package_database, "better_repository",
+ RUBY_FUNC_CAST(&package_database_better_repository), 2);
c_package_database_install_state = rb_define_class_under(master_class(), "InstallState", rb_cObject);
for (InstallState l(static_cast<InstallState>(0)), l_end(last_install_state) ; l != l_end ;
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index a21f6fe..aca8cfd 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -110,6 +110,10 @@ class Paludis
db.fetch_repository("barrepo")
end
end
+
+ def test_better_repository
+ assert_equal 'testrepo', db.better_repository('testrepo', 'virtuals')
+ end
end
end