-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile.PL
132 lines (118 loc) · 3.37 KB
/
Makefile.PL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
use strict;
use warnings;
use ExtUtils::MakeMaker 6.64; # 6.64 for TEST_REQUIRES
use Getopt::Long; # Technique inspired by IO::Lambda
use IO::Socket::INET;
my $online_tests;
if($ENV{AUTHOR_TESTING}) {
$online_tests = are_online();
} else {
Getopt::Long::GetOptions('online-tests!' => \$online_tests);
if(!defined($online_tests)) {
$online_tests = are_online();
}
if(!$online_tests) {
print "On-line tests have been disabled\n";
$online_tests = 0;
}
}
my $test_requires = {
'Test::Deep' => 0,
'Test::DescribeMe' => 0,
'Test::Most' => 0,
'Test::Needs' => 0,
'Test::NoWarnings' => 0,
'Test::Number::Delta' => 0, # Always needed since used in free.t
};
if($online_tests) {
open(my $enabled, '>', 't/online.enabled') || die "Can't touch t/online.enabled $!";
close($enabled) || die "Can't touch t/online.enabled $!";
# $test_requires->{'Geo::Coder::Google::V3'} = 0.10;
$test_requires->{'Geo::Coder::OSM'} = 0;
$test_requires->{'Geo::Coder::CA'} = 0;
$test_requires->{'Geo::Coder::DataScienceToolkit'} = 0;
$test_requires->{'Geo::Coder::OpenCage'} = 0;
$test_requires->{'Geo::Coder::GeocodeFarm'} = 0;
$test_requires->{'Geo::Coder::Ovi'} = 0;
$test_requires->{'Geo::Coder::Postcodes'} = 0;
# $test_requires->{'Geo::Coder::XYZ'} = 0.06;
$test_requires->{'Test::LWP::UserAgent'} = 0;
$test_requires->{'Test::Carp'} = 0;
$test_requires->{'LWP::UserAgent::Throttled'} = 0.04;
} else {
unlink('t/online.enabled');
}
my $dist = {
COMPRESS => 'gzip -9f',
SUFFIX => 'gz'
};
if($^O eq 'darwin') {
$dist->{'TAR'} = 'gtar';
}
WriteMakefile(
NAME => 'Geo::Coder::List',
AUTHOR => q{Nigel Horne <[email protected]>},
VERSION_FROM => 'lib/Geo/Coder/List.pm',
ABSTRACT_FROM => 'lib/Geo/Coder/List.pm',
((defined($ExtUtils::MakeMaker::VERSION) &&
($ExtUtils::MakeMaker::VERSION >= 6.3002))
? ('LICENSE'=> 'GPL')
: ()),
PL_FILES => {},
TEST_REQUIRES => $test_requires,
PREREQ_PM => {
'Carp' => 0,
'HTML::Entities' => 0,
'LWP::Protocol::https' => 0,
'Scalar::Util' => 0,
'Time::HiRes' => 0
}, dist => $dist,
clean => { FILES => 'Geo::Coder::List-*' },
META_MERGE => {
'meta-spec' => { version => 2 },
resources => {
repository => {
type => 'git',
url => 'git://github.com/nigelhorne/Geo-Coder-List.git',
web => 'https://github.com/nigelhorne/Geo-Coder-List',
}, bugtracker => {
web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Geo-Coder-List',
mailto => '[email protected]'
}
},
},
MIN_PERL_VERSION => '5.10.1'
);
sub are_online
{
return 0 if($ENV{'NO_NETWORK_TESTING'} || $ENV{'CIRCLECI'} || $ENV{'TRAVIS_PERL_VERSION'} || $ENV{'AUTOMATED_TESTING'} || $ENV{'NONINTERACTIVE_TESTING'} || (!-t STDIN));
if(my $s = IO::Socket::INET->new(
PeerAddr => 'openstreetmap.org:443',
Timeout => 10
)) {
if($ENV{'PERL_MM_USE_DEFAULT'}) {
close($s);
return 0;
}
print <<EOF;
You appear to be directly connected to the Internet. I have some tests
that try to query various geocode services.
EOF
close($s);
# Timeout inspired by Mail::IMAPClient
my $rc;
eval {
local $SIG{ALRM} = sub { die 'alarm' };
alarm(60);
$rc = prompt('Do you want to enable these tests?', 'y') =~ /^y/i ? 1 : 0;
alarm(0);
};
if($@) {
print "\n";
return 1; # The default is 'y'
}
return $rc;
}
print "On-line tests disabled because I couldn't detect an Internet connexion\n";
return 0;
}