aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2006-12-04 21:58:46 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2006-12-04 21:58:46 +0000
commitc594ec7021de939630f618430ac98995efdbc90d (patch)
treef50ac95430d5d2232f56c7ab1b01006538d302f1
parent8b0fbd2fe65cd7aff018fc31729b5b60c2c9bf14 (diff)
downloadpaludis-c594ec7021de939630f618430ac98995efdbc90d.tar.gz
paludis-c594ec7021de939630f618430ac98995efdbc90d.tar.xz
Add Repository.installed_time to ruby binding.
-rw-r--r--ruby/repository.cc27
-rw-r--r--ruby/repository_TEST.rb16
2 files changed, 39 insertions, 4 deletions
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 49b5646..c8ef766 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -263,6 +263,32 @@ namespace
}
}
+ VALUE
+ repository_installed_time(VALUE self, VALUE qpn, VALUE vs)
+ {
+ try
+ {
+ Repository::ConstPointer * self_ptr;
+ Data_Get_Struct(self, Repository::ConstPointer, self_ptr);
+ const RepositoryInstalledInterface * const installed_interface ((**self_ptr).installed_interface);
+ if (installed_interface)
+ {
+ return rb_time_new(installed_interface->installed_time(
+ value_to_qualified_package_name(qpn),
+ value_to_version_spec(vs)
+ ), 0);
+ }
+ else
+ {
+ return Qnil;
+ }
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_repository()
{
c_repository = rb_define_class_under(paludis_module(), "Repository", rb_cObject);
@@ -308,6 +334,7 @@ namespace
rb_define_method(c_repository, "info", RUBY_FUNC_CAST(&repository_info), 1);
rb_define_method(c_repository, "contents", RUBY_FUNC_CAST(&repository_contents), 2);
+ rb_define_method(c_repository, "installed_time", RUBY_FUNC_CAST(&repository_installed_time), 2);
c_repository_info = rb_define_class_under(paludis_module(), "RepositoryInfo", rb_cObject);
rb_funcall(c_repository_info, rb_intern("private_class_method"), 1, rb_str_new2("new"));
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index f0a187d..b3c1025 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -133,6 +133,9 @@ module Paludis
def test_interfaces
assert_equal repo.name, repo.installable_interface.name
assert_nil repo.installed_interface
+
+ assert_equal installed_repo.name, installed_repo.installed_interface.name
+ assert_nil installed_repo.installable_interface
end
end
@@ -144,10 +147,6 @@ module Paludis
entries = contents.entries
end
- def test_installed
- assert_not_nil installed_repo.installed_interface
- end
-
def test_contents
contents = installed_repo.contents('cat-one/pkg-one','1')
assert_kind_of Contents, contents
@@ -180,5 +179,14 @@ module Paludis
assert_equal '/test/test_link', entries[2].name
end
end
+
+ class TestCase_RepositoryInstalledTime < Test::Unit::TestCase
+ include RepositoryTestCase
+
+ def test_time
+ time = installed_repo.installed_time('cat-one/pkg-one','1')
+ assert_kind_of Time, time
+ end
+ end
end