| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::Async::Ping; | 
| 2 |  |  |  |  |  |  | $Net::Async::Ping::VERSION = '0.004001'; | 
| 3 | 5 |  |  | 5 |  | 320314 | use strict; | 
|  | 5 |  |  |  |  | 60 |  | 
|  | 5 |  |  |  |  | 129 |  | 
| 4 | 5 |  |  | 5 |  | 23 | use warnings; | 
|  | 5 |  |  |  |  | 8 |  | 
|  | 5 |  |  |  |  | 125 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | # ABSTRACT: asyncronously check remote host for reachability | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 5 |  |  | 5 |  | 2321 | use Module::Runtime 'use_module'; | 
|  | 5 |  |  |  |  | 8125 |  | 
|  | 5 |  |  |  |  | 28 |  | 
| 9 | 5 |  |  | 5 |  | 2281 | use namespace::clean; | 
|  | 5 |  |  |  |  | 61417 |  | 
|  | 5 |  |  |  |  | 49 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | my %method_map = ( | 
| 12 |  |  |  |  |  |  | tcp    => 'TCP', | 
| 13 |  |  |  |  |  |  | icmp   => 'ICMP', | 
| 14 |  |  |  |  |  |  | icmpv6 => 'ICMPv6', | 
| 15 |  |  |  |  |  |  | ); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | sub new { | 
| 18 | 4 |  |  | 4 | 1 | 10868 | my $class = shift; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 4 |  | 50 |  |  | 73 | my $method = shift || 'tcp'; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | die "The '$method' proto of Net::Ping not ported yet" | 
| 23 | 4 | 50 |  |  |  | 49 | unless $method_map{$method}; | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 4 |  |  |  |  | 23 | my @args; | 
| 26 | 4 | 50 |  |  |  | 50 | if (ref $_[0]) { | 
| 27 | 4 |  |  |  |  | 17 | @args = (%{$_[0]}) | 
|  | 4 |  |  |  |  | 39 |  | 
| 28 |  |  |  |  |  |  | } else { | 
| 29 | 0 |  |  |  |  | 0 | my ($default_timeout, $bytes, $device, $tos, $ttl) = @_; | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 0 | 0 |  |  |  | 0 | @args = ( | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | (@_ >= 1 ? (default_timeout => $default_timeout) : ()), | 
| 33 |  |  |  |  |  |  | (@_ >= 2 ? (bytes => $bytes) : ()), | 
| 34 |  |  |  |  |  |  | (@_ >= 3 ? (device => $device) : ()), | 
| 35 |  |  |  |  |  |  | (@_ >= 4 ? (tos => $tos) : ()), | 
| 36 |  |  |  |  |  |  | (@_ >= 5 ? (ttl => $ttl) : ()), | 
| 37 |  |  |  |  |  |  | ) | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 4 |  |  |  |  | 113 | use_module('Net::Async::Ping::' . $method_map{$method})->new(@args) | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | 1; | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | __END__ |