aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-12-15 21:22:51 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-12-15 21:22:51 +0000
commit357c1a1a86423f1f103f818dd9ac93ef4464a3ec (patch)
tree94d670b4d00b12067fc6438db461c5e8f21d9a91
parenta274f41aec3b07ef02601c39e944147e96bacc3a (diff)
downloadpaludis-357c1a1a86423f1f103f818dd9ac93ef4464a3ec.tar.gz
paludis-357c1a1a86423f1f103f818dd9ac93ef4464a3ec.tar.xz
(ruby) Add PackageDatabase.has_repository_named?
-rw-r--r--ruby/package_database.cc24
-rw-r--r--ruby/package_database_TEST.rb6
2 files changed, 30 insertions, 0 deletions
diff --git a/ruby/package_database.cc b/ruby/package_database.cc
index 4313b83..d222e46 100644
--- a/ruby/package_database.cc
+++ b/ruby/package_database.cc
@@ -204,6 +204,28 @@ namespace
}
}
+ /*
+ * call-seq:
+ * has_repository_named?(repository_name) -> true or false
+ *
+ * Do we have a named repository?
+ */
+ VALUE
+ package_database_has_repository_named(VALUE self, VALUE name)
+ {
+ try
+ {
+ tr1::shared_ptr<PackageDatabase> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<PackageDatabase>, self_ptr);
+
+ return ((*self_ptr)->has_repository_named(RepositoryName(StringValuePtr(name)))) ? true : false;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_package_database()
{
/*
@@ -224,6 +246,8 @@ namespace
RUBY_FUNC_CAST(&package_database_fetch_repository), 1);
rb_define_method(c_package_database, "more_important_than",
RUBY_FUNC_CAST(&package_database_more_important_than), 2);
+ rb_define_method(c_package_database, "has_repository_named?",
+ RUBY_FUNC_CAST(&package_database_has_repository_named), 1);
/*
* Document-module: Paludis::QueryOrder
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index 0840a16..5d24d45 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -232,6 +232,12 @@ module Paludis
assert db.more_important_than('testrepo', 'virtuals')
assert ! db.more_important_than('virtuals', 'testrepo')
end
+
+ def test_has_repository_named?
+ assert db.has_repository_named? 'testrepo'
+ assert db.has_repository_named? 'virtuals'
+ assert ! db.has_repository_named?('foobarbaz')
+ end
end
end