| 1 | package Padre::Plugin::Perl6::Syntax; | ||
| 2 | BEGIN { | ||
| 3 | $Padre::Plugin::Perl6::Syntax::VERSION = '0.71'; | ||
| 4 | } | ||
| 5 | |||
| 6 | # ABSTRACT: Perl document background syntax-checker | ||
| 7 | |||
| 8 | use 5.010; | ||
| 9 | use strict; | ||
| 10 | use warnings; | ||
| 11 | use Carp (); | ||
| 12 | use Params::Util (); | ||
| 13 | use Padre::Task (); | ||
| 14 | |||
| 15 | our @ISA = 'Padre::Task'; | ||
| 16 | |||
| 17 | sub new { | ||
| 18 | my $self = shift->SUPER::new(@_); | ||
| 19 | |||
| 20 | # Just convert the document to text for now. | ||
| 21 | # Later, we'll suck in more data from the project and | ||
| 22 | # other related documents to do syntax checks more awesomely. | ||
| 23 | unless ( Params::Util::_INSTANCE( $self->{document}, 'Padre::Document' ) ) { | ||
| 24 | die "Failed to provide a document to the syntax check task"; | ||
| 25 | } | ||
| 26 | |||
| 27 | # Remove the document entirely as we do this, | ||
| 28 | # as it won't be able to survive serialisation. | ||
| 29 | my $document = delete $self->{document}; | ||
| 30 | |||
| 31 | # Clone issues | ||
| 32 | my $cloned_issues = []; | ||
| 33 | if ( $document->{issues} ) { | ||
| 34 | my @issues = @{ $document->{issues} }; | ||
| 35 | foreach (@issues) { | ||
| 36 | my %cloned_issue = %$_; | ||
| 37 | push @{$cloned_issues}, \%cloned_issue; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | $self->{issues} = $cloned_issues; | ||
| 41 | |||
| 42 | return $self; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub run { | ||
| 46 | my $self = shift; | ||
| 47 | |||
| 48 | $self->{model} = delete $self->{issues}; | ||
| 49 | |||
| 50 | return 1; | ||
| 51 | } | ||
| 52 | |||
| 53 | 1; | ||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | =pod | ||
| 58 | |||
| 59 | =head1 NAME | ||
| 60 | |||
| 61 | Padre::Plugin::Perl6::Syntax - Perl document background syntax-checker | ||
| 62 | |||
| 63 | =head1 VERSION | ||
| 64 | |||
| 65 | version 0.71 | ||
| 66 | |||
| 67 | =head1 SYNOPSIS | ||
| 68 | |||
| 69 | require Padre::Plugin::Perl6::Syntax; | ||
| 70 | my $task = Padre::Plugin::Perl6::Syntax->new( | ||
| 71 | document => $self, | ||
| 72 | ); | ||
| 73 | $task->schedule; | ||
| 74 | |||
| 75 | =head1 DESCRIPTION | ||
| 76 | |||
| 77 | This class implements syntax checking of Perl documents in | ||
| 78 | the background. It inherits from L<Padre::Task::SyntaxChecker>. | ||
| 79 | Please read its documentation! | ||
| 80 | |||
| 81 | =head1 SEE ALSO | ||
| 82 | |||
| 83 | This class inherits from L<Padre::Task> and its instances can be scheduled | ||
| 84 | using L<Padre::TaskManager>. | ||
| 85 | |||
| 86 | The transfer of the objects to and from the worker threads is implemented | ||
| 87 | with L<Storable>. | ||
| 88 | |||
| 89 | =head1 AUTHORS | ||
| 90 | |||
| 91 | =over 4 | ||
| 92 | |||
| 93 | =item * | ||
| 94 | |||
| 95 | Ahmad M. Zawawi <ahmad.zawawi@gmail.com> | ||
| 96 | |||
| 97 | =item * | ||
| 98 | |||
| 99 | Gabor Szabo L<http://szabgab.com/> | ||
| 100 | |||
| 101 | =back | ||
| 102 | |||
| 103 | =head1 COPYRIGHT AND LICENSE | ||
| 104 | |||
| 105 | This software is copyright (c) 2010 by Ahmad M. Zawawi. | ||
| 106 | |||
| 107 | This is free software; you can redistribute it and/or modify it under | ||
| 108 | the same terms as the Perl 5 programming language system itself. | ||
| 109 | |||
| 110 | =cut | ||
| 111 | |||
| 112 | |||
| 113 | __END__ |