aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-06 13:21:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-01-07 11:32:56 +0000
commit81ef7b0468950cade215c889d47143db21720695 (patch)
tree9fe89084961f1bbf5c35619f82d802e457443b8a /ruby
parent20cc98f89f0208619fa8845d784463f03a7c9234 (diff)
downloadpaludis-81ef7b0468950cade215c889d47143db21720695.tar.gz
paludis-81ef7b0468950cade215c889d47143db21720695.tar.xz
Pass ID to match_package
Diffstat (limited to 'ruby')
-rw-r--r--ruby/dep_list_TEST.rb2
-rw-r--r--ruby/environment_TEST.rb20
-rw-r--r--ruby/generator.cc9
-rw-r--r--ruby/generator_TEST.rb8
-rw-r--r--ruby/package_id.cc5
-rw-r--r--ruby/paludis_ruby.cc11
-rw-r--r--ruby/paludis_ruby.hh4
-rw-r--r--ruby/paludis_ruby_TEST.rb16
-rw-r--r--ruby/repository_TEST.rb6
9 files changed, 43 insertions, 38 deletions
diff --git a/ruby/dep_list_TEST.rb b/ruby/dep_list_TEST.rb
index cf8457996..056ba64f6 100644
--- a/ruby/dep_list_TEST.rb
+++ b/ruby/dep_list_TEST.rb
@@ -206,7 +206,7 @@ module Paludis
def test_add_bad_tree
assert_raise TypeError do
dl.add(env[Selection::BestVersionOnly.new(Generator::Matches.new(
- pda, []))].last.build_dependencies_key.value, dd)
+ pda, nil, []))].last.build_dependencies_key.value, dd)
end
end
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index 22ac5c4c1..dd76c4d5c 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
# Copyright (c) 2007, 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -80,7 +80,7 @@ module Paludis
def pid
env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), nil, []))].first
end
def test_accept_license
@@ -88,7 +88,7 @@ module Paludis
assert !env.accept_license('Failure', pid)
pid2 = env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/baz-1.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/baz-1.0::testrepo', env, []), nil, []))].first
assert env.accept_license('GPL-2', pid2)
assert env.accept_license('Failure', pid2)
end
@@ -107,7 +107,7 @@ module Paludis
def pid
env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), nil, []))].first
end
def test_accept_keywords
@@ -311,7 +311,7 @@ module Paludis
end
def test_package_database_query
- a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, []))]
+ a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, nil, []))]
assert_kind_of Array, a
assert_equal 1, a.length
pid = a.first
@@ -320,7 +320,7 @@ module Paludis
assert_equal '1.0', pid.version.to_s
assert_equal 'testrepo', pid.repository_name
- a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, []) | Filter::SupportsAction.new(InstallAction))]
+ a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, nil, []) | Filter::SupportsAction.new(InstallAction))]
assert_kind_of Array, a
assert_equal 1, a.length
pid = a.first
@@ -329,7 +329,7 @@ module Paludis
assert_equal '1.0', pid.version.to_s
assert_equal 'testrepo', pid.repository_name
- a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, []))]
+ a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, nil, []))]
assert_kind_of Array, a
assert_equal 1, a.length
pid = a.first
@@ -338,7 +338,7 @@ module Paludis
assert_equal '1.0', pid.version.to_s
assert_equal 'testrepo', pid.repository_name
- a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda2, []) | Filter::SupportsAction.new(InstallAction))]
+ a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda2, nil, []) | Filter::SupportsAction.new(InstallAction))]
assert_kind_of Array, a
assert_equal 2, a.length
pid = a.shift
@@ -368,10 +368,10 @@ module Paludis
a = env[Selection::AllVersionsUnsorted.new(Generator::Matches.new(Paludis::parse_user_package_dep_spec(
- '>=foo/bar-27', env, []), []))]
+ '>=foo/bar-27', env, []), nil, []))]
assert a.empty?
- a = env[Selection::AllVersionsUnsorted.new(Generator::Matches.new(pda2, []) | Filter::SupportsAction.new(ConfigAction))]
+ a = env[Selection::AllVersionsUnsorted.new(Generator::Matches.new(pda2, nil, []) | Filter::SupportsAction.new(ConfigAction))]
assert a.empty?
end
end
diff --git a/ruby/generator.cc b/ruby/generator.cc
index 16631b992..5d6f753eb 100644
--- a/ruby/generator.cc
+++ b/ruby/generator.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2011 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -110,14 +110,15 @@ namespace
}
VALUE
- generator_matches_new(VALUE self, VALUE spec_v, VALUE options_v)
+ generator_matches_new(VALUE self, VALUE spec_v, VALUE id_v, VALUE options_v)
{
Generator * ptr(0);
try
{
std::shared_ptr<const PackageDepSpec> spec(value_to_package_dep_spec(spec_v));
+ std::shared_ptr<const PackageID> id(value_to_package_id(id_v, true));
MatchPackageOptions options(value_to_match_package_options(options_v));
- ptr = new generator::Matches(*spec, options);
+ ptr = new generator::Matches(*spec, id, options);
VALUE data(Data_Wrap_Struct(self, 0, &Common<Generator>::free, ptr));
rb_obj_call_init(data, 2, &spec_v);
return data;
@@ -300,7 +301,7 @@ namespace
* Generate matching packages.
*/
c_generator_matches = rb_define_class_under(c_generator_module, "Matches", c_generator);
- rb_define_singleton_method(c_generator_matches, "new", RUBY_FUNC_CAST(&generator_matches_new), 2);
+ rb_define_singleton_method(c_generator_matches, "new", RUBY_FUNC_CAST(&generator_matches_new), 3);
/*
* Document-class: Paludis::Generator::Intersection
diff --git a/ruby/generator_TEST.rb b/ruby/generator_TEST.rb
index e4dd336a5..7b91c0820 100644
--- a/ruby/generator_TEST.rb
+++ b/ruby/generator_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2008 Ciaran McCreesh
+# Copyright (c) 2008, 2011 Ciaran McCreesh
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
@@ -51,15 +51,15 @@ module Paludis
def test_create
assert_nothing_raised do
- Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []), [])
+ Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []), nil, [])
end
end
def test_to_s
- assert_equal Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []), []).to_s,
+ assert_equal Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []), nil, []).to_s,
"packages matching a/b"
assert_equal Generator::Matches.new(Paludis::parse_user_package_dep_spec("a/b", env, []),
- [:ignore_additional_requirements]).to_s,
+ nil, [:ignore_additional_requirements]).to_s,
"packages matching a/b (ignoring additional requirements)"
end
end
diff --git a/ruby/package_id.cc b/ruby/package_id.cc
index 71dab061f..e7ba44b8e 100644
--- a/ruby/package_id.cc
+++ b/ruby/package_id.cc
@@ -576,8 +576,11 @@ paludis::ruby::package_id_to_value(std::shared_ptr<const PackageID> m)
}
std::shared_ptr<const PackageID>
-paludis::ruby::value_to_package_id(VALUE v)
+paludis::ruby::value_to_package_id(VALUE v, bool nil_ok)
{
+ if (nil_ok && rb_obj_is_kind_of(v, rb_cNilClass))
+ return std::shared_ptr<const PackageID>();
+
if (rb_obj_is_kind_of(v, c_package_id))
{
std::shared_ptr<const PackageID> * v_ptr;
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 95d68140b..661c62d60 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
* Copyright (c) 2006, 2007, 2008 Richard Brown
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -79,20 +79,21 @@ namespace
* Document-method: match_package
*
* call-seq:
- * match_package(environment, package_dep_spec, package_id, options) -> true or false
+ * match_package(environment, package_dep_spec, package_id, from_package_id, options) -> true or false
*
* Return whether the specified PackageID matches the specified PackageDepSpec.
*
*/
- VALUE paludis_match_package(VALUE, VALUE en, VALUE a, VALUE t, VALUE o)
+ VALUE paludis_match_package(VALUE, VALUE en, VALUE a, VALUE t, VALUE f, VALUE o)
{
try
{
std::shared_ptr<Environment> env = value_to_environment(en);
std::shared_ptr<const PackageDepSpec> spec = value_to_package_dep_spec(a);
std::shared_ptr<const PackageID> target = value_to_package_id(t);
+ std::shared_ptr<const PackageID> from_package_id = value_to_package_id(f, true);
MatchPackageOptions options(value_to_match_package_options(o));
- return match_package(*env, *spec, target, options) ? Qtrue : Qfalse;
+ return match_package(*env, *spec, target, from_package_id, options) ? Qtrue : Qfalse;
}
catch (const std::exception & e)
{
@@ -427,7 +428,7 @@ void PALUDIS_VISIBLE paludis::ruby::init()
*/
c_bad_version_operator_error = rb_define_class_under(c_paludis_module, "BadVersionOperatorError", rb_eRuntimeError);
- rb_define_module_function(c_paludis_module, "match_package", RUBY_FUNC_CAST(&paludis_match_package), 4);
+ rb_define_module_function(c_paludis_module, "match_package", RUBY_FUNC_CAST(&paludis_match_package), 5);
rb_define_module_function(c_paludis_module, "match_package_in_set", RUBY_FUNC_CAST(&paludis_match_package_in_set), 4);
rb_define_module_function(c_paludis_module, "version_spec_comparator", RUBY_FUNC_CAST(&paludis_version_spec_comparator), 3);
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 8ac703083..bb86a76c9 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
* Copyright (c) 2006, 2007, 2008 Richard Brown
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -110,7 +110,7 @@ namespace paludis
VALUE bool_to_value(bool b);
VersionSpec value_to_version_spec(VALUE v);
- std::shared_ptr<const PackageID> value_to_package_id(VALUE);
+ std::shared_ptr<const PackageID> value_to_package_id(VALUE, bool nil_ok = false);
std::shared_ptr<const PackageDepSpec> value_to_package_dep_spec(VALUE v);
std::shared_ptr<const DependenciesLabelsDepSpec> value_to_dependencies_labels_dep_spec(VALUE v);
std::shared_ptr<const DepSpec> value_to_dep_spec(VALUE v);
diff --git a/ruby/paludis_ruby_TEST.rb b/ruby/paludis_ruby_TEST.rb
index 8a830fc3e..2bd9d6dd1 100644
--- a/ruby/paludis_ruby_TEST.rb
+++ b/ruby/paludis_ruby_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2011 Ciaran McCreesh
# Copyright (c) 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -42,10 +42,10 @@ module Paludis
spec_good = Paludis::parse_user_package_dep_spec('>=foo/bar-1', env, [])
spec_bad = Paludis::parse_user_package_dep_spec('>=foo/bar-2', env, [])
pid = env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), nil, []))].first
- assert Paludis::match_package(env, spec_good, pid, [])
- assert !Paludis::match_package(env, spec_bad, pid, [])
+ assert Paludis::match_package(env, spec_good, pid, nil, [])
+ assert !Paludis::match_package(env, spec_bad, pid, nil, [])
end
@@ -53,7 +53,7 @@ module Paludis
env = EnvironmentFactory.instance.create("")
world = env.set('world')
pid = env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), nil, []))].first
assert Paludis::match_package_in_set(env, world, pid, [])
end
@@ -62,14 +62,14 @@ module Paludis
env = EnvironmentFactory.instance.create("")
spec = Paludis::parse_user_package_dep_spec('>=foo/bar-1', env, [])
pid = env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/bar-1.0::testrepo', env, []), nil, []))].first
assert_raise TypeError do
- Paludis::match_package(spec,spec,pid, [])
+ Paludis::match_package(spec,spec,pid, nil, [])
end
assert_raise TypeError do
- Paludis::match_package(env,spec,spec, [])
+ Paludis::match_package(env,spec,spec, nil, [])
end
end
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 3e0260817..82aae2678 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
# Copyright (c) 2006, 2007, 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -55,7 +55,7 @@ module Paludis
def p
env[Selection::RequireExactlyOne.new(Generator::Matches.new(
- Paludis::parse_user_package_dep_spec('=foo/bar-2.0::testrepo', env, []), []))].first
+ Paludis::parse_user_package_dep_spec('=foo/bar-2.0::testrepo', env, []), nil, []))].first
end
def installed_pid
@@ -185,7 +185,7 @@ module Paludis
def test_get_environment_variable
pid = env[Selection::BestVersionOnly.new(Generator::Matches.new(Paludis::parse_user_package_dep_spec(
- '=foo/bar-1.0', env, []), []))].first;
+ '=foo/bar-1.0', env, []), nil, []))].first;
assert_equal "hello", repo.get_environment_variable(pid, "TEST_ENV_VAR")
assert_equal "", repo.get_environment_variable(pid, "TEST_UNSET_ENV_VAR")
end