+sub prepare{
+ my ($name, $format) = @_;
+ get_logger->trace("Preparing file $name...");
+
+ $Gruntmaster::Daemon::errors .= `gruntmaster-compile $format $name 2>&1`;
+ $Gruntmaster::Daemon::errors .= "\n";
+ die 'Compile error' if $?
+}
+
+sub prepare_files{
+ my $meta = shift;
+
+ for my $file (values $meta->{files}) {
+ my ($format, $name, $content) = @{$file}{qw/format name content/};
+
+ $file->{run} = mkrun($format);
+ write_file $name, $content;
+ prepare $name, $format;
+ }
+}
+
+1;
+__END__
+
+=encoding utf-8
+
+=head1 NAME
+
+Gruntmaster::Daemon::Format - Utility functions for handling source files
+
+=head1 SYNOPSIS
+
+ use Gruntmaster::Daemon::Format qw/prepare_files/;
+ prepare_files { files => {
+ prog => {
+ name => 'prog.pl',
+ format => 'PERL',
+ content => 'print "Hello, world!"'
+ },
+ ver => {
+ name => 'ver.cpp',
+ format => 'CPP',
+ content => ...
+ },
+ }};
+
+=head1 DESCRIPTION
+
+Gruntmaster::Daemon::Format exports utility functions for handling source files.
+
+=over
+
+=item B<prepare_files> I<$meta>
+
+Compiles all the source files in C<< $meta->{files} >>.
+
+=back
+
+=head1 AUTHOR
+
+Marius Gavrilescu E<lt>marius@ieval.roE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2014 by Marius Gavrilescu
+
+This library is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+
+=cut