1Git::Repository::PluginU(s3e)r Contributed Perl DocumentaGtiito:n:Repository::Plugin(3)
2
3
4
6 Git::Repository::Plugin - Base class for Git::Repository plugins
7
9 package Git::Repository::Plugin::Hello;
10
11 use Git::Repository::Plugin;
12 our @ISA = qw( Git::Repository::Plugin );
13
14 sub _keywords { return qw( hello hello_gitdir ) }
15
16 sub hello { return "Hello, git world!\n"; }
17 sub hello_gitdir { return "Hello, " . $_[0]->git_dir . "!\n"; }
18
19 1;
20
22 Git::Repository::Plugin allows one to define new methods for
23 Git::Repository, that will be imported in the Git::Repository
24 namespace.
25
26 The SYNOPSIS provides a full example.
27
28 The documentation of Git::Repository describes how to load plugins with
29 all the methods they provide, or only a selection of them.
30
32 Git::Repository::Plugin provides a single method:
33
34 install
35 $plugin->install( @keywords );
36
37 Install all keywords provided in the Git::Repository namespace.
38
39 If called with an empty list, will install all available keywords.
40
42 Adding methods to Git::Repository
43 When creating a plugin, the new keywords (i.e. methods) that are added
44 by the plugin to Git::Repository must be returned by a "_keywords()"
45 method.
46
47 Adding attributes to Git::Repository
48 Git::Repository is a blessed hash reference.
49
50 If extra attributes are needed, the recommended name for the hash key
51 (to avoid name clashes between plugins) is "_plugin_name_attribute",
52 where name is the plugin lowercase name, and attribute is the attribute
53 name.
54
56 Philippe Bruhat (BooK) <book@cpan.org>
57
59 Thanks to Todd Rinaldo, who wanted to add more methods to
60 Git::Repository, which made me look for a solution that would preserve
61 the minimalism of Git::Repository.
62
63 After a not-so-good design using @ISA (so Git::Repository would inherit
64 the extra methods), further discussions with Aristotle Pagaltzis and a
65 quick peek at Dancer's plugin management helped me come up with the
66 current design. Thank you Aristotle and the Dancer team.
67
68 Further improvements to the plugin system proposed by Aristotle
69 Pagaltzis.
70
72 Copyright 2010-2016 Philippe Bruhat (BooK), all rights reserved.
73
75 This program is free software; you can redistribute it and/or modify it
76 under the same terms as Perl itself.
77
78
79
80perl v5.30.0 2019-07-26 Git::Repository::Plugin(3)