aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-29 12:40:53 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-04-04 08:32:59 +0100
commit63ca918976505d042587bf7591dfce41b206b8cc (patch)
treef54fcf53236ecd673dffe431b3df5cbca3ffe9f0 /ruby
parent7d346bba37dfe95c858fa727bbc63bbc42074f30 (diff)
downloadpaludis-63ca918976505d042587bf7591dfce41b206b8cc.tar.gz
paludis-63ca918976505d042587bf7591dfce41b206b8cc.tar.xz
from repository to requirements
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_spec.cc12
-rw-r--r--ruby/dep_spec_TEST.rb10
-rw-r--r--ruby/package_dep_spec_constraint.cc31
3 files changed, 42 insertions, 11 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 8da862611..ff3deb6ec 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -688,18 +688,18 @@ namespace
/*
* call-seq:
- * from_repository -> String or Nil
+ * from_repository_constraint -> FromRepositoryConstraint or Nil
*
- * Fetch the from-repository name.
+ * Fetch the from-repository constraint.
*/
VALUE
- package_dep_spec_from_repository_ptr(VALUE self)
+ package_dep_spec_from_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()->from_repository_ptr()))
+ if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_constraint()))
return Qnil;
- return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_ptr())).c_str());
+ return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->from_repository_constraint());
}
/*
@@ -1114,7 +1114,7 @@ namespace
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_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, "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", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path), 0);
rb_define_method(c_package_dep_spec, "installable_to_path", RUBY_FUNC_CAST(&package_dep_spec_installable_to_path), 0);
diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb
index 1a1e2b145..58b88178a 100644
--- a/ruby/dep_spec_TEST.rb
+++ b/ruby/dep_spec_TEST.rb
@@ -148,11 +148,11 @@ module Paludis
end
def test_from_repository
- assert_nil pda.from_repository
- assert_nil pdb.from_repository
- assert_nil pdc.from_repository
- assert_nil pdd.from_repository
- assert_equal "testrepo", pde.from_repository
+ assert_nil pda.from_repository_constraint
+ assert_nil pdb.from_repository_constraint
+ assert_nil pdc.from_repository_constraint
+ assert_nil pdd.from_repository_constraint
+ assert_equal "testrepo", pde.from_repository_constraint.name
end
def test_in_repository
diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc
index 1ae743d9c..9e4757b55 100644
--- a/ruby/package_dep_spec_constraint.cc
+++ b/ruby/package_dep_spec_constraint.cc
@@ -35,6 +35,7 @@ namespace
static VALUE c_package_name_part_constraint;
static VALUE c_category_name_part_constraint;
static VALUE c_in_repository_constraint;
+ static VALUE c_from_repository_constraint;
struct V
{
@@ -69,6 +70,12 @@ namespace
value = Data_Wrap_Struct(c_in_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
new std::shared_ptr<const PackageDepSpecConstraint>(mm));
}
+
+ void visit(const FromRepositoryConstraint &)
+ {
+ value = Data_Wrap_Struct(c_from_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free,
+ new std::shared_ptr<const PackageDepSpecConstraint>(mm));
+ }
};
/*
@@ -123,6 +130,19 @@ namespace
return rb_str_new2(stringify((std::static_pointer_cast<const InRepositoryConstraint>(*ptr))->name()).c_str());
}
+ /*
+ * Document-method: name
+ *
+ * The name constraint.
+ */
+ static VALUE
+ from_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 FromRepositoryConstraint>(*ptr))->name()).c_str());
+ }
+
void do_register_package_dep_spec_constraint()
{
/*
@@ -175,6 +195,17 @@ namespace
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);
+
+ /*
+ * Document-class: Paludis::FromRepositoryConstraint
+ *
+ * Represents a /pkg name constraint in a PackageDepSpec.
+ */
+ c_from_repository_constraint = rb_define_class_under(
+ paludis_module(), "InRepositoryConstraint", c_package_dep_spec_constraint);
+ rb_funcall(c_from_repository_constraint, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_from_repository_constraint, "name", RUBY_FUNC_CAST(
+ &from_repository_constraint_name), 0);
}
}