diff options
author | 2011-03-29 13:23:41 +0100 | |
---|---|---|
committer | 2011-04-04 08:32:59 +0100 | |
commit | bc262ad74eb8d80eb979a5c5591b222d5fc1eb36 (patch) | |
tree | 6da646abbdea2c1948347abe2679fa1f79be1d15 /ruby | |
parent | 63ca918976505d042587bf7591dfce41b206b8cc (diff) | |
download | paludis-bc262ad74eb8d80eb979a5c5591b222d5fc1eb36.tar.gz paludis-bc262ad74eb8d80eb979a5c5591b222d5fc1eb36.tar.xz |
installed at path to requirements
Diffstat (limited to 'ruby')
-rw-r--r-- | ruby/dep_spec.cc | 11 | ||||
-rw-r--r-- | ruby/dep_spec_TEST.rb | 10 | ||||
-rw-r--r-- | ruby/package_dep_spec_constraint.cc | 31 |
3 files changed, 42 insertions, 10 deletions
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc index ff3deb6ec..7c13eabdd 100644 --- a/ruby/dep_spec.cc +++ b/ruby/dep_spec.cc @@ -726,18 +726,19 @@ namespace /* * call-seq: - * installed_at_path -> String or Nil + * installed_at_path_constraint -> + * InstalledAtPathConstraint or Nil * * Fetch the installed-at-path requirement. */ VALUE - package_dep_spec_installed_at_path(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); - if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_ptr())) + if (! bool(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint())) return Qnil; - return rb_str_new2(stringify((*std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_ptr())).c_str()); + return package_dep_spec_constraint_to_value(std::static_pointer_cast<const WrappedSpec<PackageDepSpec> >(*ptr)->spec()->installed_at_path_constraint()); } /* @@ -1116,7 +1117,7 @@ namespace 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, "installed_at_path", RUBY_FUNC_CAST(&package_dep_spec_installed_at_path), 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, "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); diff --git a/ruby/dep_spec_TEST.rb b/ruby/dep_spec_TEST.rb index 58b88178a..565968e93 100644 --- a/ruby/dep_spec_TEST.rb +++ b/ruby/dep_spec_TEST.rb @@ -174,11 +174,11 @@ module Paludis end def test_installed_at_path - assert_nil pda.installed_at_path - assert_nil pdb.installed_at_path - assert_nil pdc.installed_at_path - assert_nil pdd.installed_at_path - assert_equal "/mychroot", pde.installed_at_path + assert_nil pda.installed_at_path_constraint + assert_nil pdb.installed_at_path_constraint + assert_nil pdc.installed_at_path_constraint + assert_nil pdd.installed_at_path_constraint + assert_equal "/mychroot", pde.installed_at_path_constraint.path end def test_installable_to_path diff --git a/ruby/package_dep_spec_constraint.cc b/ruby/package_dep_spec_constraint.cc index 9e4757b55..10e6509fc 100644 --- a/ruby/package_dep_spec_constraint.cc +++ b/ruby/package_dep_spec_constraint.cc @@ -36,6 +36,7 @@ namespace static VALUE c_category_name_part_constraint; static VALUE c_in_repository_constraint; static VALUE c_from_repository_constraint; + static VALUE c_installed_at_path_constraint; struct V { @@ -76,6 +77,12 @@ namespace value = Data_Wrap_Struct(c_from_repository_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, new std::shared_ptr<const PackageDepSpecConstraint>(mm)); } + + void visit(const InstalledAtPathConstraint &) + { + value = Data_Wrap_Struct(c_installed_at_path_constraint, 0, &Common<std::shared_ptr<const PackageDepSpecConstraint> >::free, + new std::shared_ptr<const PackageDepSpecConstraint>(mm)); + } }; /* @@ -143,6 +150,19 @@ namespace return rb_str_new2(stringify((std::static_pointer_cast<const FromRepositoryConstraint>(*ptr))->name()).c_str()); } + /* + * Document-method: path + * + * The path constraint. + */ + static VALUE + installed_at_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 InstalledAtPathConstraint>(*ptr))->path()).c_str()); + } + void do_register_package_dep_spec_constraint() { /* @@ -206,6 +226,17 @@ namespace 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); + + /* + * Document-class: Paludis::InstalledAtPathConstraint + * + * Represents a ::/ path constraint in a PackageDepSpec. + */ + c_installed_at_path_constraint = rb_define_class_under( + paludis_module(), "InRepositoryConstraint", c_package_dep_spec_constraint); + 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); } } |