App-DocKnot

 view release on metacpan or  search on metacpan

lib/App/DocKnot/Release.pm  view on Meta::CPAN

        }
    }

    # Copy the new version into place and update the symlinks.
    my @times;
    $current_path->mkpath();
    for my $file ($tarball_ref->{files}->@*) {
        my $source = $self->{distdir}->child($file);
        my $dest = $current_path->child($file);
        $source->copy($dest);
        my ($atime, $mtime) = $source->stat()->@[8, 9];
        push(@times, $mtime);
        utime($atime, $mtime, $dest)
          or die "cannot reset timestamps of $dest: $!\n";
        my $generic_name = $file;
        $generic_name =~ s{ \A (\Q$self->{tarname}\E) - v?[\d.]+ [.] }{$1.}xms;
        my $generic_path = $current_path->child($generic_name);
        $generic_path->remove();
        symlink($file, $generic_path);
    }

lib/App/DocKnot/Spin.pm  view on Meta::CPAN

        }
    } elsif ($self->{repository} && $in_tree) {
        $modified = $self->{repository}->run(
            'log', '-1', '--format=%ct', "$source",
        );
        if ($modified) {
            $modified = strftime('%Y-%m-%d', gmtime($modified));
        }
    }
    if (!$modified) {
        $modified = strftime('%Y-%m-%d', gmtime($source->stat()->[9]));
    }
    my $now = strftime('%Y-%m-%d', gmtime());

    # Determine which template to use and substitute in the appropriate times.
    $output .= "<address>\n" . q{ } x 4;
    my $template = ($modified eq $now) ? $templates[0] : $templates[1];
    $template =~ s{ %MOD% }{$modified}xmsg;
    $template =~ s{ %NOW% }{$now}xmsg;
    $template =~ s{ %URL% }{$URL}xmsg;
    $output .= "$template\n";

lib/App/DocKnot/Spin.pm  view on Meta::CPAN

    } elsif ($input->basename() =~ m{ [.] th \z }xms) {
        my $output = $self->_output_for_file($input, '.th');
        $self->{generated}{"$output"} = 1;

        # See if we're forced to regenerate the file because it is affected by
        # a software release.
        if ($output->exists() && $self->{versions}) {
            my $relative = $input->relative($self->{source});
            my $time = $self->{versions}->latest_release($relative);
            return
              if is_newer($output, $input) && $output->stat()->[9] >= $time;
        } else {
            return if is_newer($output, $input);
        }

        # The output file is not newer.  Respin it.
        $self->_report_action('Spinning', $output);
        $self->{thread}->spin_thread_file($input, $output);
    } else {
        my ($extension) = ($input->basename =~ m{ [.] ([^.]+) \z }xms);
        if (defined($extension) && $rules{$extension}) {

lib/App/DocKnot/Spin/Pointer.pm  view on Meta::CPAN

            $navbar = join(q{}, @navbar);
        }
    }
    if ($data_ref->{style}) {
        $style = $self->{style_url} . $data_ref->{style} . '.css';
    }
    my %vars = (
        docknot_url => $URL,
        html        => decode('utf-8', $html),
        links       => $links,
        modified    => strftime('%Y-%m-%d', gmtime($source->stat()->[9])),
        navbar      => $navbar,
        now         => strftime('%Y-%m-%d', gmtime()),
        style       => $style,
        title       => $title,
    );

    # Construct the output page from those template variables.
    my $result;
    $self->{template}->process($self->{template_path}, \%vars, \$result)
      or croak($self->{template}->error());

