aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2007-07-16 22:09:34 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2007-07-16 22:09:34 +0000
commit2749a66ad689800b25696d30b0e9f446a85801d5 (patch)
treef162cd462e3a88495e9f5703542a6db771d37df1
parent077db75a6d41c51256ae540738144e669819ff09 (diff)
downloadpaludis-2749a66ad689800b25696d30b0e9f446a85801d5.tar.gz
paludis-2749a66ad689800b25696d30b0e9f446a85801d5.tar.xz
(ruby) new qa interface.
-rw-r--r--ruby/Makefile.am48
-rw-r--r--ruby/check.cc832
-rw-r--r--ruby/check_TEST.rb340
-rwxr-xr-xruby/check_TEST_cleanup.sh11
-rwxr-xr-xruby/check_TEST_setup.sh28
-rw-r--r--ruby/check_result.cc191
-rw-r--r--ruby/check_result_TEST.rb115
-rw-r--r--ruby/message.cc146
-rw-r--r--ruby/message_TEST.rb74
-rw-r--r--ruby/metadata_file.cc148
-rw-r--r--ruby/metadata_file_TEST.rb90
-rw-r--r--ruby/paludis_ruby.cc68
-rw-r--r--ruby/paludis_ruby.hh36
-rw-r--r--ruby/qa.cc198
-rw-r--r--ruby/qa_TEST.rb59
-rw-r--r--ruby/qa_environment.cc117
-rw-r--r--ruby/qa_environment_TEST.rb68
-rwxr-xr-xruby/qa_environment_TEST_cleanup.sh11
-rwxr-xr-xruby/qa_environment_TEST_setup.sh36
-rw-r--r--ruby/repository.cc45
-rw-r--r--ruby/repository_TEST.rb50
-rwxr-xr-xruby/repository_TEST_setup.sh1
22 files changed, 402 insertions, 2310 deletions
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index a700aef..796d2f2 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -34,12 +34,8 @@ IF_RUBY_TESTS = \
dep_tag_TEST.rb \
package_id_TEST.rb
-### IF_RUBY_QA_TESTS = \
-### message_TEST.rb \
-### check_result_TEST.rb \
-### metadata_file_TEST.rb \
-### qa_environment_TEST.rb \
-### check_TEST.rb
+IF_RUBY_QA_TESTS = \
+ qa_TEST.rb
IF_RUBY_SOURCES = \
paludis_ruby.cc paludis_ruby.hh \
@@ -60,12 +56,8 @@ IF_RUBY_SOURCES = \
eapi.cc \
name.cc
-### IF_RUBY_QA_SOURCES = \
-### message.cc \
-### check.cc \
-### check_result.cc \
-### qa_environment.cc \
-### metadata_file.cc
+IF_RUBY_QA_SOURCES = \
+ qa.cc
EXTRA_DIST = $(IF_RUBY_TESTS) $(IF_RUBY_SOURCES) \
$(IF_RUBY_QA_TESTS) $(IF_RUBY_QA_SOURCES) \
@@ -118,26 +110,18 @@ paludis_ruby_so.o : paludis_ruby_so.cc
$(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(AM_CXXFLAGS) -I$(RUBY_SITEARCHDIR) -I$(RUBY_ARCHDIR) -c \
-o $@ $(srcdir)/paludis_ruby_so.cc ; then ln -fs .libs/paludis_ruby_so.o $@ ; else rm -f $@ ; exit 1 ; fi
-### if ENABLE_QA
-###
-### libpaludisruby_la_SOURCES = $(IF_RUBY_SOURCES) $(IF_RUBY_QA_SOURCES)
-### libpaludisruby_la_LIBADD = \
-### $(top_builddir)/paludis/libpaludis.la \
-### $(top_builddir)/paludis/util/libpaludisutil.la \
-### $(top_builddir)/paludis/dep_list/libpaludisdeplist.la \
-### $(top_builddir)/paludis/tasks/libpaludistasks.la \
-### $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
-### $(top_builddir)/paludis/environments/paludis/libpaludispaludisenvironment.la \
-### $(top_builddir)/paludis/environments/no_config/libpaludisnoconfigenvironment.la \
-### $(top_builddir)/paludis/environments/adapted/libpaludisadaptedenvironment.la \
-### $(top_builddir)/paludis/environments/libpaludisenvironments.la \
-### $(top_builddir)/paludis/qa/libpaludisqa.la
-###
-### TESTS = $(IF_RUBY_QA_TESTS) $(IF_RUBY_TESTS)
-###
-### else
+if ENABLE_QA
+
+libpaludisruby_la_SOURCES = $(IF_RUBY_SOURCES) $(IF_RUBY_QA_SOURCES)
+TESTS = $(IF_RUBY_TESTS) $(IF_RUBY_QA_TESTS)
+
+else
libpaludisruby_la_SOURCES = $(IF_RUBY_SOURCES)
+TESTS = $(IF_RUBY_TESTS)
+
+endif
+
libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
@@ -150,10 +134,6 @@ libpaludisruby_la_LIBADD = \
$(top_builddir)/paludis/environments/libpaludisenvironments.la \
$(PTHREAD_LIBS)
-TESTS = $(IF_RUBY_TESTS)
-
-### endif
-
check_DATA = .libs/Paludis.so
rubylibdir = @RUBY_INSTALL_DIR@
rubylib_DATA = Paludis.so
diff --git a/ruby/check.cc b/ruby/check.cc
deleted file mode 100644
index 5ab12d1..0000000
--- a/ruby/check.cc
+++ /dev/null
@@ -1,832 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007 Richard Brown <rbrown@gentoo.org>
- *
- * 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/qa/check.hh>
-#include <paludis/qa/package_dir_check.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/virtual_constructor-impl.hh>
-#include <paludis/qa/qa.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::qa;
-using namespace paludis::ruby;
-
-#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
-
-namespace
-{
- static VALUE c_ebuild_check_data;
- static VALUE c_per_profile_ebuild_check_data;
- static VALUE c_profile_check_data;
- static VALUE c_package_dir_check;
- static VALUE c_package_dir_check_maker;
- static VALUE c_file_check;
- static VALUE c_file_check_maker;
- static VALUE c_ebuild_check;
- static VALUE c_ebuild_check_maker;
- static VALUE c_per_profile_ebuild_check;
- static VALUE c_per_profile_ebuild_check_maker;
- static VALUE c_profiles_check;
- static VALUE c_profiles_check_maker;
- static VALUE c_profile_check;
- static VALUE c_profile_check_maker;
-
- VALUE
- ebuild_check_data_init(int, VALUE *, VALUE self)
- {
- return self;
- }
-
- /*
- * call-seq:
- * EbuildCheckData.new(qualified_package_name, version_spec, environment_data)
- *
- * Creates a new EbuildCheckData for EbuildCheck.
- */
- VALUE
- ebuild_check_data_new(int argc, VALUE *argv, VALUE self)
- {
- EbuildCheckData * ptr(0);
- try
- {
- if (3 == argc)
- {
- ptr = new EbuildCheckData(
- value_to_qualified_package_name(argv[0]),
- value_to_version_spec(argv[1]),
- value_to_qa_environment(argv[2]).get());
- }
- else
- {
- rb_raise(rb_eArgError, "EbuildCheckData expects three arguments, but got %d",argc);
- }
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<EbuildCheckData>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- VALUE
- per_profile_ebuild_check_data_init(int, VALUE *, VALUE self)
- {
- return self;
- }
-
- /*
- * call-seq:
- * PerProfileEbuildCheckData.new(qualified_package_name, version_spec, environment_data, profile)
- *
- * Creates a new PerProfileEbuildCheckData for PerProfileEbuildCheck.2
- */
- VALUE
- per_profile_ebuild_check_data_new(int argc, VALUE *argv, VALUE self)
- {
- PerProfileEbuildCheckData * ptr(0);
- try
- {
- if (4 == argc)
- {
- ptr = new PerProfileEbuildCheckData(
- value_to_qualified_package_name(argv[0]),
- value_to_version_spec(argv[1]),
- value_to_qa_environment(argv[2]).get(),
- FSEntry(StringValuePtr(argv[3]))
- );
- }
- else
- {
- rb_raise(rb_eArgError, "PerProfileEbuildCheckData expects three arguments, but got %d",argc);
- }
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<PerProfileEbuildCheckData>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- VALUE
- profile_check_data_init(int, VALUE *, VALUE self)
- {
- return self;
- }
-
- /*
- * call-seq:
- * ProfileCheckData.new(profiles_dir, profiles_desc_line)
- *
- * Creates a new ProfileCheckData for ProfileCheck.
- */
- VALUE
- profile_check_data_new(int argc, VALUE *argv, VALUE self)
- {
- ProfileCheckData * ptr(0);
- try
- {
- if (2 == argc)
- {
- ptr = new ProfileCheckData(
- FSEntry(StringValuePtr(argv[0])),
- value_to_profiles_desc_line(argv[1])
- );
- }
- else
- {
- rb_raise(rb_eArgError, "ProfileCheckData expects two arguments, but got %d",argc);
- }
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<ProfileCheckData>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * Document-method: describe
- *
- * call-seq:
- * describe -> String
- *
- * Describe what check checks.
- */
- /*
- * Document-method: is_important?
- *
- * call-seq:
- * is_important? -> true or false
- *
- * Is the check important?
- */
- template <typename T_>
- struct CheckStruct
- {
- static
- VALUE describe(VALUE self)
- {
- T_ * ptr;
- Data_Get_Struct(self, T_, ptr);
- return rb_str_new2((*ptr)->describe().c_str());
- }
- static
- VALUE
- is_important(VALUE self)
- {
- T_ * ptr;
- Data_Get_Struct(self, T_, ptr);
- return (*ptr)->is_important() ? Qtrue : Qfalse;
- }
- };
-
- template <typename T_, typename S_>
- VALUE
- check_check(VALUE check, S_ arg)
- {
- try
- {
- T_ * ptr;
- Data_Get_Struct(check, T_, ptr);
- return check_result_to_value((**ptr)(arg));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * check(directory) -> CheckResult
- *
- * Runs check on directory.
- */
- VALUE
- package_dir_check_check(VALUE self, VALUE f)
- {
- try
- {
- return (check_check <tr1::shared_ptr<PackageDirCheck>, FSEntry> (self, FSEntry(StringValuePtr(f))));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * check(file) -> CheckResult
- *
- * Runs check on file.
- */
- VALUE
- file_check_check(VALUE self, VALUE f)
- {
- try
- {
- return (check_check <tr1::shared_ptr<FileCheck>, FSEntry> (self, FSEntry(StringValuePtr(f))));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * check(ebuild_check_data) -> CheckResult
- *
- * Runs check on EbuildCheckData.
- */
- VALUE
- ebuild_check_check(VALUE self, VALUE f)
- {
- try
- {
- return (check_check <tr1::shared_ptr<EbuildCheck>, EbuildCheckData> (self, value_to_ebuild_check_data(f)));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * check(per_profile_ebuild_check_data) -> CheckResult
- *
- * Runs check on PerProfileEbuildCheckData.
- */
- VALUE
- per_profile_ebuild_check_check(VALUE self, VALUE f)
- {
- try
- {
- return (check_check <tr1::shared_ptr<PerProfileEbuildCheck>, PerProfileEbuildCheckData> (self, value_to_per_profile_ebuild_check_data(f)));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * check(dir) -> CheckResult
- *
- * Runs check on directory.
- */
- VALUE
- profiles_check_check(VALUE self, VALUE f)
- {
- try
- {
- return (check_check <tr1::shared_ptr<ProfilesCheck>, FSEntry> (self, FSEntry(StringValuePtr(f))));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * check(profile_check_data) -> CheckResult
- *
- * Runs check on ProfileCheckData.
- */
- VALUE
- profile_check_check(VALUE self, VALUE f)
- {
- try
- {
- return (check_check <tr1::shared_ptr<ProfileCheck>, ProfileCheckData> (self, value_to_profile_check_data(f)));
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * Document-method: keys
- *
- * call-seq:
- * keys -> Array
- * keys {|check_name| block } -> Qnil
- *
- * Returns the names of all checks in this maker, either as an Array or as the parameters to a block.
- */
- template <typename T_>
- struct CheckMakerStruct
- {
- static
- VALUE keys(VALUE)
- {
- std::list<std::string> checks;
- T_::get_instance()->copy_keys(std::back_inserter(checks));
- if (rb_block_given_p())
- {
- for (std::list<std::string>::const_iterator i(checks.begin()),
- i_end(checks.end()) ; i != i_end ; ++i)
- rb_yield(rb_str_new2((*i).c_str()));
- return Qnil;
- }
- VALUE result(rb_ary_new());
- for (std::list<std::string>::const_iterator i(checks.begin()),
- i_end(checks.end()) ; i != i_end ; ++i)
- rb_ary_push(result, rb_str_new2((*i).c_str()));
- return result;
- }
- };
-
- /*
- * call-seq:
- * find_maker(name)
- *
- * Fetch the named check.
- */
- VALUE package_dir_check_maker_find_maker(VALUE, VALUE maker)
- {
- try
- {
- tr1::shared_ptr<PackageDirCheck> p = (PackageDirCheckMaker::get_instance()->find_maker(StringValuePtr(maker)))();
- return package_dir_check_to_value(p);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * find_maker(name)
- *
- * Fetch the named check.
- */
- VALUE file_check_maker_find_maker(VALUE, VALUE maker)
- {
- try
- {
- tr1::shared_ptr<FileCheck> p = (FileCheckMaker::get_instance()->find_maker(StringValuePtr(maker)))();
- return file_check_to_value(p);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * find_maker(name)
- *
- * Fetch the named check.
- */
- VALUE ebuild_check_maker_find_maker(VALUE, VALUE maker)
- {
- try
- {
- tr1::shared_ptr<EbuildCheck> p = (EbuildCheckMaker::get_instance()->find_maker(StringValuePtr(maker)))();
- return ebuild_check_to_value(p);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * find_maker(name)
- *
- * Fetch the named check.
- */
- VALUE per_profile_ebuild_check_maker_find_maker(VALUE, VALUE maker)
- {
- try
- {
- tr1::shared_ptr<PerProfileEbuildCheck> p = (PerProfileEbuildCheckMaker::get_instance()->find_maker(StringValuePtr(maker)))();
- return per_profile_ebuild_check_to_value(p);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * find_maker(name)
- *
- * Fetch the named check.
- */
- VALUE profiles_check_maker_find_maker(VALUE, VALUE maker)
- {
- try
- {
- tr1::shared_ptr<ProfilesCheck> p = (ProfilesCheckMaker::get_instance()->find_maker(StringValuePtr(maker)))();
- return profiles_check_to_value(p);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * find_maker(name)
- *
- * Fetch the named check.
- */
- VALUE profile_check_maker_find_maker(VALUE, VALUE maker)
- {
- try
- {
- tr1::shared_ptr<ProfileCheck> p = (ProfileCheckMaker::get_instance()->find_maker(StringValuePtr(maker)))();
- return profile_check_to_value(p);
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- void do_register_check()
- {
- rb_require("singleton");
-
- /*
- * Document-class: Paludis::QA::EbuildCheckData
- *
- * A collection class for EbuildCheck.
- */
- c_ebuild_check_data = rb_define_class_under(paludis_qa_module(), "EbuildCheckData", rb_cObject);
- rb_define_singleton_method(c_ebuild_check_data, "new", RUBY_FUNC_CAST(&ebuild_check_data_new),-1);
- rb_define_method(c_ebuild_check_data, "initialize", RUBY_FUNC_CAST(&ebuild_check_data_init),-1);
-
- /*
- * Document-class: Paludis::QA::PerProfileEbuildCheckData
- *
- * A collection class for PerProfileEbuildCheck.
- */
- c_per_profile_ebuild_check_data = rb_define_class_under(paludis_qa_module(), "PerProfileEbuildCheckData", rb_cObject);
- rb_define_singleton_method(c_per_profile_ebuild_check_data, "new", RUBY_FUNC_CAST(&per_profile_ebuild_check_data_new),-1);
- rb_define_method(c_per_profile_ebuild_check_data, "initialize", RUBY_FUNC_CAST(&per_profile_ebuild_check_data_init),-1);
-
- /*
- * Document-class: Paludis::QA::ProfileCheckData
- *
- * A collection class for ProfileCheck.
- */
- c_profile_check_data = rb_define_class_under(paludis_qa_module(), "ProfileCheckData", rb_cObject);
- rb_define_singleton_method(c_profile_check_data, "new", RUBY_FUNC_CAST(&profile_check_data_new),-1);
- rb_define_method(c_profile_check_data, "initialize", RUBY_FUNC_CAST(&profile_check_data_init),-1);
-
- /*
- * Document-class: Paludis::QA::PackageDirCheck
- *
- * A QA check that operates upon a package directory.
- */
- c_package_dir_check = rb_define_class_under(paludis_qa_module(), "PackageDirCheck", rb_cObject);
- rb_funcall(c_package_dir_check, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_package_dir_check, "check", RUBY_FUNC_CAST(&package_dir_check_check),1);
- rb_define_method(c_package_dir_check, "describe", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<PackageDirCheck> >::describe),0);
- rb_define_method(c_package_dir_check, "is_important?", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<PackageDirCheck> >::is_important),0);
-
- /*
- * Document-class: Paludis::QA::FileCheck
- *
- * A QA check that operates upon a file.
- */
- c_file_check = rb_define_class_under(paludis_qa_module(), "FileCheck", rb_cObject);
- rb_funcall(c_file_check, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_file_check, "check", RUBY_FUNC_CAST(&file_check_check),1);
- rb_define_method(c_file_check, "describe", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<FileCheck> >::describe),0);
- rb_define_method(c_file_check, "is_important?", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<FileCheck> >::is_important),0);
-
- /*
- * Document-class: Paludis::QA::EbuildCheck
- *
- * Base class for QA checks that operate upon ebuilds.
- */
- c_ebuild_check = rb_define_class_under(paludis_qa_module(), "EbuildCheck", rb_cObject);
- rb_funcall(c_ebuild_check, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_ebuild_check, "check", RUBY_FUNC_CAST(&ebuild_check_check),1);
- rb_define_method(c_ebuild_check, "describe", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<EbuildCheck> >::describe),0);
- rb_define_method(c_ebuild_check, "is_important?", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<EbuildCheck> >::is_important),0);
-
- /*
- * Document-class: Paludis::QA::PerProfileEbuildCheck
- *
- * Base class for QA checks that operate upon ebuilds.
- */
- c_per_profile_ebuild_check = rb_define_class_under(paludis_qa_module(), "PerProfileEbuildCheck", rb_cObject);
- rb_funcall(c_per_profile_ebuild_check, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_per_profile_ebuild_check, "check", RUBY_FUNC_CAST(&per_profile_ebuild_check_check),1);
- rb_define_method(c_per_profile_ebuild_check, "describe", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<PerProfileEbuildCheck> >::describe),0);
- rb_define_method(c_per_profile_ebuild_check, "is_important?", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<PerProfileEbuildCheck> >::is_important),0);
-
- /*
- * Document-class: Paludis::QA::ProfilesCheck
- *
- * Base class for QA checks that operate upon the top level /profiles directory.
- */
- c_profiles_check = rb_define_class_under(paludis_qa_module(), "ProfilesCheck", rb_cObject);
- rb_funcall(c_profiles_check, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_profiles_check, "check", RUBY_FUNC_CAST(&profiles_check_check),1);
- rb_define_method(c_profiles_check, "describe", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<ProfilesCheck> >::describe),0);
- rb_define_method(c_profiles_check, "is_important?", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<ProfilesCheck> >::is_important),0);
-
- /*
- * Document-class: Paludis::QA::ProfileCheck
- *
- * Base class for QA checks that operate upon a profiles.desc entry directory.
- */
- c_profile_check = rb_define_class_under(paludis_qa_module(), "ProfileCheck", rb_cObject);
- rb_funcall(c_profile_check, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_define_method(c_profile_check, "check", RUBY_FUNC_CAST(&profile_check_check),1);
- rb_define_method(c_profile_check, "describe", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<ProfileCheck> >::describe),0);
- rb_define_method(c_profile_check, "is_important?", RUBY_FUNC_CAST(&CheckStruct<tr1::shared_ptr<ProfileCheck> >::is_important),0);
-
- /*
- * Document-class: Paludis::QA::PackageDirCheckMaker
- *
- * Class to access PackageDirChecks
- *
- */
- c_package_dir_check_maker = rb_define_class_under(paludis_qa_module(), "PackageDirCheckMaker", rb_cObject);
- rb_funcall(c_package_dir_check_maker, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_package_dir_check_maker);
- rb_define_method(c_package_dir_check_maker, "keys", RUBY_FUNC_CAST(CheckMakerStruct<PackageDirCheckMaker>::keys),0);
- rb_define_method(c_package_dir_check_maker, "find_maker", RUBY_FUNC_CAST(&package_dir_check_maker_find_maker),1);
- rb_define_alias(c_package_dir_check_maker, "check_names", "keys");
- rb_define_alias(c_package_dir_check_maker, "find_check", "find_maker");
-
- /*
- * Document-class: Paludis::QA::FileCheckMaker
- *
- * Class to access FileChecks
- *
- */
- c_file_check_maker = rb_define_class_under(paludis_qa_module(), "FileCheckMaker", rb_cObject);
- rb_funcall(c_file_check_maker, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_file_check_maker);
- rb_define_method(c_file_check_maker, "keys", RUBY_FUNC_CAST(CheckMakerStruct<FileCheckMaker>::keys),0);
- rb_define_method(c_file_check_maker, "find_maker", RUBY_FUNC_CAST(&file_check_maker_find_maker),1);
- rb_define_alias(c_file_check_maker, "check_names", "keys");
- rb_define_alias(c_file_check_maker, "find_check", "find_maker");
-
- /*
- * Document-class: Paludis::QA::EbuildCheckMaker
- *
- * Class to access EbuildChecks
- *
- */
- c_ebuild_check_maker = rb_define_class_under(paludis_qa_module(), "EbuildCheckMaker", rb_cObject);
- rb_funcall(c_ebuild_check_maker, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_ebuild_check_maker);
- rb_define_method(c_ebuild_check_maker, "keys", RUBY_FUNC_CAST(&CheckMakerStruct<EbuildCheckMaker>::keys),0);
- rb_define_method(c_ebuild_check_maker, "find_maker", RUBY_FUNC_CAST(&ebuild_check_maker_find_maker),1);
- rb_define_alias(c_ebuild_check_maker, "check_names", "keys");
- rb_define_alias(c_ebuild_check_maker, "find_check", "find_maker");
-
- /*
- * Document-class: Paludis::QA::PerProfileEbuildCheckMaker
- *
- * Class to access PerProfileEbuildChecks
- *
- */
- c_per_profile_ebuild_check_maker = rb_define_class_under(paludis_qa_module(), "PerProfileEbuildCheckMaker", rb_cObject);
- rb_funcall(c_per_profile_ebuild_check_maker, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_per_profile_ebuild_check_maker);
- rb_define_method(c_per_profile_ebuild_check_maker, "keys", RUBY_FUNC_CAST(&CheckMakerStruct<PerProfileEbuildCheckMaker>::keys),0);
- rb_define_method(c_per_profile_ebuild_check_maker, "find_maker", RUBY_FUNC_CAST(&per_profile_ebuild_check_maker_find_maker),1);
- rb_define_alias(c_per_profile_ebuild_check_maker, "check_names", "keys");
- rb_define_alias(c_per_profile_ebuild_check_maker, "find_check", "find_maker");
-
- /*
- * Document-class: Paludis::QA::ProfilesCheckMaker
- *
- * Class to access ProfilesChecks
- *
- */
- c_profiles_check_maker = rb_define_class_under(paludis_qa_module(), "ProfilesCheckMaker", rb_cObject);
- rb_funcall(c_profiles_check_maker, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_profiles_check_maker);
- rb_define_method(c_profiles_check_maker, "keys", RUBY_FUNC_CAST(&CheckMakerStruct<ProfilesCheckMaker>::keys),0);
- rb_define_method(c_profiles_check_maker, "find_maker", RUBY_FUNC_CAST(&profiles_check_maker_find_maker),1);
- rb_define_alias(c_profiles_check_maker, "check_names", "keys");
- rb_define_alias(c_profiles_check_maker, "find_check", "find_maker");
-
- /*
- * Document-class: Paludis::QA::ProfileCheckMaker
- *
- * Class to access ProfileChecks
- *
- */
- c_profile_check_maker = rb_define_class_under(paludis_qa_module(), "ProfileCheckMaker", rb_cObject);
- rb_funcall(c_profile_check_maker, rb_intern("private_class_method"), 1, rb_str_new2("new"));
- rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_profile_check_maker);
- rb_define_method(c_profile_check_maker, "keys", RUBY_FUNC_CAST(&CheckMakerStruct<ProfileCheckMaker>::keys),0);
- rb_define_method(c_profile_check_maker, "find_maker", RUBY_FUNC_CAST(&profile_check_maker_find_maker),1);
- rb_define_alias(c_profile_check_maker, "check_names", "keys");
- rb_define_alias(c_profile_check_maker, "find_check", "find_maker");
- }
-}
-
-VALUE
-paludis::ruby::file_check_to_value(tr1::shared_ptr<FileCheck> m)
-{
- tr1::shared_ptr<FileCheck> * m_ptr(0);
- try
- {
- m_ptr = new tr1::shared_ptr<FileCheck>(m);
- return Data_Wrap_Struct(c_file_check, 0, &Common<tr1::shared_ptr<FileCheck> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-VALUE
-paludis::ruby::package_dir_check_to_value(tr1::shared_ptr<PackageDirCheck> m)
-{
- tr1::shared_ptr<PackageDirCheck> * m_ptr(0);
- try
- {
- m_ptr = new tr1::shared_ptr<PackageDirCheck>(m);
- return Data_Wrap_Struct(c_package_dir_check, 0, &Common<tr1::shared_ptr<PackageDirCheck> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-VALUE
-paludis::ruby::ebuild_check_to_value(tr1::shared_ptr<EbuildCheck> m)
-{
- tr1::shared_ptr<EbuildCheck> * m_ptr(0);
- try
- {
- m_ptr = new tr1::shared_ptr<EbuildCheck>(m);
- return Data_Wrap_Struct(c_ebuild_check, 0, &Common<tr1::shared_ptr<EbuildCheck> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-VALUE
-paludis::ruby::profiles_check_to_value(tr1::shared_ptr<ProfilesCheck> m)
-{
- tr1::shared_ptr<ProfilesCheck> * m_ptr(0);
- try
- {
- m_ptr = new tr1::shared_ptr<ProfilesCheck>(m);
- return Data_Wrap_Struct(c_profiles_check, 0, &Common<tr1::shared_ptr<ProfilesCheck> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-VALUE
-paludis::ruby::profile_check_to_value(tr1::shared_ptr<ProfileCheck> m)
-{
- tr1::shared_ptr<ProfileCheck> * m_ptr(0);
- try
- {
- m_ptr = new tr1::shared_ptr<ProfileCheck>(m);
- return Data_Wrap_Struct(c_profile_check, 0, &Common<tr1::shared_ptr<ProfileCheck> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-VALUE
-paludis::ruby::per_profile_ebuild_check_to_value(tr1::shared_ptr<PerProfileEbuildCheck> m)
-{
- tr1::shared_ptr<PerProfileEbuildCheck> * m_ptr(0);
- try
- {
- m_ptr = new tr1::shared_ptr<PerProfileEbuildCheck>(m);
- return Data_Wrap_Struct(c_per_profile_ebuild_check, 0, &Common<tr1::shared_ptr<PerProfileEbuildCheck> >::free, m_ptr);
- }
- catch (const std::exception & e)
- {
- delete m_ptr;
- exception_to_ruby_exception(e);
- }
-}
-
-EbuildCheckData
-paludis::ruby::value_to_ebuild_check_data(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_ebuild_check_data))
- {
- EbuildCheckData * v_ptr;
- Data_Get_Struct(v, EbuildCheckData, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into EbuildCheckData", rb_obj_classname(v));
- }
-}
-
-VALUE
-paludis::ruby::ebuild_check_data_to_value(const EbuildCheckData & v)
-{
- EbuildCheckData * vv(new EbuildCheckData(v));
- return Data_Wrap_Struct(c_ebuild_check_data, 0, &Common<EbuildCheckData>::free, vv);
-}
-
-PerProfileEbuildCheckData
-paludis::ruby::value_to_per_profile_ebuild_check_data(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_per_profile_ebuild_check_data))
- {
- PerProfileEbuildCheckData * v_ptr;
- Data_Get_Struct(v, PerProfileEbuildCheckData, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into PerProfileEbuildCheckData", rb_obj_classname(v));
- }
-}
-
-VALUE
-paludis::ruby::per_profile_ebuild_check_data_to_value(const PerProfileEbuildCheckData & v)
-{
- PerProfileEbuildCheckData * vv(new PerProfileEbuildCheckData(v));
- return Data_Wrap_Struct(c_per_profile_ebuild_check_data, 0, &Common<PerProfileEbuildCheckData>::free, vv);
-}
-
-ProfileCheckData
-paludis::ruby::value_to_profile_check_data(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_profile_check_data))
- {
- ProfileCheckData * v_ptr;
- Data_Get_Struct(v, ProfileCheckData, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into ProfileCheckData", rb_obj_classname(v));
- }
-}
-
-VALUE
-paludis::ruby::profile_check_data_to_value(const ProfileCheckData & v)
-{
- ProfileCheckData * vv(new ProfileCheckData(v));
- return Data_Wrap_Struct(c_profile_check_data, 0, &Common<ProfileCheckData>::free, vv);
-}
-
-RegisterRubyClass::Register paludis_ruby_register_check PALUDIS_ATTRIBUTE((used))
- (&do_register_check);
diff --git a/ruby/check_TEST.rb b/ruby/check_TEST.rb
deleted file mode 100644
index b9c735c..0000000
--- a/ruby/check_TEST.rb
+++ /dev/null
@@ -1,340 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
-#
-# 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
-#
-
-require 'test/unit'
-require 'Paludis'
-
-Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
-
-module Paludis
- module QA
- module MakerTests
- def instance
- maker_class.instance
- end
-
- def test_instance
- assert_equal instance.__id__, instance.__id__
- assert_kind_of maker_class, instance
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = maker_class.new()
- end
- end
-
- def test_respond_to
- [:keys, :find_maker, :check_names, :find_check].each {|sym| assert_respond_to instance, sym}
- end
-
- def test_keys
- assert_kind_of Array, instance.keys
- assert_not_equal 0, instance.keys
-
- assert_equal(nil, instance.keys {|x| x})
- end
-
- def test_find_maker
- name = instance.keys.first
- assert_kind_of made_class, instance.find_maker(name)
- end
-
- def test_check_names
- assert_kind_of Array, instance.check_names
- assert_equal instance.keys, instance.check_names
- end
-
- def test_find_check
- name = instance.keys.first
- assert_equal instance.find_maker(name).describe, instance.find_check(name).describe
- end
- end
-
- class TestCase_FileCheckMaker < Test::Unit::TestCase
- include MakerTests
- def made_class; FileCheck; end
- def maker_class; FileCheckMaker; end
- end
-
- class TestCase_PackageDirCheckMaker < Test::Unit::TestCase
- include MakerTests
- def made_class; PackageDirCheck; end
- def maker_class; PackageDirCheckMaker; end
- end
-
- class TestCase_EbuildCheckMaker < Test::Unit::TestCase
- include MakerTests
- def made_class; EbuildCheck; end
- def maker_class; EbuildCheckMaker; end
- end
-
- class TestCase_PerProfileEbuildCheckMaker < Test::Unit::TestCase
- include MakerTests
- def made_class; PerProfileEbuildCheck; end
- def maker_class; PerProfileEbuildCheckMaker; end
- end
-
- class TestCase_ProfilesCheckMaker < Test::Unit::TestCase
- include MakerTests
- def made_class; ProfilesCheck; end
- def maker_class; ProfilesCheckMaker; end
- end
-
- class TestCase_ProfileCheckMaker < Test::Unit::TestCase
- include MakerTests
- def made_class; ProfileCheck; end
- def maker_class; ProfileCheckMaker; end
- end
-
- class TestCase_EbuildCheckData < Test::Unit::TestCase
- def test_create
- env = QAEnvironment.new('check_TEST_dir/repo1')
- ecd = EbuildCheckData.new('cat-one/pkg-one', "1", env)
- end
- end
-
- class TestCase_PerProfileEbuildCheckData < Test::Unit::TestCase
- def test_create
- env = QAEnvironment.new('check_TEST_dir/repo1')
- ecd = PerProfileEbuildCheckData.new('cat-one/pkg-one',
- "1",
- env,
- 'check_TEST_dir/repo1/profiles/profile')
- end
- end
-
- class TestCase_ProfileCheckData < Test::Unit::TestCase
- def test_create
- env = QAEnvironment.new('check_TEST_dir/repo1')
- ecd = EbuildCheckData.new('cat-one/pkg-one', "1", env)
- end
- end
-
- module CheckTests
- def test_respond_to
- check = get_check
- [:describe, :is_important?, :check].each {|sym| assert_respond_to get_check, sym}
- end
- end
-
- class TestCase_PackageDirCheck < Test::Unit::TestCase
- include CheckTests
-
- def get_check
- PackageDirCheckMaker.instance.find_maker('package_name')
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = PackageDirCheck.new()
- end
- end
-
- def test_describe
- check = get_check
- assert_equal "Checks that the category/package name is valid", check.describe
- end
-
- def test_is_important
- check = get_check
- assert_equal true, check.is_important?
- end
-
- def test_check
- check = get_check
- assert_nothing_raised do
- cr = check.check('cat-one/pkg-one')
- end
- end
- end
-
- class TestCase_FileCheck < Test::Unit::TestCase
- include CheckTests
-
- def get_check
- FileCheckMaker.instance.find_maker('whitespace')
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = FileCheck.new()
- end
- end
-
- def test_describe
- check = get_check
- assert_equal "Checks whitespace", check.describe
- end
-
- def test_is_important
- check = get_check
- assert_equal false, check.is_important?
- end
-
- def test_check
- check = get_check
- assert_nothing_raised do
- cr = check.check('cat-one/pkg-one/pkg-one-1.ebuild')
- end
- end
- end
-
- class TestCase_EbuildCheck < Test::Unit::TestCase
- include CheckTests
-
- def get_ecd
- env = QAEnvironment.new('check_TEST_dir/repo1')
- ecd = EbuildCheckData.new('cat-one/pkg-one', "1", env)
- end
-
- def get_check
- EbuildCheckMaker.instance.find_maker('create_metadata')
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = EbuildCheck.new()
- end
- end
-
- def test_describe
- check = get_check
- assert_equal "Checks that the metadata can be generated", check.describe
- end
-
- def test_is_important
- check = get_check
- assert_equal true, check.is_important?
- end
-
- def test_check
- check = get_check
- assert_nothing_raised do
- cr = check.check(get_ecd)
- end
- end
- end
-
- class TestCase_PerProfileEbuildCheck < Test::Unit::TestCase
- include CheckTests
-
- def get_ecd
- env = QAEnvironment.new('check_TEST_dir/repo1')
- PerProfileEbuildCheckData.new('cat-one/pkg-one', "1", env, 'check_TEST_dir/repo1/profiles/profile')
- end
-
- def get_check
- PerProfileEbuildCheckMaker.instance.find_maker('deps_visible')
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = PerProfileEbuildCheck.new()
- end
- end
-
- def test_describe
- check = get_check
- assert_equal "Checks that packages in *DEPEND are visible", check.describe
- end
-
- def test_is_important
- check = get_check
- assert_equal false, check.is_important?
- end
-
- def test_check
- check = get_check
- assert_nothing_raised do
- cr = check.check(get_ecd)
- end
- end
- end
-
- class TestCase_ProfilesCheck < Test::Unit::TestCase
- include CheckTests
-
- def get_check
- ProfilesCheckMaker.instance.find_maker('repo_name')
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = ProfilesCheck.new()
- end
- end
-
- def test_describe
- check = get_check
- assert_equal "Checks that repo_name is sane", check.describe
- end
-
- def test_is_important
- check = get_check
- assert_equal false, check.is_important?
- end
-
- def test_check
- check = get_check
- assert_nothing_raised do
- cr = check.check('check_TEST_dir/repo1/profiles')
- end
- end
- end
-
- class TestCase_ProfileCheck < Test::Unit::TestCase
- include CheckTests
-
- def get_pcd
- env = QAEnvironment.new('check_TEST_dir/repo1')
- ProfileCheckData.new('check_TEST_dir/repo1/profiles', env.main_repository.profiles.first)
- end
-
- def get_check
- ProfileCheckMaker.instance.find_maker('profile_paths_exist')
- end
-
- def test_no_create
- assert_raise NoMethodError do
- x = ProfileCheck.new()
- end
- end
-
- def test_describe
- check = get_check
- assert_equal "Checks that profile paths exist", check.describe
- end
-
- def test_is_important
- check = get_check
- assert_equal true, check.is_important?
- end
-
- def test_check
- check = get_check
- assert_nothing_raised do
- cr = check.check(get_pcd)
- end
- end
- end
- end
-end
-
diff --git a/ruby/check_TEST_cleanup.sh b/ruby/check_TEST_cleanup.sh
deleted file mode 100755
index f083e42..0000000
--- a/ruby/check_TEST_cleanup.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-# vim: set ft=sh sw=4 sts=4 et :
-
-if [ -d check_TEST_dir ] ; then
- rm -fr check_TEST_dir
-else
- true
-fi
-
-
-
diff --git a/ruby/check_TEST_setup.sh b/ruby/check_TEST_setup.sh
deleted file mode 100755
index 66ce831..0000000
--- a/ruby/check_TEST_setup.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-# vim: set ft=sh sw=4 sts=4 et :
-
-mkdir check_TEST_dir || exit 1
-cd check_TEST_dir || exit 1
-
-mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1
-cd repo1 || exit 1
-echo "test-repo-1" > profiles/repo_name || exit 1
-cat <<END > profiles/categories || exit 1
-cat-one
-cat-two
-cat-three
-END
-cat <<END > profiles/profile/make.defaults
-ARCH=test
-END
-cat <<END > profiles/profiles.desc
-test profile/ stable
-END
-mkdir -p cat-one/pkg-one
-cat <<END > cat-one/pkg-one/pkg-one-1.ebuild
-DESCRIPTION="foo"
-SLOT="foo"
-END
-
-cd ..
-
diff --git a/ruby/check_result.cc b/ruby/check_result.cc
deleted file mode 100644
index 43f8e5e..0000000
--- a/ruby/check_result.cc
+++ /dev/null
@@ -1,191 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007 Richard Brown <rbrown@gentoo.org>
- *
- * 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/qa/check_result.hh>
-#include <paludis/util/stringify.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::qa;
-using namespace paludis::ruby;
-
-#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
-
-namespace
-{
- static VALUE c_check_result;
-
- VALUE
- check_result_init(int, VALUE *, VALUE self)
- {
- return self;
- }
-
- VALUE
- check_result_new(int argc, VALUE *argv, VALUE self)
- {
- CheckResult * ptr(0);
- try
- {
- if (2 == argc)
- {
- ptr = new CheckResult(StringValuePtr(argv[0]), StringValuePtr(argv[1]));
- }
- else
- {
- rb_raise(rb_eArgError, "CheckResult expects two arguments, but got %d",argc);
- }
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<CheckResult>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * empty? -> true of false
- *
- * Are there any messages?
- */
- VALUE
- check_result_empty(VALUE self)
- {
- CheckResult * ptr;
- Data_Get_Struct(self, CheckResult, ptr);
- return (ptr)->empty() ? Qtrue : Qfalse;
- }
-
- /*
- * call-seq:
- * most_severe_level -> QALevel
- *
- * Most severe message level in the CheckResult.
- */
- VALUE
- check_result_most_severe_level(VALUE self)
- {
- CheckResult * ptr;
- Data_Get_Struct(self, CheckResult, ptr);
- return INT2FIX((ptr)->most_severe_level());
- }
-
- VALUE
- check_result_cat_message(VALUE self, VALUE message)
- {
- try
- {
- CheckResult * ptr;
- Data_Get_Struct(self, CheckResult, ptr);
- *ptr << value_to_message(message);
- return self;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
-
- }
-
- /*
- * call-seq:
- * messages -> Array
- * messages -> {|message| block } -> Qnil
- *
- * Returns all the Messages in the CheckResult, either as an Array, or as the parameters to a block.
- */
- VALUE
- check_result_messages(VALUE self)
- {
- CheckResult * ptr;
- Data_Get_Struct(self, CheckResult, ptr);
-
- if (rb_block_given_p())
- {
- for (CheckResult::Iterator i (ptr->begin()), i_end(ptr->end()) ; i != i_end; ++i)
- rb_yield(message_to_value(*i));
- return Qnil;
- }
- VALUE result(rb_ary_new());
- for (CheckResult::Iterator i (ptr->begin()), i_end(ptr->end()) ; i != i_end; ++i)
- rb_ary_push(result, message_to_value(*i));
- return result;
- }
-
- /*
- * Document-method: item
- *
- * call-seq:
- * item -> String
- *
- * What was checked
- */
- /*
- * Document-method: rule
- *
- * call-seq:
- * rule -> String
- *
- * Check class that produced this result.
- */
- template <const std::string & (CheckResult::* m_) () const>
- struct CheckResultValue
- {
- static VALUE
- fetch(VALUE self)
- {
- CheckResult * ptr;
- Data_Get_Struct(self, CheckResult, ptr);
- return rb_str_new2((((*ptr).*m_)()).c_str());
- }
- };
-
- void do_register_check_result()
- {
- /*
- * Document-class: Paludis::QA::CheckResult
- *
- * The result of a QA check.
- */
- c_check_result = rb_define_class_under(paludis_qa_module(), "CheckResult", rb_cObject);
- rb_define_singleton_method(c_check_result, "new", RUBY_FUNC_CAST(&check_result_new),-1);
- rb_define_method(c_check_result, "initialize", RUBY_FUNC_CAST(&check_result_init),-1);
- rb_define_method(c_check_result, "empty?", RUBY_FUNC_CAST(&check_result_empty),0);
- rb_define_method(c_check_result, "most_severe_level", RUBY_FUNC_CAST(&check_result_most_severe_level),0);
- rb_define_method(c_check_result, "messages", RUBY_FUNC_CAST(&check_result_messages),0);
- rb_define_method(c_check_result, "<<", RUBY_FUNC_CAST(&check_result_cat_message),1);
- rb_define_method(c_check_result, "item", RUBY_FUNC_CAST((&CheckResultValue<&CheckResult::item>::fetch)),0);
- rb_define_method(c_check_result, "rule", RUBY_FUNC_CAST((&CheckResultValue<&CheckResult::rule>::fetch)),0);
- }
-}
-
-VALUE
-paludis::ruby::check_result_to_value(const CheckResult & v)
-{
- CheckResult * vv(new CheckResult(v));
- return Data_Wrap_Struct(c_check_result, 0, &Common<CheckResult>::free, vv);
-}
-
-RegisterRubyClass::Register paludis_ruby_register_check_result PALUDIS_ATTRIBUTE((used))
- (&do_register_check_result);
diff --git a/ruby/check_result_TEST.rb b/ruby/check_result_TEST.rb
deleted file mode 100644
index 23f86e1..0000000
--- a/ruby/check_result_TEST.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
-#
-# 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
-#
-
-require 'test/unit'
-require 'Paludis'
-
-module Paludis
- module QA
- class TestCase_CheckResult < Test::Unit::TestCase
- def test_create
- cr = CheckResult.new('a','b')
- end
-
- def test_create_error
- assert_raise TypeError do
- cr = CheckResult.new(0, 'test')
- end
-
- assert_raise TypeError do
- cr = CheckResult.new('test', 0)
- end
-
- assert_raise ArgumentError do
- cr = CheckResult.new('test')
- end
-
- assert_raise ArgumentError do
- cr = CheckResult.new('a','b','too_many')
- end
- end
-
- def test_respond_to
- cr = CheckResult.new('a','b')
- assert_respond_to cr, :empty?
- assert_respond_to cr, :most_severe_level
- assert_respond_to cr, :messages
- assert_respond_to cr, :<<
- assert_respond_to cr, :item
- assert_respond_to cr, :rule
- end
-
- def test_item
- cr = CheckResult.new('a','b')
- assert_equal 'a', cr.item
- end
-
- def test_rule
- cr = CheckResult.new('a','b')
- assert_equal 'b', cr.rule
- end
-
- def test_cat
- cr = CheckResult.new('a','b')
- assert_nothing_raised do
- cr << Message.new(QALevel::Info, 'test')
- end
- end
-
- def test_empty
- cr = CheckResult.new('a','b')
- assert_equal true, cr.empty?
- cr << Message.new(QALevel::Info, 'test')
- assert_equal false, cr.empty?
- end
-
- def test_most_severe_level
- cr = CheckResult.new('a','b')
- assert_equal 0, cr.most_severe_level
- cr << Message.new(QALevel::Info, 'test')
- assert_equal QALevel::Info, cr.most_severe_level
- cr << Message.new(QALevel::Major, 'test2')
- assert_equal QALevel::Major, cr.most_severe_level
- cr << Message.new(QALevel::Maybe, 'test3')
- assert_equal QALevel::Major, cr.most_severe_level
- end
-
- def test_messages
- cr = CheckResult.new('a','b')
- assert_equal Array.new, cr.messages
- msgs = [
- Message.new(QALevel::Info, 'test'),
- Message.new(QALevel::Fatal, 'test2')
- ]
- cr << msgs[0]
-
- assert_nothing_raised do
- cr.messages do |message|
- assert_equal msgs.first.to_s, message.to_s
- end
- end
-
- cr << msgs[1]
- assert_equal msgs.to_s, cr.messages.to_s
- end
- end
- end
-end
-
diff --git a/ruby/message.cc b/ruby/message.cc
deleted file mode 100644
index e1e50cd..0000000
--- a/ruby/message.cc
+++ /dev/null
@@ -1,146 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
- *
- * 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/qa/message.hh>
-#include <paludis/util/stringify.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::qa;
-using namespace paludis::ruby;
-
-#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
-
-namespace
-{
- static VALUE c_message;
- static VALUE c_qa_level;
-
- VALUE
- message_init(int, VALUE *, VALUE self)
- {
- return self;
- }
-
- VALUE
- message_new(int argc, VALUE *argv, VALUE self)
- {
- Message * ptr(0);
- try
- {
- if (2 == argc)
- {
- int i = NUM2INT(argv[0]);
- if (i < 0|| i >= last_qal)
- rb_raise(rb_eArgError, "QALevel out of range");
- ptr = new Message(static_cast<QALevel>(i), StringValuePtr(argv[1]));
- }
- else
- {
- rb_raise(rb_eArgError, "Message expects two arguments, but got %d",argc);
- }
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Message>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
- /*
- * call-seq:
- * msg
- *
- * Message value.
- */
- VALUE
- message_msg(VALUE self)
- {
- Message * ptr;
- Data_Get_Struct(self, Message, ptr);
- return rb_str_new2((ptr)->msg.c_str());
- }
-
- /*
- * call-seq:
- * level
- *
- * Message level.
- */
- VALUE
- message_level(VALUE self)
- {
- Message * ptr;
- Data_Get_Struct(self, Message, ptr);
- return INT2FIX((ptr)->level);
- }
- void do_register_message()
- {
- /* Document-module: Paludis::QA::QALevel
- *
- * This module contains QALevel constants.
- *
- */
- c_qa_level = rb_define_module_under(paludis_qa_module(), "QALevel");
- for (QALevel l(static_cast<QALevel>(0)), l_end(last_qal) ; l != l_end ;
- l = static_cast<QALevel>(static_cast<int>(l) + 1))
- rb_define_const(c_qa_level, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
-
- // cc_enum_special<paludis/qa/message.hh, QALevel, c_qa_level>
-
- /* Document-class: Paludis::QA::Message
- *
- * A QA message
- */
- c_message = rb_define_class_under(paludis_qa_module(), "Message", rb_cObject);
- rb_define_singleton_method(c_message, "new", RUBY_FUNC_CAST(&message_new),-1);
- rb_define_method(c_message, "initialize", RUBY_FUNC_CAST(&message_init),-1);
- rb_define_method(c_message, "to_s", RUBY_FUNC_CAST(&Common<Message>::to_s),0);
- rb_define_method(c_message, "msg", RUBY_FUNC_CAST(&message_msg),0);
- rb_define_method(c_message, "level", RUBY_FUNC_CAST(&message_level),0);
- }
-}
-
-Message
-paludis::ruby::value_to_message(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_message))
- {
- Message * v_ptr;
- Data_Get_Struct(v, Message, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into Message", rb_obj_classname(v));
- }
-}
-
-VALUE
-paludis::ruby::message_to_value(const Message & v)
-{
- Message * vv(new Message(v));
- return Data_Wrap_Struct(c_message, 0, &Common<Message>::free, vv);
-}
-
-RegisterRubyClass::Register paludis_ruby_register_message PALUDIS_ATTRIBUTE((used))
- (&do_register_message);
diff --git a/ruby/message_TEST.rb b/ruby/message_TEST.rb
deleted file mode 100644
index ebbfa4f..0000000
--- a/ruby/message_TEST.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
-#
-# 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
-#
-
-require 'test/unit'
-require 'Paludis'
-
-module Paludis
- module QA
- class TestCase_Message < Test::Unit::TestCase
- def test_create
- msg = Message.new(QALevel::Info,'test')
- end
-
- def test_create_error
- assert_raise TypeError do
- msg = Message.new('wrong', 'test')
- end
-
- assert_raise TypeError do
- msg = Message.new(QALevel::Info, 0)
- end
-
- assert_raise ArgumentError do
- msg = Message.new(QALevel::Info)
- end
-
- assert_raise ArgumentError do
- msg = Message.new(QALevel::Info,'test','too_many')
- end
-
- end
-
- def test_respond_to
- msg = Message.new(QALevel::Info,'test')
- assert_respond_to msg, :to_s
- assert_respond_to msg, :msg
- assert_respond_to msg, :level
- end
-
- def test_to_s
- msg = Message.new(QALevel::Info,'test')
- assert_equal '(info) test', msg.to_s
- end
-
- def test_msg
- msg = Message.new(QALevel::Info,'test')
- assert_equal 'test', msg.msg
- end
-
- def test_level
- msg = Message.new(QALevel::Info, 'test')
- assert_equal QALevel::Info, msg.level
- end
- end
- end
-end
-
diff --git a/ruby/metadata_file.cc b/ruby/metadata_file.cc
deleted file mode 100644
index c1fe757..0000000
--- a/ruby/metadata_file.cc
+++ /dev/null
@@ -1,148 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
- *
- * 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/qa/metadata_file.hh>
-#include <paludis/util/stringify.hh>
-#include <libwrapiter/libwrapiter_forward_iterator.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::qa;
-using namespace paludis::ruby;
-
-#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
-
-namespace
-{
- static VALUE c_metadata_file;
-
- VALUE
- metadata_file_init(int, VALUE *, VALUE self)
- {
- return self;
- }
-
- /*
- * call-seq:
- * MetadataFile.new(file_name) -> MetadataFile
- *
- * Create a new MetadataFile instance from the specified file.
- */
- VALUE
- metadata_file_new(int argc, VALUE *argv, VALUE self)
- {
- MetadataFile * ptr(0);
- try
- {
- if (1 == argc)
- {
- std::string s = StringValuePtr(argv[0]);
- FSEntry fse = FSEntry(s);
- if (fse.is_regular_file())
- ptr = new MetadataFile(fse);
- else
- ptr = new MetadataFile(s);
- }
- else
- {
- rb_raise(rb_eArgError, "MetadataFile expects one argument, but got %d",argc);
- }
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common<MetadataFile>::free, ptr));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- delete ptr;
- exception_to_ruby_exception(e);
- }
- }
-
- /*
- * call-seq:
- * herds -> Array
- *
- * Array of herds specified in file.
- */
- VALUE
- metadata_file_herds(VALUE self)
- {
- MetadataFile * ptr;
- Data_Get_Struct(self, MetadataFile, ptr);
-
- VALUE result(rb_ary_new());
- for (MetadataFile::HerdsIterator i (ptr->begin_herds()),
- i_end(ptr->end_herds()) ; i != i_end ; ++i)
- rb_ary_push(result, rb_str_new2(i->c_str()));
- return result;
- }
-
- /*
- * call-seq:
- * maintainers -> Hash
- *
- * Hash of maintainers specified in file, keys are :email and :name.
- */
- VALUE
- metadata_file_maintainers(VALUE self)
- {
- MetadataFile * ptr;
- Data_Get_Struct(self, MetadataFile, ptr);
- VALUE result(rb_ary_new());
- VALUE result_hash;
- for (MetadataFile::MaintainersIterator i(ptr->begin_maintainers()),
- i_end(ptr->end_maintainers()) ; i != i_end ; ++i)
- {
- if (i->first.empty() && i->second.empty())
- continue;
-
- result_hash = rb_hash_new();
- if (!i->first.empty())
- rb_hash_aset(result_hash, ID2SYM(rb_intern("email")), rb_str_new2(i->first.c_str()));
- if (!i->second.empty())
- rb_hash_aset(result_hash, ID2SYM(rb_intern("name")), rb_str_new2(i->second.c_str()));
- rb_ary_push(result, result_hash);
- }
- return result;
- }
- void do_register_metadata_file()
- {
- /*
- * Document-class: Paludis::QA::MetadataFile
- *
- * Wrapper around metadata.xml files.
- */
- c_metadata_file = rb_define_class_under(paludis_qa_module(), "MetadataFile", rb_cObject);
- rb_define_singleton_method(c_metadata_file, "new", RUBY_FUNC_CAST(&metadata_file_new),-1);
- rb_define_method(c_metadata_file, "initialize", RUBY_FUNC_CAST(&metadata_file_init),-1);
- rb_define_method(c_metadata_file, "herds", RUBY_FUNC_CAST(&metadata_file_herds),0);
- rb_define_method(c_metadata_file, "maintainers", RUBY_FUNC_CAST(&metadata_file_maintainers),0);
- }
-}
-
-VALUE
-paludis::ruby::metadata_file_to_value(const MetadataFile & v)
-{
- MetadataFile * vv(new MetadataFile(v));
- return Data_Wrap_Struct(c_metadata_file, 0, &Common<MetadataFile>::free, vv);
-}
-
-RegisterRubyClass::Register paludis_ruby_register_metadata_file PALUDIS_ATTRIBUTE((used))
- (&do_register_metadata_file);
diff --git a/ruby/metadata_file_TEST.rb b/ruby/metadata_file_TEST.rb
deleted file mode 100644
index 93c0d60..0000000
--- a/ruby/metadata_file_TEST.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
-#
-# 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
-#
-
-require 'test/unit'
-require 'Paludis'
-
-module Paludis
- module QA
- class TestCase_MetadataFile < Test::Unit::TestCase
- def metadata
-
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
-<!DOCTYPE pkgmetadata SYSTEM \"http://www.gentoo.org/dtd/metadata.dtd\">
-<pkgmetadata>
- <herd>vim</herd>
- <herd> cookie </herd>
- <maintainer>
- <email> foo@bar.baz </email>
- <name> Foo Bar </name>
- </maintainer>
- <maintainer>
- <email>oink@oink</email>
- </maintainer>
- <maintainer>
- <name> Fred the Fish </name>
- </maintainer>
- <longdescription lang=\"en\">
- Some text
- </longdescription>
-</pkgmetadata>"
-
- end
-
- def test_create
- #check that we can open from file as well
-
- file = MetadataFile.new(metadata)
- end
-
- def test_respond_to
- file = MetadataFile.new(metadata)
- assert_respond_to file, :herds
- assert_respond_to file, :maintainers
- end
-
- def test_herds
- file = MetadataFile.new(metadata)
- herds = file.herds
- assert_equal 2, herds.length
- assert_equal true, herds.include?('vim')
- assert_equal true, herds.include?('cookie')
- assert_equal false, herds.include?('monster')
- end
-
- def test_maintainers
- file = MetadataFile.new(metadata)
- assert_equal 3, file.maintainers.length
- file.maintainers.each do |m|
- if m.has_key? :email
- if m[:email] == 'foo@bar.baz'
- assert_equal({:email => 'foo@bar.baz', :name => 'Foo Bar'}, m)
- else
- assert_equal({:email => 'oink@oink'}, m)
- end
- else
- assert_equal({:name => 'Fred the Fish'}, m)
- end
- end
- end
- end
- end
-end
-
diff --git a/ruby/paludis_ruby.cc b/ruby/paludis_ruby.cc
index 0d2b15e..d341e90 100644
--- a/ruby/paludis_ruby.cc
+++ b/ruby/paludis_ruby.cc
@@ -28,12 +28,6 @@
#include <list>
#include <ctype.h>
-#ifdef ENABLE_RUBY_QA
-#if 0
-#include <paludis/qa/qa_environment.hh>
-#endif
-#endif
-
using namespace paludis;
using namespace paludis::ruby;
@@ -80,16 +74,6 @@ namespace
static VALUE c_environment;
static VALUE c_no_config_environment;
-#ifdef ENABLE_RUBY_QA
-#if 0
- static VALUE c_paludis_qa_module;
- static VALUE c_profiles_desc_error;
- static VALUE c_no_such_file_check_type_error;
- static VALUE c_no_such_package_dir_check_type_error;
- static VALUE c_no_such_ebuild_check_type_error;
-#endif
-#endif
-
/* Document-method: match_package
*
* call-seq:
@@ -190,16 +174,6 @@ void paludis::ruby::exception_to_ruby_exception(const std::exception & ee)
rb_raise(c_no_destination_error, dynamic_cast<const paludis::NoDestinationError *>(&ee)->message().c_str());
else if (0 != dynamic_cast<const paludis::DepListError *>(&ee))
rb_raise(c_dep_list_error, dynamic_cast<const paludis::DepListError *>(&ee)->message().c_str());
-#ifdef ENABLE_RUBY_QA
-#if 0
- else if (0 != dynamic_cast<const paludis::qa::NoSuchFileCheckTypeError *>(&ee))
- rb_raise(c_no_such_file_check_type_error, dynamic_cast<const paludis::qa::NoSuchFileCheckTypeError *>(&ee)->message().c_str());
- else if (0 != dynamic_cast<const paludis::qa::NoSuchPackageDirCheckTypeError *>(&ee))
- rb_raise(c_no_such_package_dir_check_type_error, dynamic_cast<const paludis::qa::NoSuchPackageDirCheckTypeError *>(&ee)->message().c_str());
- else if (0 != dynamic_cast<const paludis::qa::NoSuchEbuildCheckTypeError *>(&ee))
- rb_raise(c_no_such_ebuild_check_type_error, dynamic_cast<const paludis::qa::NoSuchEbuildCheckTypeError *>(&ee)->message().c_str());
-#endif
-#endif
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))
@@ -254,16 +228,6 @@ paludis::ruby::no_config_environment_class()
return c_no_config_environment;
}
-#ifdef ENABLE_RUBY_QA
-#if 0
-VALUE
-paludis::ruby::paludis_qa_module()
-{
- return c_paludis_qa_module;
-}
-#endif
-#endif
-
static VALUE
has_query_property_error_init(int argc, VALUE* argv, VALUE self)
{
@@ -355,15 +319,29 @@ void PALUDIS_VISIBLE paludis::ruby::init()
rb_define_const(c_paludis_module, "Version", rb_str_new2((stringify(PALUDIS_VERSION_MAJOR) + "."
+ stringify(PALUDIS_VERSION_MINOR) + "." + stringify(PALUDIS_VERSION_MICRO)).c_str()));
-#ifdef ENABLE_RUBY_QA
-#if 0
- c_paludis_qa_module = rb_define_module_under(c_paludis_module,"QA");
- c_profiles_desc_error = rb_define_class_under(c_paludis_qa_module, "ProfilesDescError", c_configuration_error);
- c_no_such_file_check_type_error = rb_define_class_under(c_paludis_qa_module, "NoSuchFileCheckTypeError", rb_eTypeError);
- c_no_such_package_dir_check_type_error = rb_define_class_under(c_paludis_qa_module, "NoSuchPackageDirCheckTypeError", rb_eTypeError);
- cno_such_ebuild_check_type_error = rb_define_class_under(c_paludis_qa_module, "NoSuchEbuildCheckTypeError", rb_eTypeError);
-#endif
-#endif
RegisterRubyClass::get_instance()->execute();
}
+#ifdef ENABLE_RUBY_QA
+paludis::ruby::RubyQAReporter::RubyQAReporter(VALUE* ruby_reporter) {
+ this->reporter = ruby_reporter;
+}
+
+void
+paludis::ruby::RubyQAReporter::message(const QAMessageLevel l, const std::string & s, const std::string & m)
+{
+ try
+ {
+ ID message_id = rb_intern("message");
+ VALUE l_val = INT2FIX(l);
+ VALUE s_val = rb_str_new2(s.c_str());
+ VALUE m_val = rb_str_new2(m.c_str());
+ rb_funcall(*(this->reporter), message_id, 3, l_val, s_val, m_val);
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+}
+#endif
+
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 8b446de..ec1ccaa 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -38,9 +38,7 @@
#include <paludis/util/stringify.hh>
#ifdef ENABLE_RUBY_QA
-#if 0
-#include <paludis/qa/qa.hh>
-#endif
+#include <paludis/qa.hh>
#endif
#include <ruby.h>
@@ -51,6 +49,17 @@ namespace paludis
namespace ruby
{
+#ifdef ENABLE_RUBY_QA
+ class RubyQAReporter : public QAReporter
+ {
+ VALUE* reporter;
+
+ public:
+ RubyQAReporter(VALUE*);
+ void message(const QAMessageLevel, const std::string &, const std::string &);
+ };
+#endif
+
/* general utilities */
void exception_to_ruby_exception(const std::exception &) PALUDIS_ATTRIBUTE((noreturn));
@@ -89,26 +98,7 @@ namespace paludis
tr1::shared_ptr<const Repository> value_to_repository(VALUE);
#ifdef ENABLE_RUBY_QA
-#if 0
- VALUE paludis_qa_module();
- qa::Message value_to_message(VALUE v);
- qa::EbuildCheckData value_to_ebuild_check_data(VALUE v);
- qa::PerProfileEbuildCheckData value_to_per_profile_ebuild_check_data(VALUE v);
- qa::ProfileCheckData value_to_profile_check_data(VALUE v);
- tr1::shared_ptr<qa::QAEnvironment> value_to_qa_environment(VALUE v);
- VALUE ebuild_check_data_to_value(const qa::EbuildCheckData &);
- VALUE per_profile_ebuild_check_data_to_value(const qa::PerProfileEbuildCheckData &);
- VALUE profile_check_data_to_value(const qa::ProfileCheckData &);
- VALUE check_result_to_value(const qa::CheckResult &);
- VALUE package_dir_check_to_value(tr1::shared_ptr<qa::PackageDirCheck>);
- VALUE file_check_to_value(tr1::shared_ptr<qa::FileCheck>);
- VALUE ebuild_check_to_value(tr1::shared_ptr<qa::EbuildCheck>);
- VALUE per_profile_ebuild_check_to_value(tr1::shared_ptr<qa::PerProfileEbuildCheck>);
- VALUE profiles_check_to_value(tr1::shared_ptr<qa::ProfilesCheck>);
- VALUE profile_check_to_value(tr1::shared_ptr<qa::ProfileCheck>);
- VALUE message_to_value(const qa::Message &);
- VALUE metadata_file_to_value(const qa::MetadataFile &);
-#endif
+ QACheckProperties value_to_qa_check_properties(VALUE);
#endif
/* registration */
diff --git a/ruby/qa.cc b/ruby/qa.cc
new file mode 100644
index 0000000..4223287
--- /dev/null
+++ b/ruby/qa.cc
@@ -0,0 +1,198 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Richard Brown <rbrown@gentoo.org>
+ *
+ * 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/qa.hh>
+#include <ruby.h>
+
+using namespace paludis;
+using namespace paludis::ruby;
+
+#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
+
+namespace
+{
+ static VALUE c_qa_message_level;
+ static VALUE c_qa_check_property;
+ static VALUE c_qa_check_properties;
+ static VALUE c_qa_reporter;
+
+ VALUE
+ qa_check_properties_init(VALUE self)
+ {
+ return self;
+ }
+
+ VALUE
+ qa_check_properties_new(VALUE self)
+ {
+ QACheckProperties * ptr(0);
+ try
+ {
+ ptr = new QACheckProperties;
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<QACheckProperties>::free, ptr));
+ rb_obj_call_init(tdata, 0, &self);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * each {|qa_check_property| block } -> Nil
+ *
+ * Iterate through the qa check properties.
+ */
+ VALUE
+ qa_check_properties_each(VALUE self)
+ {
+ QACheckProperties * m_ptr;
+ Data_Get_Struct(self, QACheckProperties, m_ptr);
+ for (QACheckProperty i(static_cast<QACheckProperty>(0)), i_end(last_qacp) ; i != i_end ;
+ i = static_cast<QACheckProperty>(static_cast<int>(i) + 1))
+ if ((*m_ptr)[i])
+ rb_yield(INT2FIX(i));
+ return Qnil;
+ }
+
+ /*
+ * call-seq:
+ * empty? -> true or false
+ *
+ * Is the collection empty.
+ */
+ VALUE
+ qa_check_properties_empty(VALUE self)
+ {
+ QACheckProperties * m_ptr;
+ Data_Get_Struct(self, QACheckProperties, m_ptr);
+ return m_ptr->any() ? Qfalse : Qtrue;
+ }
+
+ /*
+ * call-seq:
+ * set(qa_check_property) -> Nil
+ *
+ * Add QACheckProperty to collection.
+ */
+ VALUE
+ qa_check_properties_set(VALUE self, VALUE qa_check_property)
+ {
+ QACheckProperties * m_ptr;
+ Data_Get_Struct(self, QACheckProperties, m_ptr);
+ try
+ {
+ int mr = NUM2INT(qa_check_property);
+ if (mr < 0 || mr >= last_mro)
+ rb_raise(rb_eArgError, "QACheckProperty out of range");
+ *m_ptr += static_cast<QACheckProperty>(mr);
+ return Qnil;
+
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
+ * message(qa_message_level, source, message)
+ *
+ * Process a qa error message
+ */
+ VALUE
+ ruby_qa_reporter_message(VALUE, VALUE, VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ void do_register_qa()
+ {
+ /*
+ * Document-classs: Paludis::QAReporter
+ *
+ * Base class for QAReporter, create a new sublclass that implements a message function.
+ */
+ c_qa_reporter = rb_define_class_under(paludis_module(), "QAReporter", rb_cObject);
+ rb_define_method(c_qa_reporter, "message", RUBY_FUNC_CAST(&ruby_qa_reporter_message), 3);
+
+ /*
+ * Document-class: Paludis::QACheckProperties
+ *
+ * A collection of properties for a QACheck. Includes
+ * Enumerable[http://www.ruby-doc.org/core/classes/Enumerable.html]
+ * but not Comparable.
+ */
+ c_qa_check_properties = rb_define_class_under(paludis_module(), "QACheckProperties", rb_cObject);
+ rb_define_singleton_method(c_qa_check_properties, "new", RUBY_FUNC_CAST(&qa_check_properties_new), 0);
+ rb_define_method(c_qa_check_properties, "initialize", RUBY_FUNC_CAST(&qa_check_properties_init), 0);
+ rb_define_method(c_qa_check_properties, "each", RUBY_FUNC_CAST(&qa_check_properties_each), 0);
+ rb_include_module(c_qa_check_properties, rb_mEnumerable);
+ rb_define_method(c_qa_check_properties, "empty?", RUBY_FUNC_CAST(&qa_check_properties_empty), 0);
+ rb_define_method(c_qa_check_properties, "set", RUBY_FUNC_CAST(&qa_check_properties_set), 1);
+ rb_define_method(c_qa_check_properties, "add", RUBY_FUNC_CAST(&qa_check_properties_set), 1);
+
+ /*
+ * Document-module: Paludis::QAMessageLevel
+ *
+ * The importance of a QA notice.
+ *
+ */
+ c_qa_message_level = rb_define_module_under(paludis_module(), "QAMessageLevel");
+ for (QAMessageLevel l(static_cast<QAMessageLevel>(0)), l_end(last_qaml) ; l != l_end ;
+ l = static_cast<QAMessageLevel>(static_cast<int>(l) + 1))
+ rb_define_const(c_qa_message_level, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+ /*
+ * Document-module: Paludis::QACheckProperty
+ *
+ * Properties of a QA check.
+ *
+ */
+ c_qa_check_property = rb_define_module_under(paludis_module(), "QACheckProperty");
+ for (QACheckProperty l(static_cast<QACheckProperty>(0)), l_end(last_qacp) ; l != l_end ;
+ l = static_cast<QACheckProperty>(static_cast<int>(l) + 1))
+ rb_define_const(c_qa_check_property, value_case_to_RubyCase(stringify(l)).c_str(), INT2FIX(l));
+
+
+ }
+}
+
+RegisterRubyClass::Register paludis_ruby_register_qa PALUDIS_ATTRIBUTE((used))
+ (&do_register_qa);
+
+QACheckProperties
+paludis::ruby::value_to_qa_check_properties(VALUE v)
+{
+ if (rb_obj_is_kind_of(v, c_qa_check_properties))
+ {
+ QACheckProperties * v_ptr;
+ Data_Get_Struct(v, QACheckProperties, v_ptr);
+ return *v_ptr;
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into QACheckProperties", rb_obj_classname(v));
+ }
+}
diff --git a/ruby/qa_TEST.rb b/ruby/qa_TEST.rb
new file mode 100644
index 0000000..6b18ce5
--- /dev/null
+++ b/ruby/qa_TEST.rb
@@ -0,0 +1,59 @@
+#!/usr/bin/env ruby
+# vim: set sw=4 sts=4 et tw=80 :
+
+#
+# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+#
+# 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
+#
+
+require 'test/unit'
+require 'Paludis'
+
+module Paludis
+ class TestCase_QACheckProperties < Test::Unit::TestCase
+ def test_create
+ m = QACheckProperties.new
+ end
+
+ def test_each
+ m = QACheckProperties.new
+ assert_equal [], m.to_a
+ end
+
+ def test_empty
+ m = QACheckProperties.new
+ assert m.empty?
+ end
+
+ def test_set
+ m = QACheckProperties.new
+ m.set QACheckProperty::NeedsBuild
+ m.set QACheckProperty::NeedsNetwork
+ :qa
+
+ assert ! m.empty?
+
+ assert m.include?(QACheckProperty::NeedsBuild)
+ assert m.include?(QACheckProperty::NeedsNetwork)
+ end
+ end
+
+ class TestCase_QAReporter < Test::Unit::TestCase
+ def test_respond
+ assert_respond_to QAReporter.new, :message
+ end
+ end
+end
+
diff --git a/ruby/qa_environment.cc b/ruby/qa_environment.cc
deleted file mode 100644
index 66fadb4..0000000
--- a/ruby/qa_environment.cc
+++ /dev/null
@@ -1,117 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
- *
- * 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/qa/qa_environment.hh>
-#include <paludis/util/fs_entry.hh>
-#include <ruby.h>
-
-using namespace paludis;
-using namespace paludis::qa;
-using namespace paludis::ruby;
-
-#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
-
-namespace
-{
- static VALUE c_qa_environment;
-
- VALUE
- qa_environment_init(int, VALUE*, VALUE self)
- {
- return self;
- }
-
- /*
- * call-seq:
- * QAEnvironment.new(dir) -> QAEnvironment
- * QAEnvironment.new(dir, write_cache_dir) -> QAEnvironment
- * QAEnvironment.new(dir, write_cache_dir, master_repository_dir) -> QAEnvironment
- *
- * Creates a new QAEnvironment from the specified directory. A write cache and master repository
- * may also be specified.
- */
- VALUE
- qa_environment_new(int argc, VALUE* argv, VALUE self)
- {
- std::string write_cache, master_repository_dir;
- try
- {
- if (1 == argc)
- {
- write_cache = "/var/empty";
- master_repository_dir = "/var/empty";
- }
- else if (2 == argc)
- {
- write_cache = StringValuePtr(argv[1]);
- master_repository_dir = "/var/empty";
- }
- else if (3 == argc)
- {
- write_cache = StringValuePtr(argv[1]);
- master_repository_dir = StringValuePtr(argv[2]);
- }
- else
- {
- rb_raise(rb_eArgError, "QAEnvironment expects one to three arguments, but got %d",argc);
- }
- tr1::shared_ptr<QAEnvironment> * e = new tr1::shared_ptr<QAEnvironment>(new QAEnvironment(FSEntry(StringValuePtr(argv[0])), FSEntry(write_cache),
- FSEntry(master_repository_dir)));
- VALUE tdata(Data_Wrap_Struct(self, 0, &Common< tr1::shared_ptr<QAEnvironment> >::free, e));
- rb_obj_call_init(tdata, argc, argv);
- return tdata;
- }
- catch (const std::exception & e)
- {
- exception_to_ruby_exception(e);
- }
- }
-
- void do_register_qa_environment()
- {
- /*
- * Document-class: Paludis::QA::QAEnvironment
- *
- * The QAEnvironment is an environment fo running QA checks in.
- */
- c_qa_environment = rb_define_class_under(paludis_qa_module(), "QAEnvironment",
- no_config_environment_class());
- rb_define_singleton_method(c_qa_environment, "new", RUBY_FUNC_CAST(&qa_environment_new),-1);
- rb_define_method(c_qa_environment, "initialize", RUBY_FUNC_CAST(&qa_environment_init),-1);
- }
-}
-
-tr1::shared_ptr<QAEnvironment>
-paludis::ruby::value_to_qa_environment(VALUE v)
-{
- if (rb_obj_is_kind_of(v, c_qa_environment))
- {
- tr1::shared_ptr<QAEnvironment> * v_ptr;
- Data_Get_Struct(v, tr1::shared_ptr<QAEnvironment>, v_ptr);
- return *v_ptr;
- }
- else
- {
- rb_raise(rb_eTypeError, "Can't convert %s into QAEnvironment", rb_obj_classname(v));
- }
-}
-
-RegisterRubyClass::Register paludis_ruby_register_qa_environment PALUDIS_ATTRIBUTE((used))
- (&do_register_qa_environment);
diff --git a/ruby/qa_environment_TEST.rb b/ruby/qa_environment_TEST.rb
deleted file mode 100644
index 2379fac..0000000
--- a/ruby/qa_environment_TEST.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env ruby
-# vim: set sw=4 sts=4 et tw=80 :
-
-#
-# Copyright (c) 2006 Richard Brown <rbrown@gentoo.org>
-#
-# 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
-#
-
-require 'test/unit'
-require 'Paludis'
-
-Paludis::Log.instance.log_level = Paludis::LogLevel::Silent
-
-module Paludis
- module QA
- class TestCase_QAEnvironment < Test::Unit::TestCase
- def test_create
- env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
- env = QAEnvironment.new('qa_environment_TEST_dir/repo1', '/var/empty')
- end
-
- def test_create_error
- assert_raise ArgumentError do
- env = QAEnvironment.new
- end
-
- assert_raise ArgumentError do
- env = QAEnvironment.new("1","2","3","4")
- end
- end
-
- def test_as_environment
- env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
- assert_kind_of PackageDatabase, env.package_database
- end
-
- def test_pass
- env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
- check = EbuildCheckMaker.instance.find_maker('create_metadata')
- ecd = EbuildCheckData.new('cat-one/pkg-one', "1", env)
- cr = check.check(ecd)
- assert_equal true, cr.empty?
- end
-
- def test_fail
- env = QAEnvironment.new('qa_environment_TEST_dir/repo1')
- check = EbuildCheckMaker.instance.find_maker('create_metadata')
- ecd = EbuildCheckData.new('cat-one/pkg-one', "2", env)
- # This outputs stuff to stderr. Don't Panic.
- cr = check.check(ecd)
- assert_equal false, cr.empty?
- end
- end
- end
-end
-
diff --git a/ruby/qa_environment_TEST_cleanup.sh b/ruby/qa_environment_TEST_cleanup.sh
deleted file mode 100755
index 02ed13f..0000000
--- a/ruby/qa_environment_TEST_cleanup.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash
-# vim: set ft=sh sw=4 sts=4 et :
-
-if [ -d qa_environment_TEST_dir ] ; then
- rm -fr qa_environment_TEST_dir
-else
- true
-fi
-
-
-
diff --git a/ruby/qa_environment_TEST_setup.sh b/ruby/qa_environment_TEST_setup.sh
deleted file mode 100755
index 6764e76..0000000
--- a/ruby/qa_environment_TEST_setup.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-# vim: set ft=sh sw=4 sts=4 et :
-
-mkdir qa_environment_TEST_dir || exit 1
-cd qa_environment_TEST_dir || exit 1
-
-mkdir -p repo1/{eclass,distfiles,profiles/profile} || exit 1
-cd repo1 || exit 1
-echo "test-repo-1" > profiles/repo_name || exit 1
-cat <<END > profiles/categories || exit 1
-cat-one
-cat-two
-cat-three
-END
-cat <<END > profiles/profile/make.defaults
-ARCH=test
-END
-cat <<END > profiles/profiles.desc
-test profile/ stable
-END
-mkdir -p cat-one/pkg-one
-cat <<END > cat-one/pkg-one/pkg-one-1.ebuild
-DESCRIPTION="foo"
-SLOT="foo"
-END
-cat <<END > cat-one/pkg-one/pkg-one-2.ebuild
-DESCRIPTION="foo"
-if has_version foo ; then
- SLOT="foo"
-else
- SLOT="bar"
-fi
-END
-
-cd ..
-
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 5be5290..1fb34f9 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -401,6 +401,14 @@ namespace
*
* Returns self if the repository supports the interface, otherwise Nil.
*/
+ /*
+ * Document-method: qa_interface
+ *
+ * call-seq:
+ * qa_interface -> self or Nil
+ *
+ * Returns self if the repository supports the interface, otherwise Nil.
+ */
template <typename T_, T_ * RepositoryCapabilities::* m_>
struct Interface
{
@@ -785,6 +793,39 @@ namespace
/*
* call-seq:
+ * check_qa(qa_reporter, qa_check_properties_ignore_if, qa_check_properties_ignore_unless, qa_message_minimum_level, dir) -> Qnil
+ *
+ * Check qa in the specified dir. qa_reporter.message (QAReporter) will be called for each error found.
+ *
+ */
+ VALUE
+ repository_check_qa(VALUE self, VALUE reporter, VALUE ignore_if, VALUE ignore_unless, VALUE minumum_level, VALUE dir)
+ {
+ try
+ {
+ tr1::shared_ptr<Repository> * self_ptr;
+ Data_Get_Struct(self, tr1::shared_ptr<Repository>, self_ptr);
+#ifdef ENABLE_RUBY_QA
+ if ((*self_ptr)->qa_interface)
+ {
+ RubyQAReporter* qar = new RubyQAReporter(&reporter);
+ (*self_ptr)->qa_interface->check_qa(*qar,
+ value_to_qa_check_properties((ignore_if)),
+ value_to_qa_check_properties((ignore_unless)),
+ static_cast<QAMessageLevel>(NUM2INT(minumum_level)),
+ FSEntry(StringValuePtr(dir)));
+ }
+#endif
+ return Qnil;
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ /*
+ * call-seq:
* add_category(category_name) -> Nil
*
* Add a category.
@@ -945,6 +986,8 @@ namespace
&Repository::virtuals_interface>::fetch)), 0);
rb_define_method(c_repository, "e_interface", RUBY_FUNC_CAST((&Interface<RepositoryEInterface,
&Repository::e_interface>::fetch)), 0);
+ rb_define_method(c_repository, "qa_interface", RUBY_FUNC_CAST((&Interface<RepositoryQAInterface,
+ &Repository::qa_interface>::fetch)), 0);
rb_define_method(c_repository, "info", RUBY_FUNC_CAST(&repository_info), 1);
rb_define_method(c_repository, "query_use", RUBY_FUNC_CAST((&QueryUse<UseFlagState, use_enabled, use_disabled, &RepositoryUseInterface::query_use>::query)), -1);
@@ -958,6 +1001,8 @@ namespace
rb_define_method(c_repository, "profile_variable", RUBY_FUNC_CAST(&repository_profile_variable),1);
rb_define_method(c_repository, "set_profile", RUBY_FUNC_CAST(&repository_set_profile),1);
+ rb_define_method(c_repository, "check_qa", RUBY_FUNC_CAST(&repository_check_qa),5);
+
/*
* Document-class: Paludis::RepositoryInfo
*
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index 6171696..30b1908 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -27,6 +27,7 @@ require 'Paludis'
Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
module Paludis
+
class TestCase_Repository < Test::Unit::TestCase
def test_no_create
assert_raise NoMethodError do
@@ -174,7 +175,8 @@ module Paludis
repo = no_config_testrepo.main_repository
[:installed_interface, :sets_interface, :syncable_interface, :use_interface,
:world_interface, :mirrors_interface, :environment_variable_interface,
- :provides_interface, :virtuals_interface, :e_interface].each do |sym|
+ :provides_interface, :virtuals_interface, :e_interface,
+ :qa_interface].each do |sym|
assert_respond_to repo, sym
end
end
@@ -188,6 +190,52 @@ module Paludis
end
end
+ class TestCase_RepositoryCheckQA < Test::Unit::TestCase
+ include RepositoryTestCase
+
+ def test_responds
+ assert_respond_to(no_config_testrepo.main_repository, :check_qa)
+ end
+
+ if Paludis.const_defined? :QAReporter
+ class TestQAReporter < QAReporter
+ @messages
+
+ def message(l, s, m)
+ @messages+=1
+ end
+
+ def messages
+ @messages||=0
+ return @messages
+ end
+ end
+
+ def test_check_qa
+ repo = no_config_testrepo.main_repository
+ assert_equal repo, repo.qa_interface
+ dir = Dir.getwd().to_s + "/repository_TEST_dir/testrepo"
+ assert_nil repo.check_qa(QAReporter.new, QACheckProperties.new, QACheckProperties.new, 0, dir)
+ end
+
+ def test_message
+ repo = no_config_testrepo.main_repository
+ dir = Dir.getwd().to_s + "/repository_TEST_dir/testrepo"
+ reporter = TestQAReporter.new
+ assert_equal 0, reporter.messages
+ assert_nothing_raised do
+ repo.check_qa(reporter, QACheckProperties.new, QACheckProperties.new, 0, dir)
+ end
+ assert reporter.messages > 0
+ end
+ else
+ def test_check_qa
+ repo = no_config_testrepo.main_repository
+ assert_nil repo.qa_interface
+ end
+ end
+ end
+
class TestCase_RepositoryContents < Test::Unit::TestCase
include RepositoryTestCase
diff --git a/ruby/repository_TEST_setup.sh b/ruby/repository_TEST_setup.sh
index b32f16d..121229c 100755
--- a/ruby/repository_TEST_setup.sh
+++ b/ruby/repository_TEST_setup.sh
@@ -92,6 +92,7 @@ cat <<END > profiles/use.local.desc || exit 1
foo/bar:test2 - A test local use flag
END
+touch foo/metadata.xml
cat <<"END" > foo/bar/bar-1.0.ebuild || exit 1
DESCRIPTION="Test package"