aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-04 14:35:57 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-04 14:35:57 +0000
commitfcc837994326a9b9866f427570fd411b1bfaecef (patch)
treef16c34e3d70a6df2849122d1e26e7549408fdbe7
parent3ca769781d39756e7b50790160394f9fdc7c4d58 (diff)
downloadpaludis-fcc837994326a9b9866f427570fd411b1bfaecef.tar.gz
paludis-fcc837994326a9b9866f427570fd411b1bfaecef.tar.xz
(ruby) Add missing DependencyDepTag methods.
-rw-r--r--ruby/dep_tag.cc45
-rw-r--r--ruby/dep_tag_TEST.rb25
2 files changed, 70 insertions, 0 deletions
diff --git a/ruby/dep_tag.cc b/ruby/dep_tag.cc
index 084a8e8..1a2a953 100644
--- a/ruby/dep_tag.cc
+++ b/ruby/dep_tag.cc
@@ -106,6 +106,48 @@ namespace
}
}
+ /*
+ * call-seq:
+ * package_id -> PackageID
+ *
+ * The PackageID that contains our dependency.
+ */
+ VALUE
+ dependency_dep_tag_package_id(VALUE self)
+ {
+ tr1::shared_ptr<const DepTag> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepTag>, ptr);
+ return package_id_to_value((tr1::static_pointer_cast<const DependencyDepTag>(*ptr))->package_id());
+ }
+
+ /*
+ * call-seq:
+ * dependency -> PackageDepSpec
+ *
+ * The PackageDepSpec that pulled us in.
+ */
+ VALUE
+ dependency_dep_tag_dependency(VALUE self)
+ {
+ tr1::shared_ptr<const DepTag> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepTag>, ptr);
+ return package_dep_spec_to_value((tr1::static_pointer_cast<const DependencyDepTag>(*ptr))->dependency());
+ }
+
+ /*
+ * call-seq:
+ * conditions -> DepSpec
+ *
+ * The AnyDepSpec instances and UseDepSpec instances that our dependency
+ * is conditional upon.
+ */
+ VALUE
+ dependency_dep_tag_conditions(VALUE self)
+ {
+ tr1::shared_ptr<const DepTag> * ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<const DepTag>, ptr);
+ return dep_tree_to_value<DependencySpecTree>((tr1::static_pointer_cast<const DependencyDepTag>(*ptr))->conditions());
+ }
VALUE
glsa_dep_tag_new(int argc, VALUE * argv, VALUE self)
@@ -255,6 +297,9 @@ namespace
*/
c_dependency_dep_tag = rb_define_class_under(paludis_module(), "DependencyDepTag", c_dep_tag);
rb_define_singleton_method(c_dependency_dep_tag, "new", RUBY_FUNC_CAST(&dependency_dep_tag_new), -1);
+ rb_define_method(c_dependency_dep_tag, "package_id", RUBY_FUNC_CAST(&dependency_dep_tag_package_id), 0);
+ rb_define_method(c_dependency_dep_tag, "dependency", RUBY_FUNC_CAST(&dependency_dep_tag_dependency), 0);
+ rb_define_method(c_dependency_dep_tag, "conditions", RUBY_FUNC_CAST(&dependency_dep_tag_conditions), 0);
/*
* Document-class: Paludis::GLSADepTag
diff --git a/ruby/dep_tag_TEST.rb b/ruby/dep_tag_TEST.rb
index 97d25d1..36b007f 100644
--- a/ruby/dep_tag_TEST.rb
+++ b/ruby/dep_tag_TEST.rb
@@ -70,6 +70,31 @@ module Paludis
assert_equal val, dt.send(method)
end
end
+
+ def test_package_id
+ dt = get_dt
+ assert_respond_to dt, :package_id
+ id = dt.package_id
+ assert_kind_of PackageID, id
+ assert_equal "foo/bar-1.0::testrepo", id.to_s
+ end
+
+ def test_dependency
+ dt = get_dt
+ assert_respond_to dt, :dependency
+ pds = dt.dependency
+ assert_kind_of PackageDepSpec, pds
+ assert_equal "foo/bar", pds.to_s
+ end
+
+ # XXX extend this once we can define a non-trival condition in ruby
+ def test_conditions
+ dt = get_dt
+ assert_respond_to dt, :conditions
+ cond = dt.conditions
+ assert_kind_of AllDepSpec, cond
+ assert_equal 0, cond.to_a.length
+ end
end
class TestCase_GLSADepTag < Test::Unit::TestCase