aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Richard Brown <rbrown@exherbo.org> 2006-12-04 19:30:43 +0000
committerAvatar Richard Brown <rbrown@exherbo.org> 2006-12-04 19:30:43 +0000
commit0883465ac852c120203a3930e994fe1f5ea7013e (patch)
tree4e29709bcc85b8bd98730a144475cb0288ccbb95
parent793595baa9eb4691be1e4a5ced0eb407f211a5da (diff)
downloadpaludis-0883465ac852c120203a3930e994fe1f5ea7013e.tar.gz
paludis-0883465ac852c120203a3930e994fe1f5ea7013e.tar.xz
Add stringify for ContentsEntry and add Contents to ruby binding.
-rw-r--r--paludis/contents.cc13
-rw-r--r--paludis/contents.hh15
-rw-r--r--ruby/Makefile.am10
-rw-r--r--ruby/contents.cc268
-rw-r--r--ruby/contents_TEST.rb252
-rw-r--r--ruby/paludis_ruby.hh2
-rw-r--r--ruby/repository.cc29
-rw-r--r--ruby/repository_TEST.rb49
-rwxr-xr-xruby/repository_TEST_setup.sh24
9 files changed, 660 insertions, 2 deletions
diff --git a/paludis/contents.cc b/paludis/contents.cc
index 471b6f1..5945f22 100644
--- a/paludis/contents.cc
+++ b/paludis/contents.cc
@@ -95,3 +95,16 @@ Contents::end() const
return Iterator(_imp->c.end());
}
+std::ostream &
+paludis::operator<< (std::ostream & s, const ContentsSymEntry & e)
+{
+ s << e.name() << " -> " << e.target();
+ return s;
+}
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const ContentsEntry & e)
+{
+ s << e.name();
+ return s;
+}
diff --git a/paludis/contents.hh b/paludis/contents.hh
index fa3b20e..281c26f 100644
--- a/paludis/contents.hh
+++ b/paludis/contents.hh
@@ -225,6 +225,21 @@ namespace paludis
///\}
};
+
+ /**
+ * Write a ContentsSymEntry to a stream
+ *
+ * \ingroup grpcontents
+ */
+ std::ostream & operator<< (std::ostream &, const ContentsSymEntry &);
+
+ /**
+ * Write a ContentsEntry to a stream
+ *
+ * \ingroup grpcontents
+ */
+ std::ostream & operator<< (std::ostream &, const ContentsEntry &);
+
}
#endif
diff --git a/ruby/Makefile.am b/ruby/Makefile.am
index bbc4783..cc2afea 100644
--- a/ruby/Makefile.am
+++ b/ruby/Makefile.am
@@ -27,7 +27,8 @@ IF_RUBY_TESTS = \
repository_TEST.rb \
version_metadata_TEST.rb \
portage_dep_parser_TEST.rb \
- qualified_package_name_TEST.rb
+ qualified_package_name_TEST.rb \
+ contents_TEST.rb
IF_RUBY_QA_TESTS = \
message_TEST.rb \
@@ -48,7 +49,8 @@ IF_RUBY_SOURCES = \
repository.cc \
version_metadata.cc \
portage_dep_parser.cc \
- qualified_package_name.cc
+ qualified_package_name.cc \
+ contents.cc
IF_RUBY_QA_SOURCES = \
message.cc \
@@ -97,6 +99,7 @@ BASE_OBJECTS = \
version_metadata.o \
portage_dep_parser.o \
qualified_package_name.o \
+ contents.o \
paludis_ruby.o
if ENABLE_QA
@@ -163,6 +166,9 @@ portage_dep_parser.o : portage_dep_parser.cc paludis_ruby.hh
qualified_package_name.o : qualified_package_name.cc paludis_ruby.hh
$(OUR_CXXCOMPILE) -o $@ $(srcdir)/qualified_package_name.cc
+contents.o : contents.cc paludis_ruby.hh
+ $(OUR_CXXCOMPILE) -o $@ $(srcdir)/contents.cc
+
message.o : message.cc paludis_ruby.hh
$(OUR_CXXCOMPILE) -o $@ $(srcdir)/message.cc
diff --git a/ruby/contents.cc b/ruby/contents.cc
new file mode 100644
index 0000000..dc6bd87
--- /dev/null
+++ b/ruby/contents.cc
@@ -0,0 +1,268 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006 Richard Brown <mynamewasgone@gmail.com>
+ *
+ * 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/contents.hh>
+#include <ruby.h>
+
+using namespace paludis;
+using namespace paludis::ruby;
+
+#define RUBY_FUNC_CAST(x) reinterpret_cast<VALUE (*)(...)>(x)
+
+namespace
+{
+ static VALUE c_contents;
+ static VALUE c_contents_entry;
+ static VALUE c_contents_file_entry;
+ static VALUE c_contents_dir_entry;
+ static VALUE c_contents_sym_entry;
+ static VALUE c_contents_misc_entry;
+
+ VALUE
+ contents_init(VALUE self)
+ {
+ return self;
+ }
+
+ VALUE
+ contents_new(VALUE self)
+ {
+ Contents::Pointer * ptr(0);
+ try
+ {
+ ptr = new Contents::Pointer(new Contents());
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<Contents::Pointer>::free, ptr));
+ rb_obj_call_init(tdata, 0, 0);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ VALUE contents_add(VALUE self, VALUE v)
+ {
+ if (rb_obj_is_kind_of(v, c_contents_entry))
+ {
+ try
+ {
+ Contents::Pointer * self_ptr;
+ Data_Get_Struct(self, Contents::Pointer, self_ptr);
+ ContentsEntry::ConstPointer * v_ptr;
+ Data_Get_Struct(v, ContentsEntry::ConstPointer, v_ptr);
+ (*self_ptr)->add(*v_ptr);
+ return self;
+
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+ else
+ {
+ rb_raise(rb_eTypeError, "Can't convert %s into ContentsEntry", rb_obj_classname(v));
+ }
+ }
+
+ VALUE
+ contents_entries(VALUE self)
+ {
+ Contents::Pointer * ptr;
+ Data_Get_Struct(self, Contents::Pointer, ptr);
+
+ VALUE result(rb_ary_new());
+ for (Contents::Iterator i ((*ptr)->begin()), i_end((*ptr)->end()) ; i != i_end; ++i)
+ rb_ary_push(result, contents_entry_to_value(*i));
+ return result;
+ }
+
+ VALUE
+ contents_entry_init(int, VALUE *, VALUE self)
+ {
+ return self;
+ }
+
+ template <typename A_>
+ struct ContentsNew
+ {
+ static VALUE
+ contents_entry_new(int argc, VALUE * argv, VALUE self)
+ {
+ typename A_::ConstPointer * ptr(0);
+ try
+ {
+ if (1 == argc)
+ {
+ ptr = new typename A_::ConstPointer(new A_(StringValuePtr(argv[0])));
+ }
+ else
+ {
+ rb_raise(rb_eArgError, "ContentsEntry expects one argument, but got %d",argc);
+ }
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<typename A_::ConstPointer>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+ };
+
+ VALUE contents_sym_entry_new(int argc, VALUE * argv, VALUE self)
+ {
+ ContentsSymEntry::ConstPointer * ptr(0);
+ try
+ {
+ if (2 == argc)
+ {
+ ptr = new ContentsSymEntry::ConstPointer(new ContentsSymEntry(StringValuePtr(argv[0]), StringValuePtr(argv[1])));
+ }
+ else
+ {
+ rb_raise(rb_eArgError, "ContentsSymEntry expects two arguments, but got %d",argc);
+ }
+ VALUE tdata(Data_Wrap_Struct(self, 0, &Common<ContentsSymEntry::ConstPointer>::free, ptr));
+ rb_obj_call_init(tdata, argc, argv);
+ return tdata;
+ }
+ catch (const std::exception & e)
+ {
+ delete ptr;
+ exception_to_ruby_exception(e);
+ }
+ }
+
+ template <typename T_, std::string (T_::* m_) () const>
+ struct ContentsThings
+ {
+ static VALUE
+ fetch(VALUE self)
+ {
+ typename T_::ConstPointer * ptr;
+ Data_Get_Struct(self,typename T_::ConstPointer, ptr);
+ return rb_str_new2((((**ptr).*m_)()).c_str());
+ }
+ };
+
+ void do_register_contents()
+ {
+ c_contents = rb_define_class_under(paludis_module(), "Contents", rb_cObject);
+ rb_define_singleton_method(c_contents, "new", RUBY_FUNC_CAST(&contents_new), 0);
+ rb_define_method(c_contents, "initialize", RUBY_FUNC_CAST(&contents_init), 0);
+ rb_define_method(c_contents, "entries", RUBY_FUNC_CAST(&contents_entries), 0);
+ rb_define_method(c_contents, "add", RUBY_FUNC_CAST(&contents_add), 1);
+
+ c_contents_entry = rb_define_class_under(paludis_module(), "ContentsEntry", rb_cObject);
+ rb_funcall(c_contents_entry, rb_intern("private_class_method"), 1, rb_str_new2("new"));
+ rb_define_method(c_contents_entry, "name", RUBY_FUNC_CAST((&ContentsThings<ContentsEntry,&ContentsEntry::name>::fetch)), 0);
+ rb_define_method(c_contents_entry, "initialize", RUBY_FUNC_CAST(&contents_entry_init),-1);
+ rb_define_method(c_contents_entry, "to_s", RUBY_FUNC_CAST(&Common<ContentsEntry::ConstPointer>::to_s_via_ptr), 0);
+
+ c_contents_file_entry = rb_define_class_under(paludis_module(), "ContentsFileEntry", c_contents_entry);
+ rb_define_singleton_method(c_contents_file_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsFileEntry>::contents_entry_new)), -1);
+ c_contents_dir_entry = rb_define_class_under(paludis_module(), "ContentsDirEntry", c_contents_entry);
+ rb_define_singleton_method(c_contents_dir_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsDirEntry>::contents_entry_new)), -1);
+ c_contents_misc_entry = rb_define_class_under(paludis_module(), "ContentsMiscEntry", c_contents_entry);
+ rb_define_singleton_method(c_contents_misc_entry, "new", RUBY_FUNC_CAST((&ContentsNew<ContentsMiscEntry>::contents_entry_new)), -1);
+ c_contents_sym_entry = rb_define_class_under(paludis_module(), "ContentsSymEntry", c_contents_entry);
+ rb_define_singleton_method(c_contents_sym_entry, "new", RUBY_FUNC_CAST(&contents_sym_entry_new), -1);
+ rb_define_method(c_contents_sym_entry, "to_s", RUBY_FUNC_CAST(&Common<ContentsSymEntry::ConstPointer>::to_s_via_ptr), 0);
+ rb_define_method(c_contents_sym_entry, "target", RUBY_FUNC_CAST((&ContentsThings<ContentsSymEntry,&ContentsSymEntry::target>::fetch)), 0);
+ }
+}
+
+VALUE
+paludis::ruby::contents_entry_to_value(ContentsEntry::ConstPointer m)
+{
+ struct V :
+ ContentsVisitorTypes::ConstVisitor
+ {
+ VALUE value;
+ ContentsEntry::ConstPointer mm;
+
+ V(ContentsEntry::ConstPointer _m) :
+ mm(_m)
+ {
+ }
+
+ void visit(const ContentsFileEntry *)
+ {
+ value = Data_Wrap_Struct(c_contents_file_entry, 0, &Common<ContentsFileEntry::ConstPointer>::free,
+ new ContentsFileEntry::ConstPointer(mm));
+ }
+
+ void visit(const ContentsDirEntry *)
+ {
+ value = Data_Wrap_Struct(c_contents_dir_entry, 0, &Common<ContentsDirEntry::ConstPointer>::free,
+ new ContentsDirEntry::ConstPointer(mm));
+ }
+
+ void visit(const ContentsMiscEntry *)
+ {
+ value = Data_Wrap_Struct(c_contents_misc_entry, 0, &Common<ContentsMiscEntry::ConstPointer>::free,
+ new ContentsMiscEntry::ConstPointer(mm));
+ }
+
+ void visit(const ContentsSymEntry *)
+ {
+ value = Data_Wrap_Struct(c_contents_sym_entry, 0, &Common<ContentsSymEntry::ConstPointer>::free,
+ new ContentsSymEntry::ConstPointer(mm));
+ }
+ };
+
+ ContentsEntry::ConstPointer * m_ptr(0);
+ try
+ {
+ V v(m);
+ m->accept(&v);
+ return v.value;
+ }
+ catch (const std::exception & e)
+ {
+ delete m_ptr;
+ exception_to_ruby_exception(e);
+ }
+}
+
+VALUE
+paludis::ruby::contents_to_value(Contents::ConstPointer m)
+{
+ Contents::ConstPointer * m_ptr(0);
+ try
+ {
+ m_ptr = new Contents::ConstPointer(m);
+ return Data_Wrap_Struct(c_contents, 0, &Common<Contents::ConstPointer>::free, m_ptr);
+ }
+ catch (const std::exception & e)
+ {
+ delete m_ptr;
+ exception_to_ruby_exception(e);
+ }
+}
+
+RegisterRubyClass::Register paludis_ruby_register_contents PALUDIS_ATTRIBUTE((used))
+ (&do_register_contents);
+
diff --git a/ruby/contents_TEST.rb b/ruby/contents_TEST.rb
new file mode 100644
index 0000000..0bcbc9a
--- /dev/null
+++ b/ruby/contents_TEST.rb
@@ -0,0 +1,252 @@
+#!/usr/bin/env ruby
+# vim: set sw=4 sts=4 et tw=80 :
+
+#
+# Copyright (c) 2006 Richard Brown <mynamewasgone@gmail.com>
+#
+# 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_ContentsEntry < Test::Unit::TestCase
+ def test_no_create
+ assert_raise NoMethodError do
+ ce = ContentsEntry.new('test')
+ end
+ end
+ end
+
+ class TestCase_ContentsFileEntry < Test::Unit::TestCase
+ def get_ce
+ ContentsFileEntry.new('test')
+ end
+
+ def test_create
+ assert_kind_of ContentsEntry, get_ce
+ end
+
+ def test_create_error
+ assert_raise ArgumentError do
+ ContentsFileEntry.new
+ end
+
+ assert_raise ArgumentError do
+ ContentsFileEntry.new('a','b')
+ end
+
+ assert_raise TypeError do
+ ContentsFileEntry.new(1)
+ end
+ end
+
+ def test_respond_to
+ ce = get_ce
+ assert_respond_to ce, :name
+ end
+
+ def test_name
+ ce = get_ce
+ assert_equal 'test', ce.name
+ end
+
+ def test_to_s
+ ce = get_ce
+ assert_equal 'test', ce.to_s
+ end
+ end
+
+ class TestCase_ContentsDirEntry < Test::Unit::TestCase
+ def get_ce
+ ContentsDirEntry.new('test')
+ end
+
+ def test_create
+ assert_kind_of ContentsEntry, get_ce
+ end
+
+ def test_create_error
+ assert_raise ArgumentError do
+ ContentsDirEntry.new
+ end
+
+ assert_raise ArgumentError do
+ ContentsDirEntry.new('a','b')
+ end
+
+ assert_raise TypeError do
+ ContentsDirEntry.new(1)
+ end
+ end
+
+ def test_respond_to
+ ce = get_ce
+ assert_respond_to ce, :name
+ end
+
+ def test_name
+ ce = get_ce
+ assert_equal 'test', ce.name
+ end
+
+ def test_to_s
+ ce = get_ce
+ assert_equal 'test', ce.to_s
+ end
+ end
+
+ class TestCase_ContentsMiscEntry < Test::Unit::TestCase
+ def get_ce
+ ContentsMiscEntry.new('test')
+ end
+
+ def test_create
+ assert_kind_of ContentsEntry, get_ce
+ end
+
+ def test_create_error
+ assert_raise ArgumentError do
+ ContentsMiscEntry.new
+ end
+
+ assert_raise ArgumentError do
+ ContentsMiscEntry.new('a','b')
+ end
+
+ assert_raise TypeError do
+ ContentsMiscEntry.new(1)
+ end
+ end
+
+ def test_respond_to
+ ce = get_ce
+ assert_respond_to ce, :name
+ end
+
+ def test_name
+ ce = get_ce
+ assert_equal 'test', ce.name
+ end
+
+ def test_to_s
+ ce = get_ce
+ assert_equal 'test', ce.to_s
+ end
+ end
+
+ class TestCase_ContentsSymEntry < Test::Unit::TestCase
+ def get_ce
+ ContentsSymEntry.new('test_name', 'test_target')
+ end
+
+ def test_create
+ assert_kind_of ContentsEntry, get_ce
+ end
+
+ def test_create_error
+ assert_raise ArgumentError do
+ ContentsSymEntry.new
+ end
+
+ assert_raise ArgumentError do
+ ContentsSymEntry.new('a')
+ end
+
+ assert_raise ArgumentError do
+ ContentsSymEntry.new('a','b','c')
+ end
+
+ assert_raise TypeError do
+ ContentsSymEntry.new('a',1)
+ end
+
+ assert_raise TypeError do
+ ContentsSymEntry.new(1,'b')
+ end
+ end
+
+ def test_respond_to
+ ce = get_ce
+ assert_respond_to ce, :name
+ assert_respond_to ce, :target
+ end
+
+ def test_name
+ ce = get_ce
+ assert_equal 'test_name', ce.name
+ end
+
+ def test_target
+ ce = get_ce
+ assert_equal 'test_target', ce.target
+ end
+
+ def test_to_s
+ ce = get_ce
+ assert_equal "test_name -> test_target", ce.to_s
+ end
+ end
+ class TestCase_Contents < Test::Unit::TestCase
+ def get_cfe
+ ContentsFileEntry.new('test')
+ end
+
+ def get_cse
+ ContentsSymEntry.new('test_name', 'test_target')
+ end
+
+ def get_c
+ c = Contents.new
+ end
+
+ def test_create
+ get_c
+ end
+
+ def test_responds_to
+ c = get_c
+ assert_respond_to c, :add
+ assert_respond_to c, :entries
+ end
+
+ def test_add
+ assert_nothing_raised do
+ get_c().add(get_cfe)
+ end
+ end
+
+ def test_entries
+ c = get_c
+
+ assert_equal true, c.entries.empty?
+
+ cfe = get_cfe
+ cse = get_cse
+ c.add(cfe)
+
+ assert_equal 1, c.entries.length
+ assert_equal cfe.to_s, c.entries.first.to_s
+
+ c.add(cse)
+
+ assert_equal 2, c.entries.length
+ assert_equal cfe.to_s, c.entries.first.to_s
+ assert_equal cse.to_s, c.entries.last.to_s
+
+ end
+ end
+end
+
diff --git a/ruby/paludis_ruby.hh b/ruby/paludis_ruby.hh
index 2e5adc3..c5e955f 100644
--- a/ruby/paludis_ruby.hh
+++ b/ruby/paludis_ruby.hh
@@ -81,6 +81,8 @@ namespace paludis
VALUE version_metadata_to_value(VersionMetadata::ConstPointer);
VALUE dep_atom_to_value(DepAtom::ConstPointer);
VALUE qualified_package_name_to_value(const QualifiedPackageName &);
+ VALUE contents_to_value(Contents::ConstPointer);
+ VALUE contents_entry_to_value(ContentsEntry::ConstPointer);
VersionSpec value_to_version_spec(VALUE v);
VersionMetadata::ConstPointer value_to_version_metadata(VALUE);
diff --git a/ruby/repository.cc b/ruby/repository.cc
index 103832e..49b5646 100644
--- a/ruby/repository.cc
+++ b/ruby/repository.cc
@@ -235,6 +235,34 @@ namespace
}
}
+ VALUE
+ repository_contents(VALUE self, VALUE qpn, VALUE vs)
+ {
+ try
+ {
+ Repository::ConstPointer * self_ptr;
+ Data_Get_Struct(self, Repository::ConstPointer, self_ptr);
+ const RepositoryInstalledInterface * const installed_interface ((**self_ptr).installed_interface);
+ if (installed_interface)
+ {
+ return contents_to_value(
+ installed_interface->contents(
+ value_to_qualified_package_name(qpn),
+ value_to_version_spec(vs)
+ )
+ );
+ }
+ else
+ {
+ return Qnil;
+ }
+ }
+ catch (const std::exception & e)
+ {
+ exception_to_ruby_exception(e);
+ }
+ }
+
void do_register_repository()
{
c_repository = rb_define_class_under(paludis_module(), "Repository", rb_cObject);
@@ -279,6 +307,7 @@ namespace
&Repository::virtuals_interface>::fetch)), 0);
rb_define_method(c_repository, "info", RUBY_FUNC_CAST(&repository_info), 1);
+ rb_define_method(c_repository, "contents", RUBY_FUNC_CAST(&repository_contents), 2);
c_repository_info = rb_define_class_under(paludis_module(), "RepositoryInfo", rb_cObject);
rb_funcall(c_repository_info, rb_intern("private_class_method"), 1, rb_str_new2("new"));
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index d05f612..f0a187d 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -35,6 +35,10 @@ module Paludis
end
module RepositoryTestCase
+ def installed_repo
+ db.fetch_repository "installed"
+ end
+
def repo
db.fetch_repository "testrepo"
end
@@ -131,5 +135,50 @@ module Paludis
assert_nil repo.installed_interface
end
end
+
+ class TestCase_RepositoryContents < Test::Unit::TestCase
+ include RepositoryTestCase
+
+ def entries
+ contents = installed_repo.contents('cat-one/pkg-one','1')
+ entries = contents.entries
+ end
+
+ def test_installed
+ assert_not_nil installed_repo.installed_interface
+ end
+
+ def test_contents
+ contents = installed_repo.contents('cat-one/pkg-one','1')
+ assert_kind_of Contents, contents
+ end
+
+ def test_contents_entries
+ assert_kind_of Array, entries
+ assert_equal 3, entries.length
+ end
+
+ def test_first_entry
+ assert_kind_of ContentsEntry, entries[0]
+ assert_kind_of ContentsDirEntry, entries[0]
+ assert_equal '//test', entries[0].to_s
+ assert_equal '//test', entries[0].name
+ end
+
+ def test_second_entry
+ assert_kind_of ContentsEntry, entries[1]
+ assert_kind_of ContentsFileEntry, entries[1]
+ assert_equal '/test/test_file', entries[1].to_s
+ assert_equal '/test/test_file', entries[1].name
+ end
+
+ def test_third_entry
+ assert_kind_of ContentsEntry, entries[2]
+ assert_kind_of ContentsSymEntry, entries[2]
+ assert_equal '/test/test_link -> /test/test_file', entries[2].to_s
+ assert_equal '/test/test_file', entries[2].target
+ assert_equal '/test/test_link', entries[2].name
+ end
+ end
end
diff --git a/ruby/repository_TEST_setup.sh b/ruby/repository_TEST_setup.sh
index 06cbbd3..54a0a7a 100755
--- a/ruby/repository_TEST_setup.sh
+++ b/ruby/repository_TEST_setup.sh
@@ -14,6 +14,13 @@ cache = /var/empty
profiles = \${location}/profiles/testprofile
END
+cat <<END > home/.paludis/repositories/installed.conf
+location = `pwd`/installed
+format = vdb
+names_cache = /var/empty
+provides_cache = /var/empty
+END
+
cat <<END > home/.paludis/keywords.conf
* test
~foo/bar-1 ~test
@@ -30,6 +37,7 @@ END
mkdir -p testrepo/{eclass,distfiles,profiles/testprofile,foo/bar/files} || exit 1
cd testrepo || exit 1
+
echo "testrepo" > profiles/repo_name || exit 1
cat <<END > profiles/categories || exit 1
foo
@@ -61,5 +69,21 @@ KEYWORDS="~test"
END
cd ..
+mkdir -p installed/cat-one/pkg-one-1 || exit 1
+for i in SLOT EAPI; do
+ echo "0" >installed/cat-one/pkg-one-1/${i}
+done
+
+for i in DEPEND RDEPEND LICENSE INHERITED IUSE PDEPEND PROVIDE; do
+ touch installed/cat-one/pkg-one-1/${i}
+done
+
+echo "flag1 flag2" >>installed/cat-one/pkg-one-1/USE
+
+cat <<END >installed/cat-one/pkg-one-1/CONTENTS
+dir //test
+obj /test/test_file de54c26b0678df67aca147575523b3c2 1165250496
+sym /test/test_link -> /test/test_file 1165250496
+END