App::GHPT::WorkSubmitter::Question::ExampleFileNameCheck - An example supplemental question for pull requests
version 1.000009
package App::GHPT::WorkSubmitter::Question::ExampleFileNameCheck; use App::GHPT::Wrapper::OurMoose; with('App::GHPT::WorkSubmitter::Role::Question'); sub ask ($self) { my @answers; # must return an array of text to insert in the pull request description for my $file ( 'should/not/be/changed', 'do/not/touch', 'abandon/hope/all/who/edit/this/file', 'badfile', ) { next unless $self->changed_files->file_exists($file); # if our class had consumed the # App::GHPT::WorkSubmitter::Role::FileInspector role we could # use $self->file_contents( $file ) to see what was in the file # staged for commit in the staging area (opposed to the what's in # the working directory which may be different) but that's slow, so # we're not doing that in this example # ask the question, provide the default answers which the user # can select from, or the last option which is "Launch Editor" # so they can give an arbitary answer push @answers, $self->ask_question( <<"ENDOFQUESTION", file $file really should not be changed unless you've got a really really really good reason. What's your reason? ENDOFQUESTION q{No good reason, but PHB told me to do this so here we are}, q{I have my reasons, but I can't tell them to you}, ); } return @answers; } __PACKAGE__->meta->make_immutable; 1;
If you create one or more modules under the App::GHPT::WorkSubmitter::Question namespace, these modules will be loaded and used to (maybe) ask additional questions as part of creating a pull request.
This is useful if you want to automate prompting for various potential issues. For example, you might look for database migrations and ask the person submitting the pull request about things like table locking, whether the existing code will work with the changed schema, etc.
To make a question work, you must follow a certain API:
Consume the App::GHPT::WorkSubmitter::Role::Question role.
Implement the ask method required by this role. This method will be called with no arguments. Internally, it is expected to call $self->ask_question( $question, @responses ). The first argument is the question to ask, like "Have you tested this migration on the staging environment to make sure it does not degrade REST API performance?". The remaining arguments are potential responses. These responses will be offered to the person running the GHPT tool.
ask
$self->ask_question( $question, @responses )
GHPT
Bugs may be submitted through https://github.com/maxmind/App-GHPT/issues.
Mark Fowler <mark@twoshortplanks.com>
Dave Rolsky <autarch@urth.org>
This software is Copyright (c) 2018 by MaxMind, Inc.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install App::GHPT, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::GHPT
CPAN shell
perl -MCPAN -e shell install App::GHPT
For more information on module installation, please visit the detailed CPAN module installation guide.