aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 12:01:02 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:59 +0100
commit7d346bba37dfe95c858fa727bbc63bbc42074f30 (patch)
treec1cfaffcbe3f9bfd1b41ddef24d26372a8a2fb4b /ruby
parent5574c81a3c60266d023d18dfc115803da8b12e6b (diff)
downloadpaludis-7d346bba37dfe95c858fa727bbc63bbc42074f30.tar.gz
paludis-7d346bba37dfe95c858fa727bbc63bbc42074f30.tar.xz
in repository to requirements
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_spec.cc10
-rw-r--r--ruby/dep_spec_TEST.rb10
-rw-r--r--ruby/package_dep_spec_constraint.cc31
3 files changed, 41 insertions, 10 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 4584a2e78..8da862611 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -672,18 +672,18 @@ namespace
/*
* call-seq:
- * in_repository -> String or Nil
+ * in_repository_constraint -> InRepositoryConstraint or Nil
*
* Fetch the in-repository name.
*/
VALUE
- package_dep_spec_in_repository_ptr(VALUE self)
+ package_dep_spec_in_repository_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()->in_repository_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_constraint()))
return Qnil;
- return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_ptr())).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->in_repository_constraint());
}
/*
@@ -1113,7 +1113,7 @@ namespace
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, "in_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_in_repository_constraint), 0);
rb_define_method(c_package_dep_spec, "from_repository", RUBY_FUNC_CAST(&package_dep_spec_from_repository_ptr), 0);
rb_define_method(c_package_dep_spec, "installable_to_repository", RUBY_FUNC_CAST(&package_dep_spec_installable_to_repository), 0);
rb_define_method(c_package_dep_spec, "installed_at_path", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 7c585544f..1a1e2b145 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -156,11 +156,11 @@ module Paludis
end
def test_in_repository
- assert_equal "testrepo", pda.in_repository
- assert_nil pdb.in_repository
- assert_nil pdc.in_repository
- assert_nil pdd.in_repository
- assert_nil pde.in_repository
+ assert_equal "testrepo", pda.in_repository_constraint.name
+ assert_nil pdb.in_repository_constraint
+ assert_nil pdc.in_repository_constraint
+ assert_nil pdd.in_repository_constraint
+ assert_nil pde.in_repository_constraint
end
def test_installable_to_repository
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 925b70e2d..1ae743d9c 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -34,6 +34,7 @@ namespace
static VALUE c_name_constraint;
static VALUE c_package_name_part_constraint;
static VALUE c_category_name_part_constraint;
+ static VALUE c_in_repository_constraint;
struct V
{
@@ -62,6 +63,12 @@ namespace
value = Data_Wrap_Struct(c_package_name_part_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const InRepositoryConstraint &)
+ {
+ value = Data_Wrap_Struct(c_in_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -103,6 +110,19 @@ namespace
return rb_str_new2(stringify((std::static_pointer_cast<const CategoryNamePartConstraint>(*ptr))->name_part()).c_str());
}
+ /*
+ * Document-method: name
+ *
+ * The name constraint.
+ */
+ static VALUE
+ in_repository_constraint_name(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 InRepositoryConstraint>(*ptr))->name()).c_str());
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -144,6 +164,17 @@ namespace
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);
+
+ /*
+ * Document-class: Paludis::InRepositoryConstraint
+ *
+ * Represents a /pkg name constraint in a PackageDepSpec.
+ */
+ c_in_repository_constraint = rb_define_class_under(
+ paludis_module(), "InRepositoryConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_in_repository_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_in_repository_constraint, "name", RUBY_FUNC_CAST(
+ &in_repository_constraint_name), 0);
}
}