Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kentnl/git-pureperl-walker
Walk over a sequence of commits in a Git::PurePerl repo
https://github.com/kentnl/git-pureperl-walker
Last synced: 4 days ago
JSON representation
Walk over a sequence of commits in a Git::PurePerl repo
- Host: GitHub
- URL: https://github.com/kentnl/git-pureperl-walker
- Owner: kentnl
- License: other
- Created: 2012-05-29T04:22:28.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-03-09T16:14:17.000Z (over 7 years ago)
- Last Synced: 2023-08-20T23:04:27.221Z (about 1 year ago)
- Language: Perl
- Size: 297 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
Git::PurePerl::Walker - Walk over a sequence of commits in a Git::PurePerl repo
# VERSION
version 0.004002
# SYNOPSIS
use Git::PurePerl::Walker;
use Git::PurePerl::Walker::Method::FirstParent;my $repo = Git::PurePerl->new( ... );
my $walker = Git::PurePerl::Walker->new(
repo => $repo,
method => Git::PurePerl::Walker::Method::FirstParent->new(
start => $repo->ref_sha1('refs/heads/master'),
),
on_commit => sub {
my ( $commit ) = @_;
print $commit->sha1;
},
);$walker->step_all;
# CONSTRUCTOR ARGUMENTS
## repo
**Mandatory:** An instance of [`Git::PurePerl`](https://metacpan.org/pod/Git::PurePerl) representing
the repository to work with.## method
**Mandatory:** either a `Str` describing a Class Name Suffix, or an `Object`
that `does`
[`Git::PurePerl::**Walker::Role::Method**`](https://metacpan.org/pod/Git::PurePerl::Walker::Role::Method).If its a `Str`, the `Str` will be expanded as follows:
->new(
...
method => 'Foo',
...
);$className = 'Git::PurePerl::Walker::Method::Foo'
And the resulting class will be loaded, and instantiated for you. ( Assuming of
course, you don't need to pass any fancy args ).If you need fancy args, or a class outside the
`Git::PurePerl::**Walker::Method::**` namespace, constructing the object will
have to be your responsibility.->new(
...
method => Foo::Class->new(),
...
)## on\_commit
**Mandatory:** either a `Str` that can be expanded in a way similar to that by
[`_method_`](#method), a `CodeRef`, or an object that `does` [`Git::PurePerl::**Walker::Role::OnCommit**`](https://metacpan.org/pod/Git::PurePerl::Walker::Role::OnCommit).If passed a `Str` it will be expanded like so:
->new(
...
on_commit => $str,
...
);$class = 'Git::PurePerl::Walker::OnCommit::' . $str;
And the resulting class loaded and instantiated.
If passed a `CodeRef`,
[`Git::PurePerl::**Walker::OnCommit::CallBack**`](https://metacpan.org/pod/Git::PurePerl::Walker::OnCommit::CallBack) will be loaded and your `CodeRef` will be passed as an argument.->new(
...
on_commit => sub {
my ( $commit ) = @_;},
...
);If you need anything fancier, or requiring an unusual namespace, you'll want to
construct the object yourself.->new(
...
on_commit => Foo::Package->new()
...
);# METHODS
## reset
$walker->reset();
Reset the walk routine back to the state it was before you walked.
## step
Increments one step forward in the git history, and dispatches the object to the
`OnCommit` handlers.If there are more possible steps to take, it will return a true value.
while ( $walker->step ) {
/* Code to execute if walker has more items */
}This code is almost identical to:
while(1) {
$walker->on_commit->handle( $walker->method->current );last if not $walker->method->has_next;
$walker->method->next;
/* Code to execute if walker has more items */
}## step\_all
my $steps = $walker->step_all;
Mostly a convenience method to iterate until it can iterate no more, but without
you needing to wrap it in a while() block.Returns the number of steps executed.
# ATTRIBUTES
## repo
## method
## on\_commit
# ATTRIBUTE GENERATED METHODS
## repo
# Getter
my $repo = $walker->repo();## method
# Getter
my $method_object = $walker->method();## on\_commit
# Getter
my $on_commit_object = $walker->on_commit();# PRIVATE ATTRIBUTES
## \_method
## \_on\_commit
# PRIVATE METHODS
## \_build\_repo
## \_build\_method
## \_build\_on\_commit
# PRIVATE ATTRIBUTE GENERATED METHODS
## \_method
# Getter
my $methodish = $walker->_method();## \_on\_commit
# Getter
my $on_commitish => $walker->_on_commit();# AUTHOR
Kent Fredric
# COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Kent Fredric .
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.