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