aboutsummaryrefslogtreecommitdiff
path: root/ruby/repository.cc
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2008-05-17 14:58:07 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2008-05-17 14:58:07 +0000
commitf3b0917abaf1406d82f2b3f13629323be092cbd1 (patch)
tree599828924ddc2d564b83eb57085d4ac7723cf801 /ruby/repository.cc
parent9a269bbb0d26e39ffaf2fc6fc6769a43d04d3ed2 (diff)
downloadpaludis-f3b0917abaf1406d82f2b3f13629323be092cbd1.tar.gz
paludis-f3b0917abaf1406d82f2b3f13629323be092cbd1.tar.xz
Add mirrors to Environment and Repository.
Diffstat (limited to 'ruby/repository.cc')
-rw-r--r--ruby/repository.cc42
1 files changed, 41 insertions, 1 deletions
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 5edfd2f3e..eb2ba9e7a 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
- * Copyright (c) 2006, 2007, 2008 Richard Brown
+ * Copyright (c) 2006, 2007, 2008 Richard Brown
* Copyright (c) 2007 David Leverton
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -897,6 +897,43 @@ namespace
return Qnil;
}
+ /*
+ * call-seq:
+ * is_mirror?(mirror_name) -> true or false
+ *
+ * Is the named item a mirror?
+ */
+ VALUE
+ repository_is_mirror(VALUE self, VALUE mirror)
+ {
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
+ if ((**self_ptr)[k::mirrors_interface()])
+ return (**self_ptr)[k::mirrors_interface()]->is_mirror(StringValuePtr(mirror)) ? Qtrue : Qfalse;
+ return Qnil;
+ }
+
+ /*
+ * call-seq:
+ * mirrors(mirror_name) -> Array
+ *
+ * Return the mirror URI prefixes for a named mirror.
+ */
+ VALUE
+ repository_mirrors(VALUE self, VALUE mirror)
+ {
+ std::tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, std::tr1::shared_ptr<Repository>, self_ptr);
+ if (!(**self_ptr)[k::mirrors_interface()])
+ return Qnil;
+ VALUE result(rb_ary_new());
+ for (RepositoryMirrorsInterface::MirrorsConstIterator m((**self_ptr)[k::mirrors_interface()]->begin_mirrors(StringValuePtr(mirror))),
+ m_end((**self_ptr)[k::mirrors_interface()]->end_mirrors(StringValuePtr(mirror))) ;
+ m != m_end ; ++m)
+ rb_ary_push(result, rb_str_new2((m->second).c_str()));
+ return result;
+ }
+
void do_register_repository()
{
/*
@@ -953,6 +990,9 @@ namespace
RUBY_FUNC_CAST((&RepositoryKey<MetadataValueKey<FSEntry>, &Repository::installed_root_key>::fetch)), 0);
rb_define_method(c_repository, "get_environment_variable", RUBY_FUNC_CAST(&repository_get_environment_variable), 2);
+ rb_define_method(c_repository, "is_mirror?", RUBY_FUNC_CAST(&repository_is_mirror), 1);
+ rb_define_method(c_repository, "mirrors", RUBY_FUNC_CAST(&repository_mirrors), 1);
+
/*
* Document-class: Paludis::ProfilesDescLine
*