package CROSS::DMOSS::PostProc;

use 5.006;
use strict;
use warnings;

=head1 NAME

CROSS::DMOSS::Processors - processor functions

=head1 VERSION

Version 0.01

=cut

our $VERSION = '0.01';

use File::Basename;
use File::Slurp qw/read_file/;
use URI::Find;
use Data::Dumper;
use HTML::FormatText::Html2text;
use File::Comments;
use Text::Aspell;
use HTTP::Request;
use LWP::UserAgent;

=head1 SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

    use CROSS::DMOSS;


=head1 EXPORT

A list of functions that can be exported.  You can delete this section
if you don't export anything, such as for a purely object-oriented module.

=head1 SUBROUTINES/METHODS

=head2 term_join

=cut

sub term_join {
   my ($name,@list) = @_;
	my $res = {};

   foreach (@list) {
      if (ref($_->{__value}) eq 'ARRAY') {
         foreach my $i (@{$_->{__value}}) { $res->{$i}++; }
      }
      else {
         $res->{$_->{__value}}++;
      }
   }

   return { $name => {__type=>'TERM',__name=>$name, __value=>[keys %$res]} };

}

=head2 post_validate_links

=cut

sub post_validate_links {
   my (@list) = @_;
	my $res = {};

	foreach (@list) {
		foreach my $i (keys %{$_->{__value}}) {
			$res->{$i} = $_->{__value}->{$i};
		}
	}

	return { proc_validate_links => {__type=>'ANY',__name=>'proc_validate_links',__value=>$res} };
}

=head2 post_check_spelling

=cut

sub post_check_spelling {
   my (@list) = @_;
	my $res = {};

	$res->{ok} = 0;
	$res->{total} = 0;

	foreach (@list) {
		$res->{ok} += $_->{__value}->{ok};
		$res->{total} += $_->{__value}->{total};
	}

   return { proc_check_spelling => {__type=>'ANY',__name=>'proc_check_spelling',__value=>$res} };
}

=head2 post_verify_license

=cut

sub post_verify_license {
   my (@list) = @_;
	my $res = {};

   foreach (@list) {
		if (ref($_->{__value}) eq 'ARRAY') {
			foreach my $i (@{$_->{__value}}) { $res->{$i}++; }
		}
		else {
			$res->{$_->{__value}}++;
		}
   }

   return { proc_verify_license => {__type=>'TERM',__name=>'proc_verify_license', __value=>[keys %$res]} };
}

=head1 AUTHOR

Nuno Carvalho, C<< <smash at cpan.org> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-cross-dmoss at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CROSS-DMOSS>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.




=head1 SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc CROSS::DMOSS


You can also look for information at:

=over 4

=item * RT: CPAN's request tracker (report bugs here)

L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CROSS-DMOSS>

=item * AnnoCPAN: Annotated CPAN documentation

L<http://annocpan.org/dist/CROSS-DMOSS>

=item * CPAN Ratings

L<http://cpanratings.perl.org/d/CROSS-DMOSS>

=item * Search CPAN

L<http://search.cpan.org/dist/CROSS-DMOSS/>

=back


=head1 ACKNOWLEDGEMENTS


=head1 LICENSE AND COPYRIGHT

Copyright 2012 Nuno Carvalho.

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.


=cut

1; # End of CROSS::DMOSS
