#!/usr/bin/perl

use strict;
use PerlBean;
use PerlBean::Collection;
use PerlBean::Attribute::Factory;

@::bean_desc = ();

# The license for this Perlbean collection
my $lic = <<EOF;
This file is part of the C<PerlBean> module hierarchy for Perl by
Vincenzo Zocca.

The PerlBean module hierarchy is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.

The PerlBean module hierarchy 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 the PerlBean module hierarchy; if not, write to
the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
EOF
chomp ($lic);

foreach my $fn (<attr-*.pl>) {
    require $fn;
}

my $collection = PerlBean::Collection->new({license => $lic});
my $factory = PerlBean::Attribute::Factory->new();

foreach my $bean_desc (@::bean_desc) {
    my $bean = PerlBean->new($bean_desc->{bean_opt});
    foreach my $attr_opt (@{$bean_desc->{attr_opt}}) {
        my $attr = $factory->create_attribute($attr_opt);
        $bean->add_attribute($attr);
    }
    $collection->add_perl_bean($bean);
}

# Revove the old tmp directory
system ('rm -rf tmp');

# Make a new tmp directory
mkdir('tmp');

# Write the hierarch
$collection->write('tmp');
