-
Notifications
You must be signed in to change notification settings - Fork 213
/
dist_ini
46 lines (37 loc) · 1.07 KB
/
dist_ini
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
name 'dist_ini';
description 'Find depdencies and extract META info from dist.ini';
author 'Tatsuhiko Miyagawa';
api_version 0.1;
# This is a proof of concept and not really useful since most
# distributions heavily use Dist::Zilla's feature to mangle docs,
# auto-generate tests etc.
hook find_deps => sub {
my $args = shift;
if (-e "dist.ini") {
my $hash = read_ini("dist.ini") or return;
%{$args->{deps}} = (%{$args->{deps}}, %{$hash->{Prereq}});
$args->{meta}->{name} ||= $hash->{_}->{name};
# TODO version
}
};
sub read_ini {
my $file = shift;
my $hash = eval {
require Config::INI::Reader;
Config::INI::Reader->read_file($file);
};
if ($@) {
my $sec = '_';
open my $in, "<$file" or return;
while (<$in>) {
s/;.*$//;
next unless /\S/;
if (/^\[(.*?)\]\s*$/) {
$sec = $1;
} elsif ($sec) {
/^(\S+)\s*=\s*(.*)\s*$/ and $hash->{$sec}{$1} = $2;
}
}
}
return $hash;
}