File Coverage

lib/Module/Provision.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Module::Provision;
2              
3 1     1   962 use 5.010001;
  1         4  
4 1     1   5 use namespace::autoclean;
  1         2  
  1         10  
5 1     1   74 use version; our $VERSION = qv( sprintf '0.42.%d', q$Rev: 1 $ =~ /\d+/gmx );
  1         2  
  1         6  
6              
7 1     1   113 use Moo;
  1         2  
  1         9  
8              
9             extends q(Module::Provision::Base);
10             with q(Module::Provision::TraitFor::Rendering);
11             with q(Module::Provision::TraitFor::CreatingDistributions);
12             with q(Module::Provision::TraitFor::UpdatingContent);
13             with q(Module::Provision::TraitFor::PrereqDifferences);
14             with q(Module::Provision::TraitFor::CPANDistributions);
15             with q(Module::Provision::TraitFor::VCS);
16             with q(Module::Provision::TraitFor::AddingFiles);
17             with q(Module::Provision::TraitFor::Badges);
18             with q(Module::Provision::TraitFor::EnvControl);
19              
20             1;
21              
22             __END__
23              
24             =pod
25              
26             =encoding utf-8
27              
28             =begin html
29              
30             <a href="https://travis-ci.org/pjfl/p5-module-provision"><img src="https://travis-ci.org/pjfl/p5-module-provision.svg?branch=master" alt="Travis CI Badge"></a>
31             <a href="http://badge.fury.io/pl/Module-Provision"><img src="https://badge.fury.io/pl/Module-Provision.svg" alt="CPAN Badge"></a>
32             <a href="http://cpants.cpanauthors.org/dist/Module-Provision"><img src="http://cpants.cpanauthors.org/dist/Module-Provision.png" alt="Kwalitee Badge"></a>
33              
34             =end html
35              
36             =head1 Name
37              
38             Module::Provision - Create Perl distributions with VCS and selectable toolchain
39              
40             =head1 Version
41              
42             This documents version v0.42.$Rev: 1 $ of L<Module::Provision>
43              
44             =head1 Synopsis
45              
46             # To reduce typing define a shell alias
47             alias mp='module-provision --base ~/Projects'
48              
49             # Create a new distribution in your Projects directory with Git VCS
50             mp dist Foo::Bar 'Optional one line abstract'
51              
52             # Add another module
53             cd ~/Projects/Foo-Bar
54             mp module Foo::Bat 'Optional one line abstract'
55              
56             # Add a program to the bin directory
57             mp program bar-cli 'Optional one line abstract'
58              
59             # Add another test script
60             mp test 11another-one.t
61              
62             # Edit the project master file
63             mp -q edit_project
64              
65             # Regenerate meta data files
66             mp metadata
67              
68             # Update the version numbers of the project files
69             mp update_version 0.1 0.2
70              
71             # Stateful setting of the current working branch
72             mp set_branch <branch_name>
73              
74             # Command line help
75             mp -? | -H | -h [sub-command] | list_methods | dump_self
76              
77             =head1 Description
78              
79             L<Module::Provision> is used to create a skeletal CPAN distribution,
80             including basic builder scripts, tests, documentation, and module
81             code. It creates a VCS repository and, with Git as the VCS, installs
82             some hooks that mimic the RCS Revision keyword expansion
83              
84             On first use the directory F<~/.module_provision> is created and
85             populated with templates and an index file F<index.json>. The author
86             name, id, and email are derived from the system (the environment
87             variables C<AUTHOR> and C<EMAIL> take precedence). They can be
88             overridden by the values in the configuration file
89             F<~/.module_provision/module_provision.json>
90              
91             If the default builder (C<MB>) is used, then the project file
92             F<Build.PL> loads C<inc::Bob> which instantiates an inline subclass of
93             L<Module::Build>. The code for the subclass is in
94             C<inc::SubClass>. The file C<inc::CPANTesting> allows for fine grained
95             control over which tests are run by which CPAN Testing smokers
96              
97             The default builder used by the create distribution method can be
98             changed from the command line or from the configuration file
99              
100             If the Git VCS is used C<precommit> and C<commit-msg> hooks are
101             installed. The C<precommit> hook will expand the RCS Revision keyword
102             in files on the master branch if the file F<.distribution_name.rev>
103             exists in the parent of the working tree. The C<precommit> hook will
104             also update the version number and date/time stamp in the change log
105             (F<Changes>). The C<commit-msg> hook will extract the first comment
106             line from the change log and use it as the commit message header. The
107             remainder of the commit message (if any) is used as the commit message
108             body. This means that so long as one detail line is added to the
109             change log no other commit message text is required. The following
110             makes for a suitable C<git log> alias:
111              
112             alias gl='git log -5 --pretty=format:"%h %ci %s" | \
113             cut -d" " -f1-3,5- | cut -c1-79'
114              
115             The default VCS used by the create distribution methods can be
116             changed from the command line or from the configuration file
117              
118             The templates contain comment lines like:
119              
120             # @(#)Ident: Provision.pm 2013-04-15 13:52 pjf ;
121              
122             These are expanded automatically by Emacs using this Lisp code:
123              
124             (setq time-stamp-active t
125             time-stamp-line-limit 10
126             time-stamp-format " %f %04y-%02m-%02d %02H:%02M %u "
127             time-stamp-start "Ident:"
128             time-stamp-time-zone "UTC"
129             time-stamp-end ";")
130              
131             The alias:
132              
133             alias ident='ack "@\(#\)"'
134              
135             uses the L<App::Ack> program to implement the old SYSV R4 C<ident>
136             command
137              
138             The templates for the project files F<dist.ini>, F<Build.PL>, and
139             F<Makefile.PL> contain the following comments which are interpreted by
140             Emacs:
141              
142             # Local Variables:
143             # mode: perl
144             # eval: (load-project-state "[% appdir %]")
145             # tab-title: [% project %]
146             # tab-width: 3
147             # End:
148              
149             Perl mode is preferred over C-Perl mode since the former has better
150             syntax highlighting. Tabs are expanded to three spaces. The
151             C<tab-title> variable is used by L<Yakuake::Sessions> to set the tab
152             title for the terminal emulator. The C<load-project-state> Lisp looks
153             like this:
154              
155             (defun load-project-state (state-file) "Recovers the TinyDesk state from file"
156             (let ((session-path (concat "~/.emacs.d/config/state." state-file)))
157             (if (file-exists-p session-path) (tinydesk-recover-state session-path)
158             (message (concat "Not found: " state-file)))))
159              
160             It assumes that the TinyDesk state file containing the list of files to edit
161             for the project has been saved in F<~/.emacs.d/config/state.[% appdir %]>. To
162             work on a project; change directory to the working copy, edit the project
163             file F<Build.PL> with Emacs, this will load all of the other files in the
164             project into separate buffers displaying each in the tab bar. This Lisp code
165             will load TinyDesk and turn tab bar mode on whenever a Perl file is edited:
166              
167             (add-hook 'perl-mode-hook
168             '(lambda ()
169             (require 'fic-mode) (turn-on-fic-mode) (diminish 'fic-mode nil)
170             (require 'psvn) (require 'tinydesk) (tabbar-mode t)
171             (require 'tinyperl) (diminish 'tinyperl-mode nil)))
172              
173             This Lisp code will do likewise when a F<dist.ini> file is edited:
174              
175             (add-hook 'conf-windows-mode-hook
176             '(lambda ()
177             (require 'tinydesk) (tabbar-mode t)))
178              
179             =head1 Configuration and Environment
180              
181             The configuration file defaults to
182             F<~/.module_provision/module_provision.json>. All of the attributes
183             listed in L<Module::Provision::Config> can be set from the
184             configuration file in addition to the attributes listed in
185             L<Class::Usul::Config::Programs> and L<Class::Usul::Config>. A typical
186             file looks like;
187              
188             {
189             "author": "<first_name> <last_name>",
190             "author_email": "<userid>@example.com",
191             "author_id": "<userid>",
192             "base": "/home/<userid>/Projects",
193             "doc_title": "Perl",
194             "editor": "emacs",
195             "home_page": "http://www.example.com"
196             }
197              
198             Creating F<logs> and F<tmp> directories in F<~/.module_provision> will cause
199             the log and temporary files to use them instead of F</tmp>
200              
201             Extends L<Module::Provision::Base>. Applies these traits;
202             C<AddingFiles>, C<CreatingDistributions>, C<Rendering>,
203             C<UpdatingContent>, and C<VCS>
204              
205             This class defines no attributes
206              
207             =head1 Subroutines/Methods
208              
209             =head2 cpan_upload
210              
211             module-provision cpan_upload <optional_version_number>
212              
213             By default uploads the projects current distribution to CPAN
214              
215             =head2 delete_cpan_files
216              
217             module-provision delete_cpan_files v0.1.1
218              
219             Deletes a specified version of the projects distributions from CPAN
220              
221             =head2 dist
222              
223             module-provision dist Foo::Bar <'Optional one line abstract'>
224              
225             Create a new distribution specified by the module name on the command line
226              
227             =head2 dump_stash
228              
229             module-provision dump_stash
230              
231             Dump the hash ref used to render a template
232              
233             =head2 edit_project
234              
235             module-provision -q edit_project
236              
237             Edit the project file (one of; F<dist.ini>, F<Build.PL>, or
238             F<Makefile.PL>) in the project directory. The editor defaults to
239             C<emacs> but can be set on the command line, e.g C<-o editor=vim>
240              
241             =head2 metadata
242              
243             module-provision metadata
244              
245             Generates the distribution metadata files
246              
247             =head2 init_templates
248              
249             module-provision init_templates
250              
251             Initialise the F<.module_provision> directory and create the F<index.json> file
252              
253             =head2 module
254              
255             module-provision module Foo::Bat <'Optional one line abstract'>
256              
257             Creates a new module specified by the class name on the command line
258              
259             =head2 program
260              
261             module-provision program bar-cli <'Optional one line abstract'>
262              
263             Creates a new program specified by the program name on the command line
264              
265             =head2 prereq_diffs
266              
267             module-provision prereq_diffs
268              
269             Displays a report showing which pre-requisite modules should be added to,
270             removed from, or updated in the project file
271              
272             =head2 prove
273              
274             module-provision prove
275              
276             Runs the projects tests
277              
278             =head2 select_project
279              
280             cd $(module_provision -q select_project 3>&1 1>/dev/tty 2>/dev/null)
281              
282             Displays a list of available projects. Calls C<edit_project> on the selected
283             option
284              
285             =head2 set_branch
286              
287             module-provision set_branch <branch_name>
288              
289             Persistently sets the branch name used on this project. If C<branch_name> is
290             omitted defaults to the branch name appropriate for the VCS being used. Edits
291             the currently selected editor's state file for the project to reflect the
292             changing pathnames
293              
294             =head2 set_cpan_password
295              
296             module-provision set_cpan_password <your_PAUSE_server_password>
297              
298             Sets the password used to connect to the PAUSE server. Once used the
299             command line program C<cpan-upload> will not work since it cannot
300             decrypt the password in the configuration file F<~/.pause>
301              
302             =head2 show_tab_title
303              
304             module-provision -q show_tab_title
305              
306             Print the tab title for the current project. Can be used like this;
307              
308             alias ep='mp -q edit_project ; \
309             yakuake_session set_tab_title_for_project $(mp -q show_tab_title)'
310              
311             =head2 test
312              
313             module-provision test 11another-one.t
314              
315             Creates a new test specified by the test file name on the command line
316              
317             =head2 update_copyright_year
318              
319             module-provision update_copyright_year 2013 2014
320              
321             Substitutes the existing copyright year for the new copyright year in all
322             files in the F<MANIFEST>
323              
324             =head2 update_version
325              
326             module-provision update_version 0.1 0.2
327              
328             Substitutes the existing version number for the new version number in all
329             files in the F<MANIFEST>. Prompts for the major/minor and bump if the
330             version numbers are not provided
331              
332             =head2 C<select_method>
333              
334             The pod coverage test falsely triggers on this module if this entry is
335             removed. Caused by adding C<around> C<select_method> to
336             L<Module::Provision::TraitFor::Badges>
337              
338             =head1 Diagnostics
339              
340             Add C<-D> to command line to turn on debug output
341              
342             =head1 Dependencies
343              
344             =over 3
345              
346             =item L<Module::Provision::Base>
347              
348             =item L<Module::Provision::TraitFor::AddingFiles>
349              
350             =item L<Module::Provision::TraitFor::CreatingDistributions>
351              
352             =item L<Module::Provision::TraitFor::Rendering>
353              
354             =item L<Module::Provision::TraitFor::UpdatingContent>
355              
356             =item L<Module::Provision::TraitFor::VCS>
357              
358             =item L<Moo>
359              
360             =back
361              
362             =head1 Incompatibilities
363              
364             There are no known incompatibilities in this module
365              
366             =head1 Bugs and Limitations
367              
368             There are no known bugs in this module. Please report problems to
369             http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Provision. Source
370             code is on Github git://github.com/pjfl/p5-module-provision.git. Patches
371             and pull requests are welcome
372              
373             =head1 Acknowledgements
374              
375             Larry Wall - For the Perl programming language
376              
377             L<Module::Starter> - For some of the documentation and tests
378              
379             =head1 Author
380              
381             Peter Flanigan, C<< <pjfl@cpan.org> >>
382              
383             =head1 License and Copyright
384              
385             Copyright (c) 2017 Peter Flanigan. All rights reserved
386              
387             This program is free software; you can redistribute it and/or modify it
388             under the same terms as Perl itself. See L<perlartistic>
389              
390             This program is distributed in the hope that it will be useful,
391             but WITHOUT WARRANTY; without even the implied warranty of
392             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
393              
394             =cut
395              
396             # Local Variables:
397             # mode: perl
398             # tab-width: 3
399             # End: