aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-23 19:52:22 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-09-23 19:52:22 +0000
commitc2e11fac6dbccc0db35f7cd389cecda80ece3dba (patch)
treef9bb542c88b9f4335d4b58b3afe224a0bbf69dcd
parent604033b71af17585586fc9bb09a6f8f63bb08169 (diff)
downloadpaludis-c2e11fac6dbccc0db35f7cd389cecda80ece3dba.tar.gz
paludis-c2e11fac6dbccc0db35f7cd389cecda80ece3dba.tar.xz
More ruby work. Distcheck should now work.
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac11
-rw-r--r--ruby/Makefile.am2
-rw-r--r--ruby/default_environment.cc26
-rw-r--r--ruby/default_environment_TEST.rb73
-rwxr-xr-xruby/default_environment_TEST_setup.sh1
6 files changed, 113 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 3f55630..c66de4c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip std-options
EXTRA_DIST = autogen.bash automake-deps-hack.tmp
SUBDIRS = misc test paludis cran ebuild ruby src doc hooks eselect
-DISTCHECK_CONFIGURE_FLAGS = --enable-qa --enable-ruby
+DISTCHECK_CONFIGURE_FLAGS = --enable-qa --enable-ruby --with-ruby-install-dir='$${prefix}/ruby_dir'
automake-deps-hack.tmp :
make -C paludis/util
diff --git a/configure.ac b/configure.ac
index 39b0e9b..71f6cc4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -530,6 +530,17 @@ if test "x$enable_ruby" = "xyes" ; then
fi
AC_MSG_RESULT([$RUBY_SONAME])
AC_SUBST([RUBY_SONAME])
+
+ AC_ARG_WITH([ruby-install-dir],
+ AS_HELP_STRING([--with-ruby-install-dir=dir], [Specify Ruby installation dir]),
+ RUBY_INSTALL_DIR=`eval echo $withval`,
+ RUBY_INSTALL_DIR=)
+ AC_MSG_CHECKING([for Ruby installation dir])
+ if test "x$RUBY_INSTALL_DIR" = "x" ; then
+ RUBY_INSTALL_DIR=$RUBY_SITEARCHDIR
+ fi
+ AC_MSG_RESULT([$RUBY_INSTALL_DIR])
+ AC_SUBST([RUBY_INSTALL_DIR])
fi
AM_CONDITIONAL([ENABLE_RUBY], test "x$enable_ruby" = "xyes")
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index a30b044..e212d03 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -53,7 +53,7 @@ OUR_OBJECTS = \
TESTS = $(IF_RUBY_TESTS)
noinst_DATA = $(OUR_OBJECTS)
check_DATA = .libs/Paludis.so
-rubylibdir = $(DESTDIR)/@RUBY_SITEARCHDIR@
+rubylibdir = $(DESTDIR)/@RUBY_INSTALL_DIR@
rubylib_DATA = Paludis.so
OUR_CXXCOMPILE = $(CXX) -fPIC $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
diff --git a/ruby/default_environment.cc b/ruby/default_environment.cc
index 61816f1..3bb699a 100644
--- a/ruby/default_environment.cc
+++ b/ruby/default_environment.cc
@@ -56,6 +56,31 @@ namespace
}
}
+ VALUE
+ default_environment_accept_keyword(int argc, VALUE * argv, VALUE)
+ {
+ try
+ {
+ if (1 == argc || 2 == argc)
+ {
+ KeywordName * keyword_name_ptr;
+ Data_Get_Struct(argv[0], KeywordName, keyword_name_ptr);
+
+ PackageDatabaseEntry * pde_ptr(0);
+ if (2 == argc)
+ Data_Get_Struct(argv[1], PackageDatabaseEntry, pde_ptr);
+
+ return DefaultEnvironment::get_instance()->accept_keyword(*keyword_name_ptr, pde_ptr) ? Qtrue : Qfalse;
+ }
+ else
+ rb_raise(rb_eArgError, "DefaultEnvironment.accept_keyword expects one or two arguments, but got %d", argc);
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_default_environment()
{
rb_require("singleton");
@@ -63,6 +88,7 @@ namespace
c_default_environment = rb_define_class("DefaultEnvironment", rb_cObject);
rb_funcall(rb_const_get(rb_cObject, rb_intern("Singleton")), rb_intern("included"), 1, c_default_environment);
rb_define_method(c_default_environment, "query_use", RUBY_FUNC_CAST(&default_environment_query_use), -1);
+ rb_define_method(c_default_environment, "accept_keyword", RUBY_FUNC_CAST(&default_environment_accept_keyword), -1);
}
}
diff --git a/ruby/default_environment_TEST.rb b/ruby/default_environment_TEST.rb
new file mode 100644
index 0000000..f8892be
--- /dev/null
+++ b/ruby/default_environment_TEST.rb
@@ -0,0 +1,73 @@
+#!/usr/bin/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
+#
+
+ENV["PALUDIS_HOME"] = Dir.getwd().to_s + "/default_environment_TEST_dir/home";
+
+require 'test/unit'
+require 'Paludis'
+
+class TestCase_DefaultEnvironment < Test::Unit::TestCase
+ def test_instance
+ assert_equal DefaultEnvironment.instance.__id__, DefaultEnvironment.instance.__id__
+ end
+
+ def test_no_create
+ assert_raise NoMethodError do
+ x = DefaultEnvironment.new()
+ end
+ end
+
+ def test_query_use
+ assert DefaultEnvironment.instance.query_use(UseFlagName.new("enabled"))
+ assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("not_enabled"))
+ assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("sometimes_enabled"))
+
+ pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("nothing"))
+
+ assert DefaultEnvironment.instance.query_use(UseFlagName.new("enabled"), pde)
+ assert ! DefaultEnvironment.instance.query_use(UseFlagName.new("not_enabled"), pde)
+ assert DefaultEnvironment.instance.query_use(UseFlagName.new("sometimes_enabled"), pde)
+ end
+
+ def test_accept_keyword
+ assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("test"))
+ assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("bad"))
+ assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("~test"))
+
+ pde = PackageDatabaseEntry.new(QualifiedPackageName.new("foo/bar"),
+ VersionSpec.new("1.0"), RepositoryName.new("nothing"))
+
+ assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("test"), pde)
+ assert ! DefaultEnvironment.instance.accept_keyword(KeywordName.new("bad"), pde)
+ assert DefaultEnvironment.instance.accept_keyword(KeywordName.new("~test"), pde)
+ end
+
+ def test_query_use_bad
+ assert_raise ArgumentError do
+ DefaultEnvironment.instance.query_use(1, 2, 3)
+ end
+ assert_raise TypeError do
+ DefaultEnvironment.instance.query_use("not_enabled")
+ end
+ end
+end
+
+
diff --git a/ruby/default_environment_TEST_setup.sh b/ruby/default_environment_TEST_setup.sh
index 8b2b450..9e8feb2 100755
--- a/ruby/default_environment_TEST_setup.sh
+++ b/ruby/default_environment_TEST_setup.sh
@@ -14,6 +14,7 @@ END
cat <<END > home/.paludis/keywords.conf
* test
+~foo/bar-1 ~test
END
cat <<END > home/.paludis/use.conf