aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2006-12-12 19:23:20 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2006-12-12 19:23:20 +0000
commit2ae07833255d715d323e4d0bfd352806c83898ea (patch)
treebb23e180918303294dd622decb238de95dc52e17
parenta1a2bf0914d2bea3abcf2ac171c7df7558bcc53b (diff)
downloadpaludis-2ae07833255d715d323e4d0bfd352806c83898ea.tar.gz
paludis-2ae07833255d715d323e4d0bfd352806c83898ea.tar.xz
Add some member functions to PackageDepAtom ruby binding.
-rw-r--r--ruby/dep_atom.cc64
-rw-r--r--ruby/dep_atom_TEST.rb24
2 files changed, 86 insertions, 2 deletions
diff --git a/ruby/dep_atom.cc b/ruby/dep_atom.cc
index 9f2937a..5c8950f 100644
--- a/ruby/dep_atom.cc
+++ b/ruby/dep_atom.cc
@@ -173,6 +173,66 @@ namespace
return self;
}
+ /*
+ * call-seq:
+ * package -> String
+ *
+ * Fetch the package name.
+ */
+ VALUE
+ package_dep_atom_package(VALUE self)
+ {
+ PackageDepAtom::ConstPointer * ptr;
+ Data_Get_Struct(self, PackageDepAtom::ConstPointer, ptr);
+ return rb_str_new2(stringify((*ptr)->package()).c_str());
+ }
+
+ /*
+ * call-seq:
+ * text -> String
+ *
+ * Fetch our text.
+ */
+ VALUE
+ package_dep_atom_text(VALUE self)
+ {
+ PackageDepAtom::ConstPointer * ptr;
+ Data_Get_Struct(self, PackageDepAtom::ConstPointer, ptr);
+ return rb_str_new2(stringify((*ptr)->text()).c_str());
+ }
+
+ /*
+ * call-seq:
+ * slot -> String or Nil
+ *
+ * Fetch the slot name.
+ */
+ VALUE
+ package_dep_atom_slot_ptr(VALUE self)
+ {
+ PackageDepAtom::ConstPointer * ptr;
+ Data_Get_Struct(self, PackageDepAtom::ConstPointer, ptr);
+ if (0 == (*ptr)->slot_ptr())
+ return Qnil;
+ return rb_str_new2(stringify((*(*ptr)->slot_ptr())).c_str());
+ }
+
+ /*
+ * call-seq:
+ * repository -> String or Nil
+ *
+ * Fetch the repository name.
+ */
+ VALUE
+ package_dep_atom_repository_ptr(VALUE self)
+ {
+ PackageDepAtom::ConstPointer * ptr;
+ Data_Get_Struct(self, PackageDepAtom::ConstPointer, ptr);
+ if (0 == (*ptr)->repository_ptr())
+ return Qnil;
+ return rb_str_new2(stringify((*(*ptr)->repository_ptr())).c_str());
+ }
+
void do_register_dep_atom()
{
/*
@@ -237,6 +297,10 @@ namespace
rb_define_singleton_method(c_package_dep_atom, "new", RUBY_FUNC_CAST(&DepAtomThings<PackageDepAtom>::dep_atom_new_1), 1);
rb_define_method(c_package_dep_atom, "initialize", RUBY_FUNC_CAST(&dep_atom_init_1), 1);
rb_define_method(c_package_dep_atom, "to_s", RUBY_FUNC_CAST(&Common<PackageDepAtom::ConstPointer>::to_s_via_ptr), 0);
+ rb_define_method(c_package_dep_atom, "package", RUBY_FUNC_CAST(&package_dep_atom_package), 0);
+ rb_define_method(c_package_dep_atom, "text", RUBY_FUNC_CAST(&package_dep_atom_text), 0);
+ rb_define_method(c_package_dep_atom, "slot", RUBY_FUNC_CAST(&package_dep_atom_slot_ptr), 0);
+ rb_define_method(c_package_dep_atom, "repository", RUBY_FUNC_CAST(&package_dep_atom_repository_ptr), 0);
/*
* Document-class: Paludis::PlainTextDepAtom
diff --git a/ruby/dep_atom_TEST.rb b/ruby/dep_atom_TEST.rb
index a948888..6200b31 100644
--- a/ruby/dep_atom_TEST.rb
+++ b/ruby/dep_atom_TEST.rb
@@ -40,8 +40,12 @@ module Paludis
end
class TestCase_PackageDepAtom < Test::Unit::TestCase
+ def pda
+ PackageDepAtom.new('>=foo/bar-1:100::testrepo')
+ end
+
def test_create
- v = PackageDepAtom.new(">=foo/bar-1")
+ pda
end
def test_create_error
@@ -54,7 +58,23 @@ module Paludis
end
def test_to_s
- assert_equal ">=foo/bar-1", PackageDepAtom.new(">=foo/bar-1").to_s
+ assert_equal ">=foo/bar-1:100::testrepo", pda.to_s
+ end
+
+ def test_text
+ assert_equal ">=foo/bar-1:100::testrepo", pda.text
+ end
+
+ def test_slot
+ assert_equal "100", pda.slot
+ end
+
+ def test_package
+ assert_equal "foo/bar", pda.package
+ end
+
+ def test_repository
+ assert_equal "testrepo", pda.repository
end
end