aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 14:43:22 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:59 +0100
commit52a4c781098800f3b2831134f5e94434729c46a5 (patch)
tree55499ba5305132e315d51633332ee18289df5adb /ruby
parentbc262ad74eb8d80eb979a5c5591b222d5fc1eb36 (diff)
downloadpaludis-52a4c781098800f3b2831134f5e94434729c46a5.tar.gz
paludis-52a4c781098800f3b2831134f5e94434729c46a5.tar.xz
installable to path to requirements
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_spec.cc20
-rw-r--r--ruby/dep_spec_TEST.rb13
-rw-r--r--ruby/package_dep_spec_constraint.cc46
3 files changed, 60 insertions, 19 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 7c13eabdd..aa377fc52 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -743,24 +743,20 @@ namespace
/*
* call-seq:
- * installable_to_path -> Hash or Nil
+ * installable_to_path_constraint ->
+ * InstallableToPathConstraintPool or Nil
*
- * Fetch the installable-to-path requirement.
+ * Fetch the installable-to-path constraint.
*/
VALUE
- package_dep_spec_installable_to_path(VALUE self)
+ package_dep_spec_installable_to_path_constraint(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- std::shared_ptr<const InstallableToPath> i2p(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_ptr());
- if (! i2p)
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_constraint()))
return Qnil;
- VALUE result(rb_hash_new());
- rb_hash_aset(result, ID2SYM(rb_intern("path")),
- rb_str_new2(stringify(i2p->path()).c_str()));
- rb_hash_aset(result, ID2SYM(rb_intern("include_masked?")),
- i2p->include_masked() ? Qtrue : Qfalse);
- return result;
+ return package_dep_spec_constraint_to_value(
+ std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_constraint());
}
/*
@@ -1118,7 +1114,7 @@ namespace
rb_define_method(c_package_dep_spec, "from_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_from_repository_constraint), 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_constraint", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path_constraint), 0);
- rb_define_method(c_package_dep_spec, "installable_to_path", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path), 0);
+ rb_define_method(c_package_dep_spec, "installable_to_path_constraint", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path_constraint), 0);
rb_define_method(c_package_dep_spec, "version_requirements", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_ptr), 0);
rb_define_method(c_package_dep_spec, "version_requirements_mode", RUBY_FUNC_CAST(&package_dep_spec_version_requirements_mode), 0);
#ifdef CIARANM_REMOVED_THIS
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 565968e93..80e32f351 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -182,13 +182,12 @@ module Paludis
end
def test_installable_to_path
- assert_nil pda.installable_to_path
- assert_nil pdb.installable_to_path
- assert_nil pdc.installable_to_path
- assert_kind_of Hash, pdd.installable_to_path
- assert_equal "/", pdd.installable_to_path[:path]
- assert pdd.installable_to_path[:include_masked?]
- assert_nil pde.installable_to_path
+ assert_nil pda.installable_to_path_constraint
+ assert_nil pdb.installable_to_path_constraint
+ assert_nil pdc.installable_to_path_constraint
+ assert_equal "/", pdd.installable_to_path_constraint.path
+ assert pdd.installable_to_path_constraint.include_masked?
+ assert_nil pde.installable_to_path_constraint
end
def test_package_name_part
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 10e6509fc..360caab8e 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -37,6 +37,7 @@ namespace
static VALUE c_in_repository_constraint;
static VALUE c_from_repository_constraint;
static VALUE c_installed_at_path_constraint;
+ static VALUE c_installable_to_path_constraint;
struct V
{
@@ -83,6 +84,12 @@ namespace
value = Data_Wrap_Struct(c_installed_at_path_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const InstallableToPathConstraint &)
+ {
+ value = Data_Wrap_Struct(c_installable_to_path_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -163,6 +170,32 @@ namespace
return rb_str_new2(stringify((std::static_pointer_cast<const InstalledAtPathConstraint>(*ptr))->path()).c_str());
}
+ /*
+ * Document-method: path
+ *
+ * The path constraint.
+ */
+ static VALUE
+ installable_to_path_constraint_path(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 InstallableToPathConstraint>(*ptr))->path()).c_str());
+ }
+
+ /*
+ * Document-method: include_masked?
+ *
+ * The include-masked constraint.
+ */
+ static VALUE
+ installable_to_path_constraint_include_masked(VALUE self)
+ {
+ std::shared_ptr<const PackageDepSpecConstraint> * ptr;
+ Data_Get_Struct(self, std::shared_ptr<const PackageDepSpecConstraint>, ptr);
+ return (std::static_pointer_cast<const InstallableToPathConstraint>(*ptr))->include_masked() ? Qtrue : Qfalse;
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -237,6 +270,19 @@ namespace
rb_funcall(c_installed_at_path_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
rb_define_method(c_installed_at_path_constraint, "path", RUBY_FUNC_CAST(
&installed_at_path_constraint_path), 0);
+
+ /*
+ * Document-class: Paludis::InstallableToPathConstraint
+ *
+ * Represents a ::/ path constraint in a PackageDepSpec.
+ */
+ c_installable_to_path_constraint = rb_define_class_under(
+ paludis_module(), "InRepositoryConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_installable_to_path_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_installable_to_path_constraint, "path", RUBY_FUNC_CAST(
+ &installable_to_path_constraint_path), 0);
+ rb_define_method(c_installable_to_path_constraint, "include_masked?", RUBY_FUNC_CAST(
+ &installable_to_path_constraint_include_masked), 0);
}
}