aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-26 10:33:03 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-10-26 10:33:03 +0000
commit8b31d155b1b9de15139ba7fa7d008b9ca792d548 (patch)
treee22650c054466ad69fcf5daf1844fe4c4adcb8dc
parent4f409fa9676f1864914e27670fee7980eabeeea2 (diff)
downloadpaludis-8b31d155b1b9de15139ba7fa7d008b9ca792d548.tar.gz
paludis-8b31d155b1b9de15139ba7fa7d008b9ca792d548.tar.xz
Add dep string support
-rw-r--r--ruby/version_metadata.cc19
-rw-r--r--ruby/version_metadata_TEST.rb8
-rwxr-xr-xruby/version_metadata_TEST_setup.sh2
3 files changed, 29 insertions, 0 deletions
diff --git a/ruby/version_metadata.cc b/ruby/version_metadata.cc
index 41d1fa3..b53ea19 100644
--- a/ruby/version_metadata.cc
+++ b/ruby/version_metadata.cc
@@ -107,6 +107,18 @@ namespace
}
};
+ template <std::string VersionMetadataDeps::* m_>
+ struct DependValueString
+ {
+ static VALUE
+ fetch(VALUE self)
+ {
+ VersionMetadata::ConstPointer * self_ptr;
+ Data_Get_Struct(self, VersionMetadata::ConstPointer, self_ptr);
+ return rb_str_new2(((&(*self_ptr)->deps)->*m_).c_str());
+ }
+ };
+
void do_register_version_metadata()
{
c_version_metadata = rb_define_class_under(master_class(), "VersionMetadata", rb_cObject);
@@ -147,6 +159,13 @@ namespace
&VersionMetadataDeps::run_depend>::fetch)), 0);
rb_define_method(c_version_metadata, "post_depend", RUBY_FUNC_CAST((&DependValue<
&VersionMetadataDeps::post_depend>::fetch)), 0);
+
+ rb_define_method(c_version_metadata, "build_depend_string", RUBY_FUNC_CAST((&DependValueString<
+ &VersionMetadataDeps::build_depend_string>::fetch)), 0);
+ rb_define_method(c_version_metadata, "run_depend_string", RUBY_FUNC_CAST((&DependValueString<
+ &VersionMetadataDeps::run_depend_string>::fetch)), 0);
+ rb_define_method(c_version_metadata, "post_depend_string", RUBY_FUNC_CAST((&DependValueString<
+ &VersionMetadataDeps::post_depend_string>::fetch)), 0);
}
}
diff --git a/ruby/version_metadata_TEST.rb b/ruby/version_metadata_TEST.rb
index df88900..6433e93 100644
--- a/ruby/version_metadata_TEST.rb
+++ b/ruby/version_metadata_TEST.rb
@@ -73,6 +73,14 @@ class Paludis
assert_kind_of AllDepAtom, vmd("1.0").build_depend
assert_kind_of AllDepAtom, vmd("1.0").run_depend
assert_kind_of AllDepAtom, vmd("1.0").post_depend
+
+ assert_equal 1, vmd("1.0").build_depend.to_a.length
+ assert vmd("1.0").run_depend.to_a.empty?
+ assert vmd("1.0").post_depend.to_a.empty?
+
+ assert_equal "foo/bar", vmd("1.0").build_depend_string.gsub(/\s/, "")
+ assert_equal "", vmd("1.0").run_depend_string.gsub(/\s/, "")
+ assert_equal "", vmd("1.0").post_depend_string.gsub(/\s/, "")
end
end
end
diff --git a/ruby/version_metadata_TEST_setup.sh b/ruby/version_metadata_TEST_setup.sh
index 5ad102f..28e4f8a 100755
--- a/ruby/version_metadata_TEST_setup.sh
+++ b/ruby/version_metadata_TEST_setup.sh
@@ -28,6 +28,8 @@ IUSE=""
LICENSE="GPL-2"
KEYWORDS="test"
RESTRICT="monkey"
+DEPEND="foo/bar"
+RDEPEND=""
END
cd ..