File: makeh

package info (click to toggle)
libgedcom-perl 1.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 828 kB
  • sloc: perl: 7,883; sh: 102; makefile: 10
file content (60 lines) | stat: -rw-r--r-- 1,855 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env perl

# Copyright 2001-2019, Paul Johnson (paul@pjcj.net)

# This software is free.  It is licensed under the same terms as Perl itself.

# The latest version of this software should be available from my homepage:
# http://www.pjcj.net

use strict;
use warnings;

my $Command = {
    set_version => sub {
        my ($command, $version, $date, @files) = @_;
        local ($^I, @ARGV) = ("", @files);
        while (<>) {
            s/(^\s*(?:our\s+)?\$VERSION = ")\d+\.\d+(";)/$1$version$2/;
            s/(Version )\d+\.\d+( - ).*/$1$version$2$date/;
            s/(^\s*use Gedcom(?:::\w+)*\s+)\d+\.\d+;/$1$version;/;
            print;
        }
    },
    make_readme => sub {
        my ($command) = @_;
        local @ARGV;
        while (<>) {
            print if (/NAME/        ... /^[A-Z ]+$/) =~ /^\d+$/;
            print if (/DESCRIPTION/ ... /^[A-Z ]+$/) =~ /^\d+$/;
        }
    },
    munge_readme => sub {
        my ($command) = @_;
        local @ARGV;
        while (<>) {
            next if $. < 3;
            s/^/# / if $. == 3;
            if ($. == 5) {
                my $coveralls = "https://coveralls.io";
                my $gedcom    = "github/pjcj/Gedcom.pm";
                my $travis    = "https://travis-ci.org/pjcj/Gedcom.pm";
                my $badges    = "[![Build Status]($travis.svg?branch=master)]" .
                                "($travis) " .
                                "[![Coverage Status]($coveralls/repos/" .
                                "$gedcom/badge.svg?branch=master)]" .
                                "($coveralls/$gedcom?branch=master)";
                s/.*/$badges/;
            };
            print;
        }
    },
};

sub main {
    my ($command) = @ARGV;
    die "No such command: $command" unless $Command->{$command};
    $Command->{$command}->(@ARGV)
}

main