aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-07-17 21:10:12 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-07-17 21:10:12 +0000
commit6dfe78633a6155bb6231e996cfb2ac2bce3157bd (patch)
tree6ef26a87bd18c53f9d59c4a43be551457c33ec47
parent1f2712f7271410df52f26d63b7cccadf0d0f9982 (diff)
downloadpaludis-6dfe78633a6155bb6231e996cfb2ac2bce3157bd.tar.gz
paludis-6dfe78633a6155bb6231e996cfb2ac2bce3157bd.tar.xz
(ruby) Add SupportsAction Query objects.
-rw-r--r--ruby/package_database_TEST.rb18
-rw-r--r--ruby/query.cc50
-rw-r--r--ruby/query_TEST.rb90
3 files changed, 149 insertions, 9 deletions
diff --git a/ruby/package_database_TEST.rb b/ruby/package_database_TEST.rb
index cb09d98..369eb00 100644
--- a/ruby/package_database_TEST.rb
+++ b/ruby/package_database_TEST.rb
@@ -118,15 +118,15 @@ module Paludis
assert_equal '1.0', pid.version.to_s
assert_equal 'testrepo', pid.repository.name
-#### a = db.query(Query::Matches.new(pda) & Query::RepositoryHasInstallableInterface.new,
-#### QueryOrder::Whatever)
-#### assert_kind_of Array, a
-#### assert_equal 1, a.length
-#### pid = a.first
-#### assert_kind_of PackageID, pid
-#### assert_equal 'foo/bar', pid.name
-#### assert_equal '1.0', pid.version.to_s
-#### assert_equal 'testrepo', pid.repository.name
+ a = db.query(Query::Matches.new(pda) & Query::SupportsInstallAction.new,
+ QueryOrder::Whatever)
+ assert_kind_of Array, a
+ assert_equal 1, a.length
+ pid = a.first
+ assert_kind_of PackageID, pid
+ assert_equal 'foo/bar', pid.name
+ assert_equal '1.0', pid.version.to_s
+ assert_equal 'testrepo', pid.repository.name
a = db.query(pda, InstallState::Any, QueryOrder::Whatever)
assert_kind_of Array, a
diff --git a/ruby/query.cc b/ruby/query.cc
index 43d25b7..6ae18d5 100644
--- a/ruby/query.cc
+++ b/ruby/query.cc
@@ -39,6 +39,11 @@ namespace
static VALUE c_not_masked;
static VALUE c_installed_at_root;
static VALUE c_all;
+ static VALUE c_supports_install_action;
+ static VALUE c_supports_uninstall_action;
+ static VALUE c_supports_installed_action;
+ static VALUE c_supports_pretend_action;
+ static VALUE c_supports_config_action;
VALUE
query_to_value(const Query & v)
@@ -312,6 +317,51 @@ namespace
*/
c_category = rb_define_class_under(c_query_module, "Category", c_query);
rb_define_singleton_method(c_category, "new", RUBY_FUNC_CAST(&category_new), 1);
+
+ /*
+ * Document-class: Paludis::Query::SupportsInstallAction
+ *
+ * Fetch packages that support InstallAction
+ */
+ c_supports_install_action = rb_define_class_under(c_query_module, "SupportsInstallAction", c_query);
+ rb_define_singleton_method(c_supports_install_action, "new",
+ RUBY_FUNC_CAST(&QueryNew<query::SupportsAction<InstallAction> >::query_new), 0);
+
+ /*
+ * Document-class: Paludis::Query::SupportsUninstallAction
+ *
+ * Fetch packages that support UninstallAction
+ */
+ c_supports_uninstall_action = rb_define_class_under(c_query_module, "SupportsUninstallAction", c_query);
+ rb_define_singleton_method(c_supports_uninstall_action, "new",
+ RUBY_FUNC_CAST(&QueryNew<query::SupportsAction<UninstallAction> >::query_new), 0);
+
+ /*
+ * Document-class: Paludis::Query::SupportsInstalledAction
+ *
+ * Fetch packages that support InstalledAction
+ */
+ c_supports_installed_action = rb_define_class_under(c_query_module, "SupportsInstalledAction", c_query);
+ rb_define_singleton_method(c_supports_installed_action, "new",
+ RUBY_FUNC_CAST(&QueryNew<query::SupportsAction<InstalledAction> >::query_new), 0);
+
+ /*
+ * Document-class: Paludis::Query::SupportsPretendAction
+ *
+ * Fetch packages that support PretendAction
+ */
+ c_supports_pretend_action = rb_define_class_under(c_query_module, "SupportsPretendAction", c_query);
+ rb_define_singleton_method(c_supports_pretend_action, "new",
+ RUBY_FUNC_CAST(&QueryNew<query::SupportsAction<PretendAction> >::query_new), 0);
+
+ /*
+ * Document-class: Paludis::Query::SupportsConfigAction
+ *
+ * Fetch packages that support ConfigAction
+ */
+ c_supports_config_action = rb_define_class_under(c_query_module, "SupportsConfigAction", c_query);
+ rb_define_singleton_method(c_supports_config_action, "new",
+ RUBY_FUNC_CAST(&QueryNew<query::SupportsAction<ConfigAction> >::query_new), 0);
}
}
diff --git a/ruby/query_TEST.rb b/ruby/query_TEST.rb
index a37c229..26a222c 100644
--- a/ruby/query_TEST.rb
+++ b/ruby/query_TEST.rb
@@ -150,5 +150,95 @@ module Paludis
assert_kind_of Query::Query, get_query
end
end
+
+ class TestCase_SupportsInstallAction < Test::Unit::TestCase
+ def get_query
+ Query::SupportsInstallAction.new
+ end
+
+ def test_create
+ assert_nothing_raised do
+ get_query
+ end
+ end
+
+ def test_and
+ q = get_query
+ assert_respond_to q, :&
+ assert_kind_of Query::Query, get_query
+ end
+ end
+
+ class TestCase_SupportsUninstallAction < Test::Unit::TestCase
+ def get_query
+ Query::SupportsUninstallAction.new
+ end
+
+ def test_create
+ assert_nothing_raised do
+ get_query
+ end
+ end
+
+ def test_and
+ q = get_query
+ assert_respond_to q, :&
+ assert_kind_of Query::Query, get_query
+ end
+ end
+
+ class TestCase_SupportsInstalledAction < Test::Unit::TestCase
+ def get_query
+ Query::SupportsInstalledAction.new
+ end
+
+ def test_create
+ assert_nothing_raised do
+ get_query
+ end
+ end
+
+ def test_and
+ q = get_query
+ assert_respond_to q, :&
+ assert_kind_of Query::Query, get_query
+ end
+ end
+
+ class TestCase_SupportsPretendAction < Test::Unit::TestCase
+ def get_query
+ Query::SupportsPretendAction.new
+ end
+
+ def test_create
+ assert_nothing_raised do
+ get_query
+ end
+ end
+
+ def test_and
+ q = get_query
+ assert_respond_to q, :&
+ assert_kind_of Query::Query, get_query
+ end
+ end
+
+ class TestCase_SupportsConfigAction < Test::Unit::TestCase
+ def get_query
+ Query::SupportsConfigAction.new
+ end
+
+ def test_create
+ assert_nothing_raised do
+ get_query
+ end
+ end
+
+ def test_and
+ q = get_query
+ assert_respond_to q, :&
+ assert_kind_of Query::Query, get_query
+ end
+ end
end