lib/App/DocKnot/Spin/Text.pm  view on Meta::CPAN

    my ($self, $header_ref) = @_;
    my (@subheaders, $modified);

    # Generate a last modified date if we have an RCS/CVS Id string or if a
    # last modified subheader from the file modification time was requested.
    # We'll set $modified back to undef if we push it into the subheaders at
    # any point; otherwise, we'll add it at the end.
    if ($header_ref->{id}) {
        $modified = modified_id($header_ref->{id});
    } elsif ($self->{modified} && defined($self->{in_path})) {
        $modified = modified_timestamp($self->{in_path}->stat()->[9]);
    }

    # Parse subheaders.  The first must be centered; after that, assume
    # everything is a subheading until a blank line.
    my $line;
    while (defined($line = $self->_next_line())) {
        next if _is_rule($line);
        last if $line =~ m{ \A \s* \z }xms;

        # For cases other than a rule or blank line, we have to either be in a

lib/App/DocKnot/Spin/Thread.pm  view on Meta::CPAN

    # Add the end-of-page navbar if we have sitemap information.
    if ($self->{sitemap} && $self->{output}) {
        my $page = $self->{out_path}->relative($self->{output});
        $output .= join(q{}, $self->{sitemap}->navbar($page)) . "\n";
    }

    # Figure out the modification dates.  Use the Git repository if available.
    my $now = strftime('%Y-%m-%d', gmtime());
    my $modified = $now;
    if (defined($input_path)) {
        $modified = strftime('%Y-%m-%d', gmtime($input_path->stat()->[9]));
    }
    if ($self->{repository} && $self->{source}) {
        if (path($self->{source})->subsumes($input_path)) {
            my $repository = $self->{repository};
            $modified = $self->{repository}->run(
                'log', '-1', '--format=%ct', "$input_path",
            );
            if ($modified) {
                $modified = strftime('%Y-%m-%d', gmtime($modified));
            }

lib/App/DocKnot/Spin/Thread.pm  view on Meta::CPAN

# Insert the formatted size in bytes, kilobytes, or megabytes of some local
# file.  We could use Number::Format here, but what we're doing is simple
# enough and doesn't seem worth the trouble of another dependency.
sub _cmd_size {
    my ($self, $file) = @_;
    $file = $self->_file_path($self->_parse($file));

    # Get the size of the file.
    my $size;
    if ($file->exists()) {
        $size = $file->stat()->[7];
    }
    if (!defined($size)) {
        $self->_warning("cannot stat file $file: $!");
        return (0, q{});
    }

    # Format the size using SI units.
    my @suffixes = qw(Ki Mi Gi Ti);
    my $suffix = q{};
    while ($size > 1024 && @suffixes) {

lib/App/DocKnot/Util.pm  view on Meta::CPAN


# Check if a file, which may not exist, is newer than another list of files.
#
# $file   - File whose timestamp to compare
# @others - Other files to compare against
#
# Returns: True if $file exists and is newer than @others, false otherwise
sub is_newer {
    my ($file, @others) = @_;
    return if !$file->exists();
    my $file_mtime = $file->stat()->[9];
    my @others_mtimes = map { $_->stat()->[9] } @others;
    return all { $file_mtime >= $_ } @others_mtimes;
}

# Find the files for a given package with the latest version and return them
# along with some associated metadata.
#
# $path    - Path::Tiny path to directory
# $tarname - Name of the tarball before the version component
#
# Returns: Anonymous hash with the following keys:

t/release/basic.t  view on Meta::CPAN

);
my $release = App::DocKnot::Release->new(\%options);
$release->release();

# Check that the files were copied correctly and the symlinks were created.
for my $ext (@extensions) {
    my $file = 'Empty-1.9.' . $ext;
    my $file_path = $archive_path->child('devel', $file);
    ok($file_path->is_file(), "Copied $file");
    is(
        $dist_path->child($file)->stat()->[9],
        $file_path->stat()->[9],
        "Timestamp set on $file",
    );
    my $link = 'Empty.' . $ext;
    is(readlink($archive_path->child('devel', $link)), $file, "Linked $link");
}

# Build a Git repository and a .versions file.
my $spin_path = $tempdir->child('spin');
$spin_path->mkpath();
my $versions_path = $spin_path->child('.versions');



( run in 0.596 second using v1.01-cache-2.11-cpan-49f99fa48dc )