aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 11:03:54 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:58 +0100
commit5574c81a3c60266d023d18dfc115803da8b12e6b (patch)
tree659da456cb9813045fd32067a3db11d7c7d7ce82 /ruby
parentb7f5d7dbfeff2e406ef24ca471657e1735a4db4f (diff)
downloadpaludis-5574c81a3c60266d023d18dfc115803da8b12e6b.tar.gz
paludis-5574c81a3c60266d023d18dfc115803da8b12e6b.tar.xz
category and package parts to requirements
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_spec.cc28
-rw-r--r--ruby/dep_spec_TEST.rb20
-rw-r--r--ruby/package_dep_spec_constraint.cc62
3 files changed, 85 insertions, 25 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index b6628e8d7..4584a2e78 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -580,7 +580,7 @@ namespace
/*
* call-seq:
- * package_name_constraint -> PackageDepSpecConstraint or Nil
+ * package_name_constraint -> NameConstraint or Nil
*
* Fetch the package name constraint (may be Nil).
*/
@@ -596,36 +596,34 @@ namespace
/*
* call-seq:
- * package_name_part -> String or Nil
+ * package_name_part_constraint -> PackageNamePartConstraint or Nil
*
- * Fetch the package name part.
+ * Fetch the package name part constraint (may be Nil).
*/
VALUE
- package_dep_spec_package_name_part(VALUE self)
+ package_dep_spec_package_name_part_constraint(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_constraint()))
return Qnil;
- return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->
- package_name_part_ptr()).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->package_name_part_constraint());
}
/*
* call-seq:
- * category_name_part -> String or Nil
+ * category_name_part_constraint -> CategoryNamePartConstraint or Nil
*
- * Fetch the category name part.
+ * Fetch the category name part constraint (may be Nil).
*/
VALUE
- package_dep_spec_category_name_part(VALUE self)
+ package_dep_spec_category_name_part_constraint(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_constraint()))
return Qnil;
- return rb_str_new2(stringify(*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->
- category_name_part_ptr()).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->category_name_part_constraint());
}
/*
@@ -1112,8 +1110,8 @@ namespace
*/
c_package_dep_spec = rb_define_class_under(paludis_module(), "PackageDepSpec", c_string_dep_spec);
rb_define_method(c_package_dep_spec, "package_name_constraint", RUBY_FUNC_CAST(&package_dep_spec_package_name_constraint), 0);
- rb_define_method(c_package_dep_spec, "package_name_part", RUBY_FUNC_CAST(&package_dep_spec_package_name_part), 0);
- rb_define_method(c_package_dep_spec, "category_name_part", RUBY_FUNC_CAST(&package_dep_spec_category_name_part), 0);
+ rb_define_method(c_package_dep_spec, "package_name_part_constraint", RUBY_FUNC_CAST(&package_dep_spec_package_name_part_constraint), 0);
+ rb_define_method(c_package_dep_spec, "category_name_part_constraint", RUBY_FUNC_CAST(&package_dep_spec_category_name_part_constraint), 0);
rb_define_method(c_package_dep_spec, "slot_requirement", RUBY_FUNC_CAST(&package_dep_spec_slot_requirement_ptr), 0);
rb_define_method(c_package_dep_spec, "in_repository", RUBY_FUNC_CAST(&package_dep_spec_in_repository_ptr), 0);
rb_define_method(c_package_dep_spec, "from_repository", RUBY_FUNC_CAST(&package_dep_spec_from_repository_ptr), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 6c5363f3b..7c585544f 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -192,19 +192,19 @@ module Paludis
end
def test_package_name_part
- assert_nil pda.package_name_part
- assert_equal "bar", pdb.package_name_part
- assert_nil pdc.package_name_part
- assert_nil pdd.package_name_part
- assert_nil pde.package_name_part
+ assert_nil pda.package_name_part_constraint
+ assert_equal "bar", pdb.package_name_part_constraint.name_part
+ assert_nil pdc.package_name_part_constraint
+ assert_nil pdd.package_name_part_constraint
+ assert_nil pde.package_name_part_constraint
end
def test_category_name_part
- assert_nil pda.category_name_part
- assert_nil pdb.category_name_part
- assert_nil pdc.category_name_part
- assert_equal "foo", pdd.category_name_part
- assert_nil pde.category_name_part
+ assert_nil pda.category_name_part_constraint
+ assert_nil pdb.category_name_part_constraint
+ assert_nil pdc.category_name_part_constraint
+ assert_equal "foo", pdd.category_name_part_constraint.name_part
+ assert_nil pde.category_name_part_constraint
end
def test_version_requirements
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 4cfd42f67..925b70e2d 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -32,6 +32,8 @@ namespace
{
static VALUE c_package_dep_spec_constraint;
static VALUE c_name_constraint;
+ static VALUE c_package_name_part_constraint;
+ static VALUE c_category_name_part_constraint;
struct V
{
@@ -48,6 +50,18 @@ namespace
value = Data_Wrap_Struct(c_name_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const CategoryNamePartConstraint &)
+ {
+ value = Data_Wrap_Struct(c_category_name_part_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
+
+ void visit(const PackageNamePartConstraint &)
+ {
+ value = Data_Wrap_Struct(c_package_name_part_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -63,6 +77,32 @@ namespace
return qualified_package_name_to_value((std::static_pointer_cast<const NameConstraint>(*ptr))->name());
}
+ /*
+ * Document-method: name_part
+ *
+ * The name part constraint.
+ */
+ static VALUE
+ package_name_part_constraint_name_part(VALUE self)
+ {
+ std::shared_ptr<const PackageDepSpecConstraint> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr);
+ return rb_str_new2(stringify((std::static_pointer_cast<const PackageNamePartConstraint>(*ptr))->name_part()).c_str());
+ }
+
+ /*
+ * Document-method: name_part
+ *
+ * The name part constraint.
+ */
+ static VALUE
+ category_name_part_constraint_name_part(VALUE self)
+ {
+ std::shared_ptr<const PackageDepSpecConstraint> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr);
+ return rb_str_new2(stringify((std::static_pointer_cast<const CategoryNamePartConstraint>(*ptr))->name_part()).c_str());
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -82,6 +122,28 @@ namespace
paludis_module(), "NameConstraint", c_package_dep_spec_constraint);
rb_funcall(c_name_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_package_dep_spec_constraint, "name", RUBY_FUNC_CAST(&name_constraint_name), 0);
+
+ /*
+ * Document-class: Paludis::PackageNamePartConstraint
+ *
+ * Represents a /pkg name constraint in a PackageDepSpec.
+ */
+ c_package_name_part_constraint = rb_define_class_under(
+ paludis_module(), "PackageNamePartConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_package_name_part_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_package_name_part_constraint, "name_part", RUBY_FUNC_CAST(
+ &package_name_part_constraint_name_part), 0);
+
+ /*
+ * Document-class: Paludis::CategoryNamePartConstraint
+ *
+ * Represents a /pkg name constraint in a PackageDepSpec.
+ */
+ c_category_name_part_constraint = rb_define_class_under(
+ paludis_module(), "CategoryNamePartConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_category_name_part_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_category_name_part_constraint, "name_part", RUBY_FUNC_CAST(
+ &category_name_part_constraint_name_part), 0);
}
}