aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 15:26:48 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:59 +0100
commita004eeed5dda3432dcb1a4c0a865ae24daae4fd3 (patch)
tree69188ac33eeb2acd1860315e7f794a42f19e6358 /ruby
parent52a4c781098800f3b2831134f5e94434729c46a5 (diff)
downloadpaludis-a004eeed5dda3432dcb1a4c0a865ae24daae4fd3.tar.gz
paludis-a004eeed5dda3432dcb1a4c0a865ae24daae4fd3.tar.xz
installable to repository to requirements
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_spec.cc40
-rw-r--r--ruby/dep_spec_TEST.rb13
-rw-r--r--ruby/package_dep_spec_constraint.cc48
3 files changed, 70 insertions, 31 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index aa377fc52..da98fb9f8 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -704,59 +704,53 @@ namespace
/*
* call-seq:
- * installable_to_repository -> Hash or Nil
+ * installed_at_path_constraint ->
+ * InstalledAtPathConstraint or Nil
*
- * Fetch the installable-to-repository requirement.
+ * Fetch the installed-at-path requirement.
*/
VALUE
- package_dep_spec_installable_to_repository(VALUE self)
+ package_dep_spec_installed_at_path_constraint(VALUE self)
{
std::shared_ptr<WrappedSpecBase> * ptr;
Data_Get_Struct(self, std::shared_ptr<WrappedSpecBase>, ptr);
- std::shared_ptr<const InstallableToRepository> i2r(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_ptr());
- if (! i2r)
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint()))
return Qnil;
- VALUE result(rb_hash_new());
- rb_hash_aset(result, ID2SYM(rb_intern("repository")),
- rb_str_new2(stringify(i2r->repository()).c_str()));
- rb_hash_aset(result, ID2SYM(rb_intern("include_masked?")),
- i2r->include_masked() ? Qtrue : Qfalse);
- return result;
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint());
}
/*
* call-seq:
- * installed_at_path_constraint ->
- * InstalledAtPathConstraint or Nil
+ * installable_to_path_constraint -> InstallableToPathConstraint or Nil
*
- * Fetch the installed-at-path requirement.
+ * Fetch the installable-to-path constraint.
*/
VALUE
- package_dep_spec_installed_at_path_constraint(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);
- if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_constraint()))
return Qnil;
- return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint());
+ return package_dep_spec_constraint_to_value(
+ std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_constraint());
}
/*
* call-seq:
- * installable_to_path_constraint ->
- * InstallableToPathConstraintPool or Nil
+ * installable_to_path_constraint -> InstallableToRepositoryConstraint or Nil
*
* Fetch the installable-to-path constraint.
*/
VALUE
- package_dep_spec_installable_to_path_constraint(VALUE self)
+ package_dep_spec_installable_to_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()->installable_to_path_constraint()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_constraint()))
return Qnil;
return package_dep_spec_constraint_to_value(
- std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_path_constraint());
+ std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installable_to_repository_constraint());
}
/*
@@ -1112,7 +1106,7 @@ namespace
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_constraint", RUBY_FUNC_CAST(&package_dep_spec_in_repository_constraint), 0);
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, "installable_to_repository_constraint", RUBY_FUNC_CAST(&package_dep_spec_installable_to_repository_constraint), 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_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);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 80e32f351..7e3db1b9c 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -164,13 +164,12 @@ module Paludis
end
def test_installable_to_repository
- assert_nil pda.installable_to_repository
- assert_nil pdb.installable_to_repository
- assert_kind_of Hash, pdc.installable_to_repository
- assert_equal "installed", pdc.installable_to_repository[:repository]
- assert ! pdc.installable_to_repository[:include_masked?]
- assert_nil pdd.installable_to_repository
- assert_nil pde.installable_to_repository
+ assert_nil pda.installable_to_repository_constraint
+ assert_nil pdb.installable_to_repository_constraint
+ assert_equal "installed", pdc.installable_to_repository_constraint.name
+ assert ! pdc.installable_to_repository_constraint.include_masked?
+ assert_nil pdd.installable_to_repository_constraint
+ assert_nil pde.installable_to_repository_constraint
end
def test_installed_at_path
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 360caab8e..4d4ed3852 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -38,6 +38,7 @@ namespace
static VALUE c_from_repository_constraint;
static VALUE c_installed_at_path_constraint;
static VALUE c_installable_to_path_constraint;
+ static VALUE c_installable_to_repository_constraint;
struct V
{
@@ -90,6 +91,12 @@ namespace
value = Data_Wrap_Struct(c_installable_to_path_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const InstallableToRepositoryConstraint &)
+ {
+ value = Data_Wrap_Struct(c_installable_to_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -196,6 +203,32 @@ namespace
return (std::static_pointer_cast<const InstallableToPathConstraint>(*ptr))->include_masked() ? Qtrue : Qfalse;
}
+ /*
+ * Document-method: name
+ *
+ * The name constraint.
+ */
+ static VALUE
+ installable_to_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 InstallableToRepositoryConstraint>(*ptr))->name()).c_str());
+ }
+
+ /*
+ * Document-method: include_masked?
+ *
+ * The include-masked constraint.
+ */
+ static VALUE
+ installable_to_repository_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 InstallableToRepositoryConstraint>(*ptr))->include_masked() ? Qtrue : Qfalse;
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -274,7 +307,7 @@ namespace
/*
* Document-class: Paludis::InstallableToPathConstraint
*
- * Represents a ::/ path constraint in a PackageDepSpec.
+ * Represents a ::/? path constraint in a PackageDepSpec.
*/
c_installable_to_path_constraint = rb_define_class_under(
paludis_module(), "InRepositoryConstraint", c_package_dep_spec_constraint);
@@ -283,6 +316,19 @@ namespace
&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);
+
+ /*
+ * Document-class: Paludis::InstallableToRepositoryConstraint
+ *
+ * Represents a ::repo? repository constraint in a PackageDepSpec.
+ */
+ c_installable_to_repository_constraint = rb_define_class_under(
+ paludis_module(), "InstallableToRepositoryConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_installable_to_repository_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_installable_to_repository_constraint, "name", RUBY_FUNC_CAST(
+ &installable_to_repository_constraint_name), 0);
+ rb_define_method(c_installable_to_repository_constraint, "include_masked?", RUBY_FUNC_CAST(
+ &installable_to_repository_constraint_include_masked), 0);
}
}