aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-04 21:34:18 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-09-04 21:34:18 +0100
commitc90d4dec7920a8d70949d8e2e71e704d2800d2c1 (patch)
treeb27391f20de3e33d4bfe074e6a5f9592d4fb3465 /ruby
parent9a153e42f9703672b5a9de6d24d6a35697b05531 (diff)
downloadpaludis-c90d4dec7920a8d70949d8e2e71e704d2800d2c1.tar.gz
paludis-c90d4dec7920a8d70949d8e2e71e704d2800d2c1.tar.xz
PackageID::contents
Diffstat (limited to 'ruby')
-rw-r--r--ruby/package_id.cc30
-rw-r--r--ruby/package_id_TEST.rb5
2 files changed, 32 insertions, 3 deletions
diff --git a/ruby/package_id.cc b/ruby/package_id.cc
index d661866a6..10d9fa12f 100644
--- a/ruby/package_id.cc
+++ b/ruby/package_id.cc
@@ -342,6 +342,35 @@ namespace
}
/*
+ * Document-method: contents
+ *
+ * call-seq:
+ * contents -> Contents
+ *
+ * Our Contents
+ */
+ VALUE
+ package_id_contents(VALUE self)
+ {
+ std::shared_ptr<const PackageID> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageID>, self_ptr);
+ try
+ {
+ auto contents((*self_ptr)->contents());
+ if (! contents)
+ return Qnil;
+ else
+ return contents_to_value(contents);
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+
+ return Qnil;
+ }
+
+ /*
* Document-method: masked?
*
* call-seq:
@@ -558,6 +587,7 @@ namespace
rb_define_method(c_package_id, "behaviours_key", RUBY_FUNC_CAST((
&KeyValue<MetadataCollectionKey<Set<std::string> >, &PackageID::behaviours_key>::fetch)), 0);
rb_define_method(c_package_id, "uniquely_identifying_spec", RUBY_FUNC_CAST(&package_id_uniquely_identifying_spec), 0);
+ rb_define_method(c_package_id, "contents", RUBY_FUNC_CAST(&package_id_contents), 0);
/*
* Document-module: Paludis::PackageIDCanonicalForm
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index d287c2435..4921baab0 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -302,9 +302,8 @@ module Paludis
assert_nil pid_installed.long_description_key
end
- def test_contents_key
- assert_kind_of MetadataContentsKey, pid_installed.contents_key
- assert_kind_of Contents, pid_installed.contents_key.parse_value
+ def test_contents
+ assert_kind_of Contents, pid_installed.contents
end
def test_installed_time_key