Source

XML-CompareML / inc / XML / Grammar / Builder.pm

package XML::Grammar::Builder;

use strict;
use warnings;

use base 'Test::Run::Builder';

use File::Find;

our $VERSION = '0.0101';

sub new
{
    my $package = shift;
    my %args = @_;
    my @extradata_files;
    
    my $module_name = $args{'module_name'};
    $module_name =~ s{::}{-}g;

    my $filter_files_cb = sub {
        my $filename = $File::Find::name;
        if ((-f $filename) &&
            ($filename =~ /\.(?:mod|xslt|dtd|ent|cat|jpg|rng|xcf\.bz2)$/)
        )
        {
            push @extradata_files, $filename;
        }
    };
 
    find({ wanted => $filter_files_cb, no_chdir => 1}, "extradata");

    my $builder = $package->SUPER::new(
        extradata_files =>
        {
            (map { $_ => $_ } @extradata_files)
        },
        @_
    );

    $builder->add_build_element('extradata');

    $builder->install_path()->{'extradata'} = 
        File::Spec->catdir(
                $builder->install_destination("lib"),
                qw(data modules),
                $module_name,
                qw(data)
        );

    $builder->config_data(
        'extradata_install_path' =>
        [$builder->install_path()->{'extradata'}]
    );

    return $builder;
}


=begin excluded

    my $get_dest_extradata_cb = sub {
        my $fn = shift;

        # Trying if this makes it work.
        # TODO : Either remove this line or the rest of the lines.
        return $fn;

        $fn =~ s{^extradata}{data};
        return "lib/$module_name/$fn";
    };

=end excluded

=cut

1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.