File Coverage

blib/lib/App/MultiModule/Tasks/SmartMerge.pm
Criterion Covered Total %
statement 26 69 37.6
branch 0 14 0.0
condition n/a
subroutine 9 17 52.9
pod 3 3 100.0
total 38 103 36.8


line stmt bran cond sub pod time code
1             package App::MultiModule::Tasks::SmartMerge;
2              
3 2     2   974 use 5.006;
  2         10  
4 2     2   6 use strict;
  2         2  
  2         40  
5 2     2   4 use warnings FATAL => 'all';
  2         2  
  2         60  
6 2     2   6 use Data::Dumper;
  2         2  
  2         82  
7 2     2   924 use Message::SmartMerge;
  2         2566  
  2         48  
8 2     2   8 use IPC::Transit;
  2         2  
  2         32  
9 2     2   6 use Storable;
  2         2  
  2         72  
10              
11 2     2   8 use parent 'App::MultiModule::Task';
  2         2  
  2         10  
12              
13             =head1 NAME
14              
15             App::MultiModule::Tasks::SmartMerge - The great new App::MultiModule::Tasks::SmartMerge!
16              
17             =cut
18              
19             =head1 SYNOPSIS
20              
21             Quick summary of what the module does.
22              
23             Perhaps a little code snippet.
24              
25             use App::MultiModule::Tasks::SmartMerge;
26              
27             my $foo = App::MultiModule::Tasks::SmartMerge->new();
28             ...
29              
30             =head1 EXPORT
31              
32             A list of functions that can be exported. You can delete this section
33             if you don't export anything, such as for a purely object-oriented module.
34              
35             =head1 SUBROUTINES/METHODS
36              
37             =head2 message
38              
39             =cut
40             sub message {
41 0     0 1   my $self = shift;
42 0           my $message = shift;
43 0           my %args = @_;
44             $self->debug('message', message => $message)
45 0 0         if $self->{debug} > 5;
46 0 0         if($message->{add_merge}) {
47 0           eval {
48 0           $self->_add_merge($message->{add_merge});
49             };
50 0 0         if($@) {
51 0           $self->error("App::MultiModule::Tasks::SmartMerge::message: call to _add_merge() failed: $@", message => $message);
52             }
53 0           return;
54             }
55 0 0         if($message->{remove_merge}) {
56 0           eval {
57 0           $self->_remove_merge($message->{remove_merge});
58             };
59 0 0         if($@) {
60 0           $self->error("App::MultiModule::Tasks::SmartMerge::message: call to _remove_merge() failed: $@", message => $message);
61             }
62 0           return;
63             }
64 0           eval {
65 0           $self->{smartmerge}->message($message);
66             };
67 0 0         if($@) {
68 0           $self->error("App::MultiModule::Tasks::SmartMerge::message: call to message() failed: $@", message => $message);
69             }
70             }
71              
72             sub _add_merge {
73 0     0     my $self = shift;
74 0           my $merge = shift;
75 0           my %args = @_;
76 0           $self->{smartmerge}->add_merge($merge);
77             }
78              
79             sub _remove_merge {
80 0     0     my $self = shift;
81 0           my $merge_id = shift;
82 0           my %args = @_;
83 0           $self->{smartmerge}->remove_merge($merge_id);
84             }
85              
86             sub _my_emit {
87 0     0     my $self = shift;
88 0           my $message = shift;
89 0           $self->emit($message);
90             }
91              
92             =head2 set_config
93              
94             =cut
95             sub set_config {
96 0     0 1   my $self = shift;
97 0           my $config = shift;
98 0 0         if(not $self->{smartmerge}) {
99 0           $self->{smartmerge} = mine->new(state => $self->{state});
100 0           $self->{smartmerge}->config($config);
101 0           $App::MultiModule::Tasks::SmartMerge::global_object = $self;
102             }
103             $self->named_recur(
104             recur_name => 'SmartMerge_state_sync',
105             repeat_interval => 1,
106             work => sub {
107             # $self->{state} = Storable::dclone($self->{smartmerge}->get_state);
108 0     0     $self->{state} = $self->{smartmerge}->get_state;
109             },
110 0           );
111             }
112              
113             =head2 is_stateful
114              
115             =cut
116             sub is_stateful {
117 0     0 1   return 'yes';
118             }
119             =head1 AUTHOR
120              
121             Dana M. Diederich, C<< <diederich at gmail.com> >>
122              
123             =head1 BUGS
124              
125             Please report any bugs or feature requests to C<bug-app-multimodule-tasks-buckets at rt.cpan.org>, or through
126             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-MultiModule-Tasks-SmartMerge>. I will be notified, and then you'll
127             automatically be notified of progress on your bug as I make changes.
128              
129              
130              
131              
132             =head1 SUPPORT
133              
134             You can find documentation for this module with the perldoc command.
135              
136             perldoc App::MultiModule::Tasks::SmartMerge
137              
138              
139             You can also look for information at:
140              
141             =over 4
142              
143             =item * RT: CPAN's request tracker (report bugs here)
144              
145             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-MultiModule-Tasks-SmartMerge>
146              
147             =item * AnnoCPAN: Annotated CPAN documentation
148              
149             L<http://annocpan.org/dist/App-MultiModule-Tasks-SmartMerge>
150              
151             =item * CPAN Ratings
152              
153             L<http://cpanratings.perl.org/d/App-MultiModule-Tasks-SmartMerge>
154              
155             =item * Search CPAN
156              
157             L<http://search.cpan.org/dist/App-MultiModule-Tasks-SmartMerge/>
158              
159             =back
160              
161              
162             =head1 ACKNOWLEDGEMENTS
163              
164              
165             =head1 LICENSE AND COPYRIGHT
166              
167             Copyright 2013 Dana M. Diederich.
168              
169             This program is free software; you can redistribute it and/or modify it
170             under the terms of the the Artistic License (2.0). You may obtain a
171             copy of the full license at:
172              
173             L<http://www.perlfoundation.org/artistic_license_2_0>
174              
175             Any use, modification, and distribution of the Standard or Modified
176             Versions is governed by this Artistic License. By using, modifying or
177             distributing the Package, you accept this license. Do not use, modify,
178             or distribute the Package, if you do not accept this license.
179              
180             If your Modified Version has been derived from a Modified Version made
181             by someone other than you, you are nevertheless required to ensure that
182             your Modified Version complies with the requirements of this license.
183              
184             This license does not grant you the right to use any trademark, service
185             mark, tradename, or logo of the Copyright Holder.
186              
187             This license includes the non-exclusive, worldwide, free-of-charge
188             patent license to make, have made, use, offer to sell, sell, import and
189             otherwise transfer the Package with respect to any patent claims
190             licensable by the Copyright Holder that are necessarily infringed by the
191             Package. If you institute patent litigation (including a cross-claim or
192             counterclaim) against any party alleging that the Package constitutes
193             direct or contributory patent infringement, then this Artistic License
194             to you shall terminate on the date that such litigation is filed.
195              
196             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
197             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
198             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
199             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
200             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
201             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
202             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
203             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
204              
205              
206             =cut
207              
208             package mine;
209             $mine::VERSION = '1.142121';
210 2     2   2110 use base 'Message::SmartMerge';
  2         2  
  2         214  
211             sub emit {
212 0     0     my $self = shift;
213 0           my %args = @_;
214             #oh dear god...
215 0           $App::MultiModule::Tasks::SmartMerge::global_object->_my_emit($args{message});
216             }
217             1; # End of App::MultiModule::Tasks::SmartMerge