aboutsummaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 18:58:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-03-26 19:00:38 +0000
commit5c2a332b70243cb583a29bb74f712bfca2c1fb76 (patch)
tree0a01f8e624caa2c6639181df45fa80bc20adba84 /ruby
parent79d9f02fb355d81c472f3d94b8b85d5a7639210c (diff)
downloadpaludis-5c2a332b70243cb583a29bb74f712bfca2c1fb76.tar.gz
paludis-5c2a332b70243cb583a29bb74f712bfca2c1fb76.tar.xz
Use Environment rather than PackageDatabase
Diffstat (limited to 'ruby')
-rw-r--r--ruby/Makefile.am3
-rw-r--r--ruby/choice_TEST.rb4
-rwxr-xr-xruby/demos/find_unmanaged_files.rb1
-rwxr-xr-xruby/demos/latest_stable.rb2
-rwxr-xr-xruby/demos/playman.rb2
-rwxr-xr-xruby/demos/version_spec_distributions.rb2
-rw-r--r--ruby/dep_spec.cc2
-rw-r--r--ruby/environment.cc190
-rw-r--r--ruby/environment_TEST.rb125
-rw-r--r--ruby/package_database.cc233
-rw-r--r--ruby/package_database_TEST.rb138
-rwxr-xr-xruby/package_database_TEST_cleanup.sh13
-rwxr-xr-xruby/package_database_TEST_setup.sh90
-rw-r--r--ruby/package_id_TEST.rb6
-rw-r--r--ruby/paludis_ruby.cc17
-rw-r--r--ruby/paludis_ruby.hh1
-rw-r--r--ruby/repository.cc2
-rw-r--r--ruby/repository_TEST.rb4
18 files changed, 276 insertions, 559 deletions
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index 149d06a02..ade8df5ca 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -28,7 +28,6 @@ IF_RUBY_TESTS = \
filtered_generator_TEST.rb \
generator_TEST.rb \
log_TEST.rb \
- package_database_TEST.rb \
package_id_TEST.rb \
paludis_ruby_TEST.rb \
qualified_package_name_TEST.rb \
@@ -51,7 +50,6 @@ IF_RUBY_SOURCES = \
metadata_key.cc \
name.cc \
nice_names-nn.hh nice_names-nn.cc \
- package_database.cc \
package_id.cc \
paludis_ruby.cc paludis_ruby.hh \
qualified_package_name.cc \
@@ -69,7 +67,6 @@ EXTRA_DIST = $(IF_RUBY_TESTS) $(IF_RUBY_SOURCES) \
environment_TEST_setup.sh environment_TEST_cleanup.sh \
generator_TEST_setup.sh generator_TEST_cleanup.sh \
nice_names.nn \
- package_database_TEST_setup.sh package_database_TEST_cleanup.sh \
package_id_TEST_setup.sh package_id_TEST_cleanup.sh \
paludis_ruby_TEST_setup.sh paludis_ruby_TEST_cleanup.sh \
repository_TEST_setup.sh repository_TEST_cleanup.sh \
diff --git a/ruby/choice_TEST.rb b/ruby/choice_TEST.rb
index 1dd94d907..20f9ddfa0 100644
--- a/ruby/choice_TEST.rb
+++ b/ruby/choice_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
@@ -33,7 +33,7 @@ module Paludis
end
def pid
- env.package_database.fetch_repository("testrepo").package_ids("foo/bar").first
+ env.fetch_repository("testrepo").package_ids("foo/bar").first
end
def choices
diff --git a/ruby/demos/find_unmanaged_files.rb b/ruby/demos/find_unmanaged_files.rb
index c15f5a703..d41f7c135 100755
--- a/ruby/demos/find_unmanaged_files.rb
+++ b/ruby/demos/find_unmanaged_files.rb
@@ -72,7 +72,6 @@ opts.each do | opt, arg |
end
env = Paludis::EnvironmentFactory.instance.create env_spec
-db = env.package_database
root = env.preferred_root_key.value[-1] == ?/ ? env.preferred_root_key.value.chop : env.preferred_root_key.value
directories = []
diff --git a/ruby/demos/latest_stable.rb b/ruby/demos/latest_stable.rb
index 0a86079e4..5ddc5ab97 100755
--- a/ruby/demos/latest_stable.rb
+++ b/ruby/demos/latest_stable.rb
@@ -100,7 +100,7 @@ def check_one_package(env, search_keywords, repo, pkg)
end
end
-env.package_database.repositories.each do |repo|
+env.repositories.each do |repo|
next if repo.virtuals_interface.nil?
repo.category_names.each do |cat|
repo.package_names(cat).each do |pkg|
diff --git a/ruby/demos/playman.rb b/ruby/demos/playman.rb
index 3d55bc51d..730274bb6 100755
--- a/ruby/demos/playman.rb
+++ b/ruby/demos/playman.rb
@@ -146,7 +146,7 @@ if ARGV.empty?
end
end
-repositories = $env.package_database.repositories
+repositories = $env.repositories
begin
req = Net::HTTP::Get.new($laymanglobal_url.request_uri)
diff --git a/ruby/demos/version_spec_distributions.rb b/ruby/demos/version_spec_distributions.rb
index bac3e19f1..582a63abc 100755
--- a/ruby/demos/version_spec_distributions.rb
+++ b/ruby/demos/version_spec_distributions.rb
@@ -130,7 +130,7 @@ end
distribution = Distribution.new
env = Paludis::NoConfigEnvironment.new repository_dir, write_cache_dir, master_repository_dir
-env.package_database.repositories.each do | repo |
+env.repositories.each do | repo |
distribution.add_repository repo
end
if output_image
diff --git a/ruby/dep_spec.cc b/ruby/dep_spec.cc
index 405d2d05c..9f6790bc0 100644
--- a/ruby/dep_spec.cc
+++ b/ruby/dep_spec.cc
@@ -915,7 +915,7 @@ namespace
* GotASetNotAPackageDepSpec exception if the string is a set name and :no_disambiguation
* to disallow disambiguation (require an explicit category). The Filter, if
* provided, is used to restrict disambiguation as per
- * PackageDatabase#fetch_unique_qualified_package_name.
+ * Environment#fetch_unique_qualified_package_name.
*
*/
VALUE paludis_parse_user_dep_spec(int argc, VALUE * argv, VALUE)
diff --git a/ruby/environment.cc b/ruby/environment.cc
index 6f86ab004..ac9db1191 100644
--- a/ruby/environment.cc
+++ b/ruby/environment.cc
@@ -67,25 +67,6 @@ namespace
/*
* call-seq:
- * package_database -> PackageDatabase
- *
- * Fetch our PackageDatabase.
- */
- VALUE
- environment_package_database(VALUE self)
- {
- try
- {
- return package_database_to_value(value_to_environment(self)->package_database());
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
* set(set_name) -> DepSpec
*
* Fetch a named package set as a DepSpec.
@@ -439,6 +420,164 @@ namespace
}
}
+ /*
+ * call-seq:
+ * fetch_unique_qualified_package_name(package_name) -> QualifiedPackageName
+ * fetch_unique_qualified_package_name(package_name, filter) -> QualifiedPackageName
+ *
+ * Disambiguate a package name. If a filter is specified, limit
+ * the potential results to packages that match.
+ */
+ VALUE
+ environment_fetch_unique_qualified_package_name(int argc, VALUE *argv, VALUE self)
+ {
+ try
+ {
+ if (1 == argc || 2 == argc)
+ {
+ std::shared_ptr<Environment> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<Environment>, self_ptr);
+ return qualified_package_name_to_value((*self_ptr)->fetch_unique_qualified_package_name(
+ PackageNamePart(StringValuePtr(argv[0])), 2 == argc ? value_to_filter(argv[1]) : filter::All()));
+ }
+ else
+ rb_raise(rb_eArgError, "fetch_unique_qualified_package_name expects one or two arguments, but got %d",argc);
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * repositories -> Array
+ * repositories {|repository| block } -> Nil
+ *
+ * Returns all the repositories in the package database, either as an Array, or as
+ * the parameters to a block.
+ */
+ VALUE
+ environment_repositories(VALUE self)
+ {
+ try
+ {
+ std::shared_ptr<Environment> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<Environment>, self_ptr);
+
+ if (rb_block_given_p())
+ {
+ for (Environment::RepositoryConstIterator r((*self_ptr)->begin_repositories()),
+ r_end((*self_ptr)->end_repositories()) ; r != r_end ; ++r)
+ rb_yield(repository_to_value(*r));
+ return Qnil;
+ }
+ VALUE result(rb_ary_new());
+ for (Environment::RepositoryConstIterator r((*self_ptr)->begin_repositories()),
+ r_end((*self_ptr)->end_repositories()) ; r != r_end ; ++r)
+ rb_ary_push(result, repository_to_value(*r));
+
+ return result;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * fetch_repository(repository_name) -> Repository
+ *
+ * Fetch a named repository.
+ */
+ VALUE
+ environment_fetch_repository(VALUE self, VALUE name)
+ {
+ try
+ {
+ std::shared_ptr<Environment> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<Environment>, self_ptr);
+
+ return repository_to_value((*self_ptr)->fetch_repository(RepositoryName(StringValuePtr(name))));
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * more_important_than(repository_name_a, repository_name_b) -> bool
+ *
+ * True if repository_name_a is more important than repository_name_b .
+ */
+ VALUE
+ environment_more_important_than(VALUE self, VALUE name1, VALUE name2)
+ {
+ try
+ {
+ std::shared_ptr<Environment> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<Environment>, self_ptr);
+
+ return (*self_ptr)->more_important_than(RepositoryName(StringValuePtr(name1)),
+ RepositoryName(StringValuePtr(name2))) ? Qtrue : Qfalse;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * has_repository_named?(repository_name) -> true or false
+ *
+ * Do we have a named repository?
+ */
+ VALUE
+ environment_has_repository_named(VALUE self, VALUE name)
+ {
+ try
+ {
+ std::shared_ptr<Environment> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<Environment>, self_ptr);
+
+ return ((*self_ptr)->has_repository_named(RepositoryName(StringValuePtr(name)))) ? true : false;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * add_repository(importance, repository) -> nil
+ *
+ * Add a repository.
+ */
+ VALUE
+ environment_add_repository(VALUE self, VALUE importance, VALUE repo_v)
+ {
+ try
+ {
+ std::shared_ptr<Environment> * self_ptr;
+ Data_Get_Struct(self, std::shared_ptr<Environment>, self_ptr);
+
+ std::shared_ptr<Repository> repo(value_to_repository(repo_v));
+
+ (*self_ptr)->add_repository(NUM2INT(importance), repo);
+ return Qnil;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+
void do_register_environment()
{
rb_require("singleton");
@@ -451,7 +590,6 @@ namespace
*/
c_environment = rb_define_class_under(paludis_module(), "Environment", rb_cObject);
rb_funcall(c_environment, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_environment, "package_database", RUBY_FUNC_CAST(&environment_package_database), 0);
rb_define_method(c_environment, "set", RUBY_FUNC_CAST(&environment_set), 1);
rb_define_method(c_environment, "distribution", RUBY_FUNC_CAST(&environment_distribution), 0);
rb_define_method(c_environment, "accept_license", RUBY_FUNC_CAST(&environment_accept_license), 2);
@@ -464,6 +602,18 @@ namespace
RUBY_FUNC_CAST((&EnvironmentKey<MetadataValueKey<FSPath>, &Environment::config_location_key>::fetch)), 0);
rb_define_method(c_environment, "preferred_root_key",
RUBY_FUNC_CAST((&EnvironmentKey<MetadataValueKey<FSPath>, &Environment::preferred_root_key>::fetch)), 0);
+ rb_define_method(c_environment, "fetch_unique_qualified_package_name",
+ RUBY_FUNC_CAST(&environment_fetch_unique_qualified_package_name), -1);
+ rb_define_method(c_environment, "repositories",
+ RUBY_FUNC_CAST(&environment_repositories), 0);
+ rb_define_method(c_environment, "fetch_repository",
+ RUBY_FUNC_CAST(&environment_fetch_repository), 1);
+ rb_define_method(c_environment, "more_important_than",
+ RUBY_FUNC_CAST(&environment_more_important_than), 2);
+ rb_define_method(c_environment, "has_repository_named?",
+ RUBY_FUNC_CAST(&environment_has_repository_named), 1);
+ rb_define_method(c_environment, "add_repository",
+ RUBY_FUNC_CAST(&environment_add_repository), 2);
/*
* Document-class: Paludis::PaludisEnvironment
diff --git a/ruby/environment_TEST.rb b/ruby/environment_TEST.rb
index 536850dac..fd348ecdc 100644
--- a/ruby/environment_TEST.rb
+++ b/ruby/environment_TEST.rb
@@ -129,36 +129,6 @@ module Paludis
end
end
- class TestCase_EnvironmentPackageDatabase < Test::Unit::TestCase
- def env
- @env or @env = EnvironmentFactory.instance.create("")
- end
-
- def db
- env.package_database
- end
-
- def test_package_database
- assert_kind_of PackageDatabase, db
- assert_equal "testrepo", db.fetch_repository("testrepo").name
- end
- end
-
- class TestCase_NoConfigEnvironmentPackageDatabase < Test::Unit::TestCase
- def env
- NoConfigEnvironment.new(Dir.getwd().to_s + "/environment_TEST_dir/testrepo")
- end
-
- def db
- env.package_database
- end
-
- def test_package_database
- assert_kind_of PackageDatabase, db
- assert_equal "testrepo", db.fetch_repository("testrepo").name
- end
- end
-
class TestCase_EnvironmentPackageSet < Test::Unit::TestCase
def env
@env or @env = EnvironmentFactory.instance.create("")
@@ -262,10 +232,6 @@ module Paludis
@env or @env = EnvironmentFactory.instance.create("")
end
- def db
- return env.package_database
- end
-
def pda
Paludis::parse_user_package_dep_spec('=foo/bar-1.0', env, [])
end
@@ -280,7 +246,7 @@ module Paludis
end
end
- def test_package_database_query
+ def test_environment_query
a = env[Selection::AllVersionsSorted.new(Generator::Matches.new(pda, nil, []))]
assert_kind_of Array, a
assert_equal 1, a.length
@@ -383,5 +349,94 @@ module Paludis
x = TestEnvironment.new()
end
end
+
+ class TestCase_EnvironmentFetchUniqueQualifiedPackageName < Test::Unit::TestCase
+ def env
+ @env or @env = EnvironmentFactory.instance.create("")
+ end
+
+ def test_environment_fetch_unique_qualified_package_name
+ assert_equal "foo/bar", env.fetch_unique_qualified_package_name("bar")
+ assert_equal "foo/bar", env.fetch_unique_qualified_package_name("bar", Filter::SupportsAction.new(InstallAction))
+ end
+
+ def test_error
+ assert_raise NoSuchPackageError do
+ env.fetch_unique_qualified_package_name('foobarbaz')
+ end
+ assert_raise NoSuchPackageError do
+ env.fetch_unique_qualified_package_name('bar', Filter::SupportsAction.new(ConfigAction))
+ end
+ end
+
+ def test_bad
+ assert_raise ArgumentError do
+ env.fetch_unique_qualified_package_name
+ end
+ assert_raise ArgumentError do
+ env.fetch_unique_qualified_package_name(1, 2, 3)
+ end
+ assert_raise TypeError do
+ env.fetch_unique_qualified_package_name([])
+ end
+ assert_raise TypeError do
+ env.fetch_unique_qualified_package_name('bar', 123)
+ end
+ end
+ end
+
+ class TestCase_EnvironmentRepositories < Test::Unit::TestCase
+ def env
+ @env or @env = EnvironmentFactory.instance.create("")
+ end
+
+ def test_repositories
+ if ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "yes" then
+ assert_equal 3, env.repositories.length
+ else
+ assert_equal 1, env.repositories.length
+ end
+
+ a = env.repositories.find_all do | repo |
+ repo.name == "testrepo"
+ end
+ assert_equal 1, a.length
+
+ a = env.repositories.find_all do | repo |
+ repo.name == "foorepo"
+ end
+ assert a.empty?
+
+ assert_equal nil, env.repositories {|repo| assert_kind_of Repository, repo}
+ end
+
+ def test_fetch_repository
+ assert_equal "testrepo", env.fetch_repository("testrepo").name
+
+ assert_raise Paludis::NoSuchRepositoryError do
+ env.fetch_repository("barrepo")
+ end
+ end
+
+ def test_more_important_than
+ if ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "yes" then
+ assert env.more_important_than('testrepo', 'virtuals')
+ assert ! env.more_important_than('virtuals', 'testrepo')
+ elsif ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "no" then
+ else
+ throw "oops"
+ end
+ end
+
+ def test_has_repository_named?
+ assert env.has_repository_named?('testrepo')
+ if ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "yes" then
+ assert env.has_repository_named?('virtuals')
+ else
+ assert ! env.has_repository_named?('virtuals')
+ end
+ assert ! env.has_repository_named?('foobarbaz')
+ end
+ end
end
diff --git a/ruby/package_database.cc b/ruby/package_database.cc
deleted file mode 100644
index 2b59680ce..000000000
--- a/ruby/package_database.cc
+++ /dev/null
@@ -1,233 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007, 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
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis_ruby.hh>
-#include <paludis/package_database.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/wrapped_forward_iterator.hh>
-#include <paludis/util/sequence.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::ruby;
-
-namespace
-{
- static VALUE c_package_database;
-
- /*
- * call-seq:
- * fetch_unique_qualified_package_name(package_name) -> QualifiedPackageName
- * fetch_unique_qualified_package_name(package_name, filter) -> QualifiedPackageName
- *
- * Disambiguate a package name. If a filter is specified, limit
- * the potential results to packages that match.
- */
- VALUE
- package_database_fetch_unique_qualified_package_name(int argc, VALUE *argv, VALUE self)
- {
- try
- {
- if (1 == argc || 2 == argc)
- {
- std::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, std::shared_ptr<PackageDatabase>, self_ptr);
- return qualified_package_name_to_value((*self_ptr)->fetch_unique_qualified_package_name(
- PackageNamePart(StringValuePtr(argv[0])), 2 == argc ? value_to_filter(argv[1]) : filter::All()));
- }
- else
- rb_raise(rb_eArgError, "fetch_unique_qualified_package_name expects one or two arguments, but got %d",argc);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * repositories -> Array
- * repositories {|repository| block } -> Nil
- *
- * Returns all the repositories in the package database, either as an Array, or as
- * the parameters to a block.
- */
- VALUE
- package_database_repositories(VALUE self)
- {
- try
- {
- std::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, std::shared_ptr<PackageDatabase>, self_ptr);
-
- if (rb_block_given_p())
- {
- for (PackageDatabase::RepositoryConstIterator r((*self_ptr)->begin_repositories()),
- r_end((*self_ptr)->end_repositories()) ; r != r_end ; ++r)
- rb_yield(repository_to_value(*r));
- return Qnil;
- }
- VALUE result(rb_ary_new());
- for (PackageDatabase::RepositoryConstIterator r((*self_ptr)->begin_repositories()),
- r_end((*self_ptr)->end_repositories()) ; r != r_end ; ++r)
- rb_ary_push(result, repository_to_value(*r));
-
- return result;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * fetch_repository(repository_name) -> Repository
- *
- * Fetch a named repository.
- */
- VALUE
- package_database_fetch_repository(VALUE self, VALUE name)
- {
- try
- {
- std::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, std::shared_ptr<PackageDatabase>, self_ptr);
-
- return repository_to_value((*self_ptr)->fetch_repository(RepositoryName(StringValuePtr(name))));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * more_important_than(repository_name_a, repository_name_b) -> bool
- *
- * True if repository_name_a is more important than repository_name_b .
- */
- VALUE
- package_database_more_important_than(VALUE self, VALUE name1, VALUE name2)
- {
- try
- {
- std::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, std::shared_ptr<PackageDatabase>, self_ptr);
-
- return (*self_ptr)->more_important_than(RepositoryName(StringValuePtr(name1)),
- RepositoryName(StringValuePtr(name2))) ? Qtrue : Qfalse;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * has_repository_named?(repository_name) -> true or false
- *
- * Do we have a named repository?
- */
- VALUE
- package_database_has_repository_named(VALUE self, VALUE name)
- {
- try
- {
- std::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, std::shared_ptr<PackageDatabase>, self_ptr);
-
- return ((*self_ptr)->has_repository_named(RepositoryName(StringValuePtr(name)))) ? true : false;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * add_repository(importance, repository) -> nil
- *
- * Add a repository.
- */
- VALUE
- package_database_add_repository(VALUE self, VALUE importance, VALUE repo_v)
- {
- try
- {
- std::shared_ptr<PackageDatabase> * self_ptr;
- Data_Get_Struct(self, std::shared_ptr<PackageDatabase>, self_ptr);
-
- std::shared_ptr<Repository> repo(value_to_repository(repo_v));
-
- (*self_ptr)->add_repository(NUM2INT(importance), repo);
- return Qnil;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- void do_register_package_database()
- {
- /*
- * Document-class: Paludis::PackageDatabase
- *
- * A PackageDatabase can be queried for Package instances.
- */
- c_package_database = rb_define_class_under(paludis_module(), "PackageDatabase", rb_cObject);
- rb_funcall(c_package_database, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_package_database, "fetch_unique_qualified_package_name",
- RUBY_FUNC_CAST(&package_database_fetch_unique_qualified_package_name), -1);
- rb_define_method(c_package_database, "repositories",
- RUBY_FUNC_CAST(&package_database_repositories), 0);
- rb_define_method(c_package_database, "fetch_repository",
- RUBY_FUNC_CAST(&package_database_fetch_repository), 1);
- rb_define_method(c_package_database, "more_important_than",
- RUBY_FUNC_CAST(&package_database_more_important_than), 2);
- rb_define_method(c_package_database, "has_repository_named?",
- RUBY_FUNC_CAST(&package_database_has_repository_named), 1);
- rb_define_method(c_package_database, "add_repository",
- RUBY_FUNC_CAST(&package_database_add_repository), 2);
- }
-}
-
-VALUE
-paludis::ruby::package_database_to_value(std::shared_ptr<PackageDatabase> m)
-{
- std::shared_ptr<PackageDatabase> * m_ptr(0);
- try
- {
- m_ptr = new std::shared_ptr<PackageDatabase>(m);
- return Data_Wrap_Struct(c_package_database, 0, &Common<std::shared_ptr<PackageDatabase> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-RegisterRubyClass::Register paludis_ruby_register_package_database PALUDIS_ATTRIBUTE((used))
- (&do_register_package_database);
-
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
deleted file mode 100644
index fe4087fd6..000000000
--- a/ruby/package_database_TEST.rb
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006, 2007, 2008, 2009, 2011 Ciaran McCreesh
-# Copyright (c) 2007 Richard Brown
-#
-# 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
-# Public License version 2, as published by the Free Software Foundation.
-#
-# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
-# Place, Suite 330, Boston, MA 02111-1307 USA
-#
-
-ENV["PALUDIS_HOME"] = Dir.getwd().to_s + "/package_database_TEST_dir/home";
-
-require 'test/unit'
-require 'Paludis'
-
-Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
-
-module Paludis
- class TestCase_PackageDatabase < Test::Unit::TestCase
- def test_no_create
- assert_raise NoMethodError do
- p = PackageDatabase.new
- end
- end
- end
-
- class TestCase_PackageDatabaseFetchUniqueQualifiedPackageName < Test::Unit::TestCase
- def env
- @env or @env = EnvironmentFactory.instance.create("")
- end
-
- def db
- return env.package_database
- end
-
- def test_package_database_fetch_unique_qualified_package_name
- assert_equal "foo/bar", db.fetch_unique_qualified_package_name("bar")
- assert_equal "foo/bar", db.fetch_unique_qualified_package_name("bar", Filter::SupportsAction.new(InstallAction))
- end
-
- def test_error
- assert_raise AmbiguousPackageNameError do
- db.fetch_unique_qualified_package_name('baz')
- end
- assert_raise NoSuchPackageError do
- db.fetch_unique_qualified_package_name('foobarbaz')
- end
- assert_raise NoSuchPackageError do
- db.fetch_unique_qualified_package_name('bar', Filter::SupportsAction.new(ConfigAction))
- end
- end
-
- def test_bad
- assert_raise ArgumentError do
- db.fetch_unique_qualified_package_name
- end
- assert_raise ArgumentError do
- db.fetch_unique_qualified_package_name(1, 2, 3)
- end
- assert_raise TypeError do
- db.fetch_unique_qualified_package_name([])
- end
- assert_raise TypeError do
- db.fetch_unique_qualified_package_name('bar', db)
- end
- end
- end
-
- class TestCase_PackageDatabaseRepositories < Test::Unit::TestCase
- def env
- @env or @env = EnvironmentFactory.instance.create("")
- end
-
- def db
- return env.package_database
- end
-
- def test_repositories
- if ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "yes" then
- assert_equal 3, db.repositories.length
- else
- assert_equal 1, db.repositories.length
- end
-
- a = db.repositories.find_all do | repo |
- repo.name == "testrepo"
- end
- assert_equal 1, a.length
-
- a = db.repositories.find_all do | repo |
- repo.name == "foorepo"
- end
- assert a.empty?
-
- assert_equal nil, db.repositories {|repo| assert_kind_of Repository, repo}
- end
-
- def test_fetch_repository
- assert_equal "testrepo", db.fetch_repository("testrepo").name
-
- assert_raise Paludis::NoSuchRepositoryError do
- db.fetch_repository("barrepo")
- end
- end
-
- def test_more_important_than
- if ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "yes" then
- assert db.more_important_than('testrepo', 'virtuals')
- assert ! db.more_important_than('virtuals', 'testrepo')
- elsif ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "no" then
- else
- throw "oops"
- end
- end
-
- def test_has_repository_named?
- assert db.has_repository_named?('testrepo')
- if ENV["PALUDIS_ENABLE_VIRTUALS_REPOSITORY"] == "yes" then
- assert db.has_repository_named?('virtuals')
- else
- assert ! db.has_repository_named?('virtuals')
- end
- assert ! db.has_repository_named?('foobarbaz')
- end
- end
-end
-
diff --git a/ruby/package_database_TEST_cleanup.sh b/ruby/package_database_TEST_cleanup.sh
deleted file mode 100755
index c34eeb70b..000000000
--- a/ruby/package_database_TEST_cleanup.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-# vim: set ft=sh sw=4 sts=4 et :
-
-if [ -d package_database_TEST_dir ] ; then
- rm -fr package_database_TEST_dir
-else
- true
-fi
-
-
-
-
-
diff --git a/ruby/package_database_TEST_setup.sh b/ruby/package_database_TEST_setup.sh
deleted file mode 100755
index 8148063e5..000000000
--- a/ruby/package_database_TEST_setup.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env bash
-# vim: set ft=sh sw=4 sts=4 et :
-
-mkdir package_database_TEST_dir || exit 1
-cd package_database_TEST_dir || exit 1
-
-mkdir -p home/.paludis/repositories
-
-cat <<END > home/.paludis/repositories/testrepo.conf
-location = `pwd`/testrepo
-format = e
-names_cache = /var/empty
-cache = /var/empty
-profiles = \${location}/profiles/testprofile
-builddir = `pwd`
-END
-
-cat <<END > home/.paludis/keywords.conf
-*/* test
-~foo/bar-1 ~test
-END
-
-cat <<END > home/.paludis/use.conf
-*/* enabled
-~foo/bar-1 sometimes_enabled
-END
-
-cat <<END > home/.paludis/licenses.conf
-*/* *
-END
-
-cat <<END > home/.paludis/general.conf
-world = /dev/null
-END
-
-mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files,foo/baz/files,quux/baz/files} || exit 1
-cd testrepo || exit 1
-echo "testrepo" > profiles/repo_name || exit 1
-cat <<END > profiles/categories || exit 1
-foo
-quux
-END
-cat <<END > profiles/testprofile/make.defaults
-ARCH=test
-USERLAND=test
-KERNEL=test
-END
-
-cat <<"END" > foo/bar/bar-1.0.ebuild || exit 1
-DESCRIPTION="Test package"
-HOMEPAGE="http://paludis.pioto.org/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-END
-
-cat <<"END" > foo/bar/bar-2.0.ebuild || exit 1
-DESCRIPTION="Test package"
-HOMEPAGE="http://paludis.pioto.org/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="~test"
-END
-
-cat <<"END" > foo/baz/baz-1.0.ebuild || exit 1
-DESCRIPTION="Test package"
-HOMEPAGE="http://paludis.pioto.org/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-END
-
-cat <<"END" > quux/baz/baz-2.0.ebuild || exit 1
-DESCRIPTION="Test package"
-HOMEPAGE="http://paludis.pioto.org/"
-SRC_URI=""
-SLOT="0"
-IUSE=""
-LICENSE="GPL-2"
-KEYWORDS="test"
-END
-cd ..
-
-
diff --git a/ruby/package_id_TEST.rb b/ruby/package_id_TEST.rb
index 1f0a181f9..e230843d9 100644
--- a/ruby/package_id_TEST.rb
+++ b/ruby/package_id_TEST.rb
@@ -40,15 +40,15 @@ module Paludis
end
def pid_testrepo
- env.package_database.fetch_repository("testrepo").package_ids("foo/bar").first
+ env.fetch_repository("testrepo").package_ids("foo/bar").first
end
def pid_bad
- env.package_database.fetch_repository("testrepo").package_ids("bad/pkg").first
+ env.fetch_repository("testrepo").package_ids("bad/pkg").first
end
def pid_installed
- env_vdb.package_database.fetch_repository("installed").package_ids("cat-one/pkg-one").first
+ env_vdb.fetch_repository("installed").package_ids("cat-one/pkg-one").first
end
end
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 3c201b95a..cf749d216 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -28,7 +28,6 @@
#include <paludis/about.hh>
#include <paludis/user_dep_spec.hh>
#include <paludis/action.hh>
-#include <paludis/package_database.hh>
#include <ruby.h>
#include <list>
#include <ctype.h>
@@ -56,8 +55,6 @@ namespace
static VALUE c_package_name_part_error;
static VALUE c_bad_version_spec_error;
static VALUE c_package_dep_spec_error;
- static VALUE c_package_database_error;
- static VALUE c_package_database_lookup_error;
static VALUE c_ambiguous_package_name_error;
static VALUE c_no_such_package_error;
static VALUE c_no_such_repository_error;
@@ -204,10 +201,6 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
rb_raise(c_no_such_package_error, dynamic_cast<const paludis::NoSuchPackageError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::NoSuchRepositoryError *>(&ee))
rb_raise(c_no_such_repository_error, dynamic_cast<const paludis::NoSuchRepositoryError *>(&ee)->message().c_str());
- else if (0 != dynamic_cast<const paludis::PackageDatabaseLookupError *>(&ee))
- rb_raise(c_package_database_lookup_error, dynamic_cast<const paludis::PackageDatabaseLookupError *>(&ee)->message().c_str());
- else if (0 != dynamic_cast<const paludis::PackageDatabaseError *>(&ee))
- rb_raise(c_package_database_error, dynamic_cast<const paludis::PackageDatabaseError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::ConfigFileError *>(&ee))
rb_raise(c_config_file_error, dynamic_cast<const paludis::ConfigFileError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::ConfigurationError *>(&ee))
@@ -315,10 +308,8 @@ void PALUDIS_VISIBLE paludis::ruby::init()
c_package_name_part_error = rb_define_class_under(c_paludis_module, "PackageNamePartError", c_name_error);
c_bad_version_spec_error = rb_define_class_under(c_paludis_module, "BadVersionSpecError", c_name_error);
c_package_dep_spec_error = rb_define_class_under(c_paludis_module, "PackageDepSpecError", rb_eRuntimeError);
- c_package_database_error = rb_define_class_under(c_paludis_module, "PackageDatabaseError", rb_eRuntimeError);
- c_package_database_lookup_error = rb_define_class_under(c_paludis_module, "PackageDatabaseLookupError", c_package_database_error);
- c_no_such_package_error = rb_define_class_under(c_paludis_module, "NoSuchPackageError", c_package_database_lookup_error);
- c_no_such_repository_error = rb_define_class_under(c_paludis_module, "NoSuchRepositoryError", c_package_database_lookup_error);
+ c_no_such_package_error = rb_define_class_under(c_paludis_module, "NoSuchPackageError", rb_eRuntimeError);
+ c_no_such_repository_error = rb_define_class_under(c_paludis_module, "NoSuchRepositoryError", rb_eRuntimeError);
c_configuration_error = rb_define_class_under(c_paludis_module, "ConfigurationError", rb_eRuntimeError);
c_config_file_error = rb_define_class_under(c_paludis_module, "ConfigFileError", c_configuration_error);
@@ -335,9 +326,9 @@ void PALUDIS_VISIBLE paludis::ruby::init()
/*
* Document-class: Paludis::AmbiguousPackageNameError
*
- * Thrown if a PackageDatabase query results in more than one matching Package.
+ * Thrown if an Environment query results in more than one matching Package.
*/
- c_ambiguous_package_name_error = rb_define_class_under(c_paludis_module, "AmbiguousPackageNameError", c_package_database_lookup_error);
+ c_ambiguous_package_name_error = rb_define_class_under(c_paludis_module, "AmbiguousPackageNameError", rb_eRuntimeError);
rb_define_method(c_ambiguous_package_name_error, "initialize", RUBY_FUNC_CAST(&ambiguous_package_name_error_init), -1);
rb_define_method(c_ambiguous_package_name_error, "options", RUBY_FUNC_CAST(&ambiguous_package_name_error_failures), 0);
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 7e2b61657..aab1fb1c4 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -80,7 +80,6 @@ namespace paludis
/* constructors */
- VALUE package_database_to_value(std::shared_ptr<PackageDatabase>);
VALUE repository_to_value(std::shared_ptr<Repository>);
VALUE version_spec_to_value(const VersionSpec &);
VALUE package_id_to_value(std::shared_ptr<const PackageID>);
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 15803aaef..62eadfdeb 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -615,7 +615,7 @@ namespace
/*
* Document-class: Paludis::Repository
*
- * A Repository provides a representation of a physical repository to a PackageDatabase.
+ * A Repository provides a representation of a physical repository to an Environment.
*/
c_repository = rb_define_class_under(paludis_module(), "Repository", rb_cObject);
rb_funcall(c_repository, rb_intern("private_class_method"), 1, rb_str_new2("new"));
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 82aae2678..117f311f7 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -38,11 +38,11 @@ module Paludis
module RepositoryTestCase
def installed_repo
- env.package_database.fetch_repository "installed"
+ env.fetch_repository "installed"
end
def repo
- env.package_database.fetch_repository "testrepo"
+ env.fetch_repository "testrepo"
end
def env