@@ -1,12 +0,0 @@
-use strict;
-use warnings;
-use 5.008;
-
-use Module::Build;
-
-Module::Build->new(
- module_name => 'Term::Sk',
- license => 'perl',
- configure_requires => { 'Module::Build' => 0.30 },
- dist_abstract => 'Perl extension for displaying a progress indicator on a terminal',
-)->create_build_script;
@@ -1,80 +1,152 @@
Revision history for Term-Sk
-0.01 20 Jun 2009
- First version, released on an unsuspecting world.
-
-0.02 24 Nov 2009
- make option {quiet => !-t STDOUT} the default
- make option {pdisp => '!'} meaningless, i.e. always use "#" to
- display the progress bar
-
-0.03 22 Jan 2010
- add code to detect $ENV{TERM_SK_OUTPUT} to connect to, in which case {quiet =>...} is ignored
- add Build.PL
- add Sidenotes.pod
- make new() die on errors
- add "use IO::Handle" and replace "local $| = 1;" by "IO::Handle::flush();"
-
-0.04 27 Mar 2010
- add a function rem_backspace() that takes a file and removes backspaces from that file
- revert back to version 0.02 (except for "add Build.PL" and "make new() die on errors"), that is...
- - remove item from ver 0.03: "...add code to detect $ENV{TERM_SK_OUTPUT}..."
- - remove item from ver 0.03: "...add Sidenotes.pod..."
- - remove item from ver 0.03: "...add use IO::Handle and replace local $| = 1;..."
-
-0.05 11 May 2010
- in Build.PL and in Makefile.PL
- change requirement "use 5.10" to the less restrictive "use 5.8"
-
-0.06 28 May 2010
- add option {num => q{9'999}} to allow variable number formats
-
- add dynamic growth of a number, such that format: '%c of %m' outputs
- 2_870 of 9_274
-
- Also, write something reasonable in file README
-
-0.07 09 May 2011
- Introduce a new format character "%k" (="Token"). Idea and patch provided by Bruce Ravel.
- Token which updates its value before being displayed. An example use
- of this would be a loop wherein every step of the loop could be
- identified by a particular string.
-
-0.08 14 May 2011
- In the POD documentation, remove the "or die..." from "my $ctr = Term::Sk->new(...) or die..."
- Also, as suggested by Salvatore Bonaccorso, change the POD documentation as follows:
- before: This option allows to register...
- after : This option allows one to register...
- Make subs log_info(), set_chunk_size() and set_bkup_size() effectively dummy operations (i.e. they
- don't have any effect whatsoever)
-
-0.09 21 Jun 2011
- refactor/simplify subroutine rem_backspace().
- refactor/simplify time recording (subroutine show_maybe())
- in subroutine token(): replace $self->up; by $self->show_maybe;
- add some more tests
- add initialiser 'mock_tm' and method mock_time() to mock time for testing
- add configure_requires => { 'Module::Build' => 0.30 } to Build.PL
-
-0.10 16 Jul 2011
- allow more than one token in a single line
-
-0.11 19 Jul 2011
- update the documentation and give some examples to allow more than one token in a single line
-
-0.12 08 Dec 2012
- make subroutine $sk->token() to display the progress immediately (replacing
- $self->show_maybe; by $self->show; inside the subroutine token)
-
-0.13 30 Dec 2012
- Bug #82102 for Term-Sk: [PATCH] Small Spelling error in manpage (Wed, 19 Dec 2012 07:21:10 +0100)
- https://rt.cpan.org/Public/Bug/Display.html?id=82102
- >> Hi In Debian we are currently applying the attached patch to Term-Sk. We thought you might be interested
- >> in it, too. Thanks in advance, Salvatore Bonaccorso, Debian Perl Group
- >> -counter must be instantiated with an in tial value for the token.
- >> +counter must be instantiated with an initial value for the token.
-
-0.14 19 May 2013
- Add a new sub tok_maybe(), which is similar to token(), except that
- tok_maybe() calls $self->show_maybe; whereas...
- token() calls $self->show;
+0.17 - 2014-12-28T09:24:30+01:00
+
+ [DOCUMENTATION]
+
+ - Migrate to Dist::Zilla
+
+0.16 - 2014-09-07T19:42:55+01:00
+
+ [DOCUMENTATION]
+
+ - Add a .gitignore file
+
+ - Changelog dates are better written as YYYY.MM.DD and probably ordered in
+ the other, descending, direction
+ Remark: I have decided to follow the ISO 8601 standard at
+ http://www.w3.org/TR/NOTE-datetime
+
+ - Just use a Makefile.PL and not a Build.PL the latter does not have any
+ added value any more
+
+ - In Makefile.PL ==> meta files link to repository
+
+0.15 - 2014-08-17T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - Reformat changes files to comply with the format already used in Acme::Indent
+ Also, make time token (%t) align right (and not left)
+
+0.14 - 2013-05-19T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - Add a new sub tok_maybe(), which is similar to token(), except that
+ tok_maybe() calls $self->show_maybe; whereas...
+ token() calls $self->show;
+
+0.13 - 2012-12-30T12:00:00+01:00
+
+ [DOCUMENTATION]
+
+ - Bug #82102 for Term-Sk: [PATCH] Small Spelling error in manpage (Wed, 19 Dec 2012 07:21:10 +0100)
+ https://rt.cpan.org/Public/Bug/Display.html?id=82102
+ >> Hi In Debian we are currently applying the attached patch to Term-Sk. We thought you might be interested
+ >> in it, too. Thanks in advance, Salvatore Bonaccorso, Debian Perl Group
+ >> -counter must be instantiated with an in tial value for the token.
+ >> +counter must be instantiated with an initial value for the token.
+
+0.12 - 2012-12-08T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - make subroutine $sk->token() to display the progress immediately (replacing
+ $self->show_maybe; by $self->show; inside the subroutine token)
+
+0.11 - 2011-07-19T12:00:00+01:00
+
+ [DOCUMENTATION]
+
+ - update the documentation and give some examples to allow more than one token in a single line
+
+0.10 - 2011-07-16T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - allow more than one token in a single line
+
+0.09 - 2011-06-21T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - refactor/simplify subroutine rem_backspace().
+ refactor/simplify time recording (subroutine show_maybe())
+ in subroutine token(): replace $self->up; by $self->show_maybe;
+ add some more tests
+ add initialiser 'mock_tm' and method mock_time() to mock time for testing
+ add configure_requires => { 'Module::Build' => 0.30 } to Build.PL
+
+0.08 - 2011-05-14T12:00:00+01:00
+
+ [DOCUMENTATION]
+
+ - In the POD documentation, remove the "or die..." from "my $ctr = Term::Sk->new(...) or die..."
+ Also, as suggested by Salvatore Bonaccorso, change the POD documentation as follows:
+ before: This option allows to register...
+ after : This option allows one to register...
+ Make subs log_info(), set_chunk_size() and set_bkup_size() effectively dummy operations (i.e. they
+ don't have any effect whatsoever)
+
+0.07 - 2011-05-09T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - Introduce a new format character "%k" (="Token"). Idea and patch provided by Bruce Ravel.
+ Token which updates its value before being displayed. An example use
+ of this would be a loop wherein every step of the loop could be
+ identified by a particular string.
+
+0.06 - 2010-05-28T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - add option {num => q{9'999}} to allow variable number formats
+ add dynamic growth of a number, such that format: '%c of %m' outputs
+ 2_870 of 9_274
+ Also, write something reasonable in file README
+
+0.05 - 2010-05-11T12:00:00+01:00
+
+ [DOCUMENTATION]
+
+ - in Build.PL and in Makefile.PL
+ change requirement "use 5.10" to the less restrictive "use 5.8"
+
+0.04 - 2010-03-27T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - add a function rem_backspace() that takes a file and removes backspaces from that file
+
+ [REVERT]
+
+ - revert back to version 0.02 (except for "add Build.PL" and "make new() die on errors"), that is...
+ * remove item from ver 0.03: "...add code to detect $ENV{TERM_SK_OUTPUT}..."
+ * remove item from ver 0.03: "...add Sidenotes.pod..."
+ * remove item from ver 0.03: "...add use IO::Handle and replace local $| = 1;..."
+
+0.03 - 2010-01-22T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - add code to detect $ENV{TERM_SK_OUTPUT} to connect to, in which case {quiet =>...} is ignored
+ add Build.PL
+ add Sidenotes.pod
+ make new() die on errors
+ add "use IO::Handle" and replace "local $| = 1;" by "IO::Handle::flush();"
+
+0.02 - 2009-11-24T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - make option {quiet => !-t STDOUT} the default
+ make option {pdisp => '!'} meaningless, i.e. always use "#" to
+ display the progress bar
+
+0.01 - 2009-06-20T12:00:00+01:00
+
+ [ENHANCEMENTS]
+
+ - First version, released on an unsuspecting world.
@@ -0,0 +1,379 @@
+This software is copyright (c) 2014 by Klaus Eichner.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+Terms of the Perl programming language system itself
+
+a) the GNU General Public License as published by the Free
+ Software Foundation; either version 1, or (at your option) any
+ later version, or
+b) the "Artistic License"
+
+--- The GNU General Public License, Version 1, February 1989 ---
+
+This software is Copyright (c) 2014 by Klaus Eichner.
+
+This is free software, licensed under:
+
+ The GNU General Public License, Version 1, February 1989
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 1, February 1989
+
+ Copyright (C) 1989 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The license agreements of most software companies try to keep users
+at the mercy of those companies. By contrast, our General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. The
+General Public License applies to the Free Software Foundation's
+software and to any other program whose authors commit to using it.
+You can use it for your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Specifically, the General Public License is designed to make
+sure that you have the freedom to give away or sell copies of free
+software, that you receive source code or can get it if you want it,
+that you can change the software or use pieces of it in new free
+programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of a such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must tell them their rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any program or other work which
+contains a notice placed by the copyright holder saying it may be
+distributed under the terms of this General Public License. The
+"Program", below, refers to any such program or work, and a "work based
+on the Program" means either the Program or any work containing the
+Program or a portion of it, either verbatim or with modifications. Each
+licensee is addressed as "you".
+
+ 1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this
+General Public License and to the absence of any warranty; and give any
+other recipients of the Program a copy of this General Public License
+along with the Program. You may charge a fee for the physical act of
+transferring a copy.
+
+ 2. You may modify your copy or copies of the Program or any portion of
+it, and copy and distribute such modifications under the terms of Paragraph
+1 above, provided that you also do the following:
+
+ a) cause the modified files to carry prominent notices stating that
+ you changed the files and the date of any change; and
+
+ b) cause the whole of any work that you distribute or publish, that
+ in whole or in part contains the Program or any part thereof, either
+ with or without modifications, to be licensed at no charge to all
+ third parties under the terms of this General Public License (except
+ that you may choose to grant warranty protection to some or all
+ third parties, at your option).
+
+ c) If the modified program normally reads commands interactively when
+ run, you must cause it, when started running for such interactive use
+ in the simplest and most usual way, to print or display an
+ announcement including an appropriate copyright notice and a notice
+ that there is no warranty (or else, saying that you provide a
+ warranty) and that users may redistribute the program under these
+ conditions, and telling the user how to view a copy of this General
+ Public License.
+
+ d) You may charge a fee for the physical act of transferring a
+ copy, and you may at your option offer warranty protection in
+ exchange for a fee.
+
+Mere aggregation of another independent work with the Program (or its
+derivative) on a volume of a storage or distribution medium does not bring
+the other work under the scope of these terms.
+
+ 3. You may copy and distribute the Program (or a portion or derivative of
+it, under Paragraph 2) in object code or executable form under the terms of
+Paragraphs 1 and 2 above provided that you also do one of the following:
+
+ a) accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of
+ Paragraphs 1 and 2 above; or,
+
+ b) accompany it with a written offer, valid for at least three
+ years, to give any third party free (except for a nominal charge
+ for the cost of distribution) a complete machine-readable copy of the
+ corresponding source code, to be distributed under the terms of
+ Paragraphs 1 and 2 above; or,
+
+ c) accompany it with the information you received as to where the
+ corresponding source code may be obtained. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form alone.)
+
+Source code for a work means the preferred form of the work for making
+modifications to it. For an executable file, complete source code means
+all the source code for all modules it contains; but, as a special
+exception, it need not include source code for modules which are standard
+libraries that accompany the operating system on which the executable
+file runs, or for standard header files or definitions files that
+accompany that operating system.
+
+ 4. You may not copy, modify, sublicense, distribute or transfer the
+Program except as expressly provided under this General Public License.
+Any attempt otherwise to copy, modify, sublicense, distribute or transfer
+the Program is void, and will automatically terminate your rights to use
+the Program under this License. However, parties who have received
+copies, or rights to use copies, from you under this General Public
+License will not have their licenses terminated so long as such parties
+remain in full compliance.
+
+ 5. By copying, distributing or modifying the Program (or any work based
+on the Program) you indicate your acceptance of this license to do so,
+and all its terms and conditions.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these
+terms and conditions. You may not impose any further restrictions on the
+recipients' exercise of the rights granted herein.
+
+ 7. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of the license which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+the license, you may choose any version ever published by the Free Software
+Foundation.
+
+ 8. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to humanity, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+ To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively convey
+the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19xx name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the
+appropriate parts of the General Public License. Of course, the
+commands you use may be called something other than `show w' and `show
+c'; they could even be mouse-clicks or menu items--whatever suits your
+program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ program `Gnomovision' (a program to direct compilers to make passes
+ at assemblers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
+--- The Artistic License 1.0 ---
+
+This software is Copyright (c) 2014 by Klaus Eichner.
+
+This is free software, licensed under:
+
+ The Artistic License 1.0
+
+The Artistic License
+
+Preamble
+
+The intent of this document is to state the conditions under which a Package
+may be copied, such that the Copyright Holder maintains some semblance of
+artistic control over the development of the package, while giving the users of
+the package the right to use and distribute the Package in a more-or-less
+customary fashion, plus the right to make reasonable modifications.
+
+Definitions:
+
+ - "Package" refers to the collection of files distributed by the Copyright
+ Holder, and derivatives of that collection of files created through
+ textual modification.
+ - "Standard Version" refers to such a Package if it has not been modified,
+ or has been modified in accordance with the wishes of the Copyright
+ Holder.
+ - "Copyright Holder" is whoever is named in the copyright or copyrights for
+ the package.
+ - "You" is you, if you're thinking about copying or distributing this Package.
+ - "Reasonable copying fee" is whatever you can justify on the basis of media
+ cost, duplication charges, time of people involved, and so on. (You will
+ not be required to justify it to the Copyright Holder, but only to the
+ computing community at large as a market that must bear the fee.)
+ - "Freely Available" means that no fee is charged for the item itself, though
+ there may be fees involved in handling the item. It also means that
+ recipients of the item may redistribute it under the same conditions they
+ received it.
+
+1. You may make and give away verbatim copies of the source form of the
+Standard Version of this Package without restriction, provided that you
+duplicate all of the original copyright notices and associated disclaimers.
+
+2. You may apply bug fixes, portability fixes and other modifications derived
+from the Public Domain or from the Copyright Holder. A Package modified in such
+a way shall still be considered the Standard Version.
+
+3. You may otherwise modify your copy of this Package in any way, provided that
+you insert a prominent notice in each changed file stating how and when you
+changed that file, and provided that you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise make them
+ Freely Available, such as by posting said modifications to Usenet or an
+ equivalent medium, or placing the modifications on a major archive site
+ such as ftp.uu.net, or by allowing the Copyright Holder to include your
+ modifications in the Standard Version of the Package.
+
+ b) use the modified Package only within your corporation or organization.
+
+ c) rename any non-standard executables so the names do not conflict with
+ standard executables, which must also be provided, and provide a separate
+ manual page for each non-standard executable that clearly documents how it
+ differs from the Standard Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+4. You may distribute the programs of this Package in object code or executable
+form, provided that you do at least ONE of the following:
+
+ a) distribute a Standard Version of the executables and library files,
+ together with instructions (in the manual page or equivalent) on where to
+ get the Standard Version.
+
+ b) accompany the distribution with the machine-readable source of the Package
+ with your modifications.
+
+ c) accompany any non-standard executables with their corresponding Standard
+ Version executables, giving the non-standard executables non-standard
+ names, and clearly documenting the differences in manual pages (or
+ equivalent), together with instructions on where to get the Standard
+ Version.
+
+ d) make other distribution arrangements with the Copyright Holder.
+
+5. You may charge a reasonable copying fee for any distribution of this
+Package. You may charge any fee you choose for support of this Package. You
+may not charge a fee for this Package itself. However, you may distribute this
+Package in aggregate with other (possibly commercial) programs as part of a
+larger (possibly commercial) software distribution provided that you do not
+advertise this Package as a product of your own.
+
+6. The scripts and library files supplied as input to or produced as output
+from the programs of this Package do not automatically fall under the copyright
+of this Package, but belong to whomever generated them, and may be sold
+commercially, and may be aggregated with this Package.
+
+7. C or perl subroutines supplied by you and linked into this Package shall not
+be considered part of this Package.
+
+8. The name of the Copyright Holder may not be used to endorse or promote
+products derived from this software without specific prior written permission.
+
+9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+The End
+
@@ -1,9 +1,11 @@
-Changes
-MANIFEST
-Makefile.PL
-Build.PL
-README
-lib/Term/Sk.pm
-t/0010_test.t
-META.yml
-META.json
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.025.
+Changes
+LICENSE
+MANIFEST
+META.yml
+Makefile.PL
+README
+dist.ini
+lib/Term/Sk.pm
+t/0010_test.t
+t/release-pod-syntax.t
@@ -1,36 +0,0 @@
-{
- "abstract" : "Perl extension for displaying a progress indicator on a terminal",
- "author" : [
- "unknown"
- ],
- "dynamic_config" : 1,
- "generated_by" : "Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921",
- "license" : [
- "perl_5"
- ],
- "meta-spec" : {
- "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
- "version" : "2"
- },
- "name" : "Term-Sk",
- "prereqs" : {
- "configure" : {
- "requires" : {
- "Module::Build" : "0.3"
- }
- }
- },
- "provides" : {
- "Term::Sk" : {
- "file" : "lib/Term/Sk.pm",
- "version" : "0.14"
- }
- },
- "release_status" : "stable",
- "resources" : {
- "license" : [
- "http://dev.perl.org/licenses/"
- ]
- },
- "version" : "0.14"
-}
@@ -1,21 +1,25 @@
----
-abstract: 'Perl extension for displaying a progress indicator on a terminal'
-author:
- - unknown
-build_requires: {}
-configure_requires:
- Module::Build: 0.3
-dynamic_config: 1
-generated_by: 'Module::Build version 0.4003, CPAN::Meta::Converter version 2.120921'
-license: perl
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
-name: Term-Sk
-provides:
- Term::Sk:
- file: lib/Term/Sk.pm
- version: 0.14
-resources:
- license: http://dev.perl.org/licenses/
-version: 0.14
+---
+abstract: 'Perl extension for displaying a progress indicator on a terminal. '
+author:
+ - 'Klaus Eichner <klaus03@gmail.com>'
+build_requires:
+ Test::More: '0'
+configure_requires:
+ ExtUtils::MakeMaker: '0'
+dynamic_config: 0
+generated_by: 'Dist::Zilla version 5.025, CPAN::Meta::Converter version 2.142060'
+license: perl
+meta-spec:
+ url: http://module-build.sourceforge.net/META-spec-v1.4.html
+ version: '1.4'
+name: Term-Sk
+requires:
+ Exporter: '0'
+ Fcntl: '0'
+ Time::HiRes: '0'
+ strict: '0'
+ warnings: '0'
+resources:
+ homepage: https://github.com/klaus03/Term-Sk
+ repository: https://github.com/klaus03/Term-Sk.git
+version: '0.17'
@@ -1,12 +1,62 @@
-use 5.008;
-use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-WriteMakefile(
- NAME => 'Term::Sk',
- VERSION_FROM => 'lib/Term/Sk.pm', # finds $VERSION
- PREREQ_PM => {}, # e.g., Module::Name => 1.1
- ($] >= 5.005 ? ## Add these new keywords supported since 5.005
- (ABSTRACT_FROM => 'lib/Term/Sk.pm', # retrieve abstract from module
- AUTHOR => 'Klaus Eichner <klaus03@gmail.com>') : ()),
-);
+
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.025.
+use strict;
+use warnings;
+
+
+
+use ExtUtils::MakeMaker;
+
+
+
+my %WriteMakefileArgs = (
+ "ABSTRACT" => "Perl extension for displaying a progress indicator on a terminal. ",
+ "AUTHOR" => "Klaus Eichner <klaus03\@gmail.com>",
+ "CONFIGURE_REQUIRES" => {
+ "ExtUtils::MakeMaker" => 0
+ },
+ "DISTNAME" => "Term-Sk",
+ "EXE_FILES" => [],
+ "LICENSE" => "perl",
+ "NAME" => "Term::Sk",
+ "PREREQ_PM" => {
+ "Exporter" => 0,
+ "Fcntl" => 0,
+ "Time::HiRes" => 0,
+ "strict" => 0,
+ "warnings" => 0
+ },
+ "TEST_REQUIRES" => {
+ "Test::More" => 0
+ },
+ "VERSION" => "0.17",
+ "test" => {
+ "TESTS" => "t/*.t"
+ }
+);
+
+
+my %FallbackPrereqs = (
+ "Exporter" => 0,
+ "ExtUtils::MakeMaker" => 0,
+ "Fcntl" => 0,
+ "Test::More" => 0,
+ "Time::HiRes" => 0,
+ "strict" => 0,
+ "warnings" => 0
+);
+
+
+unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
+ delete $WriteMakefileArgs{TEST_REQUIRES};
+ delete $WriteMakefileArgs{BUILD_REQUIRES};
+ $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
+}
+
+delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
+ unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
+
+WriteMakefile(%WriteMakefileArgs);
+
+
+
@@ -1,97 +1,15 @@
-Term-Sk Version 0.14
-
-This is a Perl extension for displaying a progress indicator on a terminal.
-
-SYNOPSIS
-
- use Term::Sk;
-
- my $ctr = Term::Sk->new('%d Elapsed: %8t %21b %4p %2d (%8c of %11m)',
- {quiet => 0, freq => 10, base => 0, target => 100, pdisp => '!'})
- or die "Error 0010: Term::Sk->new, ".
- "(code $Term::Sk::errcode) ".
- "$Term::Sk::errmsg";
-
- $ctr->up for (1..100);
-
- $ctr->down for (1..100);
-
- $ctr->whisper('abc');
-
- my last_line = $ctr->get_line;
-
- $ctr->close;
-
- print "Number of ticks: ", $ctr->ticks, "\n";
-
-EXAMPLES
-
-Term::Sk is a class to implement a progress indicator ("Sk" is a short form for "Show Key"). This is used to provide immediate feedback for
-long running processes.
-
-A sample code fragment that uses Term::Sk:
-
- use Term::Sk;
-
- print qq{This is a test of "Term::Sk"\n\n};
-
- my $target = 2_845;
- my $format = '%2d Elapsed: %8t %21b %4p %2d (%8c of %11m)';
-
- my $ctr = Term::Sk->new($format,
- {freq => 10, base => 0, target => $target, pdisp => '!'})
- or die "Error 0010: Term::Sk->new, ".
- "(code $Term::Sk::errcode) ".
- "$Term::Sk::errmsg";
-
- for (1..$target) {
- $ctr->up;
- do_something();
- }
-
- $ctr->close;
-
- sub do_something {
- my $test = 0;
- for my $i (0..10_000) {
- $test += sin($i) * cos($i);
- }
- }
-
-INSTALLATION
-
-To install this module, run the following commands:
-
- perl Build.PL
- perl Build
- perl Build test
- perl Build install
-
-SUPPORT AND DOCUMENTATION
-
-After installing, you can find documentation for this module with the
-perldoc command.
-
- perldoc Term::Sk
-
-You can also look for information at:
-
- RT, CPAN's request tracker
- http://rt.cpan.org/NoAuth/Bugs.html?Dist=Term-Sk
-
- AnnoCPAN, Annotated CPAN documentation
- http://annocpan.org/dist/Term-Sk
-
- CPAN Ratings
- http://cpanratings.perl.org/d/Term-Sk
-
- Search CPAN
- http://search.cpan.org/dist/Term-Sk/
-
-
-COPYRIGHT AND LICENCE
-
-Copyright (C) 2008 Klaus Eichner
-
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
+
+
+This archive contains the distribution Term-Sk,
+version 0.17:
+
+ Perl extension for displaying a progress indicator on a terminal.
+
+This software is copyright (c) 2014 by Klaus Eichner.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+
+This README file was generated by Dist::Zilla::Plugin::Readme v5.025.
+
@@ -0,0 +1,35 @@
+name = Term-Sk
+version = 0.17
+author = Klaus Eichner <klaus03@gmail.com>
+license = Perl_5
+copyright_holder = Klaus Eichner
+
+[Git::Check]
+allow_dirty=
+
+[Git::Tag]
+[GithubMeta]
+
+[GatherDir]
+[PruneCruft]
+[ManifestSkip]
+[MetaYAML]
+[License]
+[Readme]
+[ExtraTests]
+[ExecDir]
+[ShareDir]
+[PkgVersion]
+die_on_existing_version=1
+die_on_line_insertion=1
+
+[MakeMaker]
+[Manifest]
+
+[TestRelease]
+
+[Run::Release]
+
+[PodSyntaxTests]
+
+[AutoPrereqs]
@@ -1,672 +1,670 @@
-package Term::Sk;
-
-use strict;
-use warnings;
-
-use Time::HiRes qw( time );
-use Fcntl qw(:seek);
-
-require Exporter;
-
-our @ISA = qw(Exporter);
-
-our %EXPORT_TAGS = ( 'all' => [ qw(set_chunk_size set_bkup_size rem_backspace) ] );
-
-our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-
-our @EXPORT = qw();
-
-our $VERSION = '0.14';
-
-our $errcode = 0;
-our $errmsg = '';
-
-sub new {
- shift;
- my $self = {};
- bless $self;
-
- $errcode = 0;
- $errmsg = '';
-
- my %hash = (freq => 1, base => 0, target => 1_000, quiet => 0, test => 0, num => q{9_999});
- %hash = (%hash, %{$_[1]}) if defined $_[1];
-
- my $format = defined $_[0] ? $_[0] : '%8c';
-
- $self->{base} = $hash{base};
- $self->{target} = $hash{target};
- $self->{quiet} = $hash{quiet};
- $self->{test} = $hash{test};
- $self->{format} = $format;
- $self->{freq} = $hash{freq};
- $self->{value} = $hash{base};
- $self->{mock_tm} = $hash{mock_tm};
- $self->{oldtext} = '';
- $self->{line} = '';
- $self->{pdisp} = '#';
- $self->{commify} = $hash{commify};
- $self->{token} = defined($hash{token}) ? ref($hash{token}) eq 'ARRAY' ? $hash{token} : [$hash{token}] : [];
-
- unless (defined $self->{quiet}) {
- $self->{quiet} = !-t STDOUT;
- }
-
- if ($hash{num} eq '9') {
- $self->{sep} = '';
- $self->{group} = 0;
- }
- else {
- my ($sep, $group) = $hash{num} =~ m{\A 9 ([^\d\+\-]) (9+) \z}xms or do {
- $errcode = 95;
- $errmsg = qq{Can't parse num => '$hash{num}'};
- die sprintf('Error-%04d: %s', $errcode, $errmsg);
- };
- $self->{sep} = $sep;
- $self->{group} = length($group);
- }
-
- # Here we de-compose the format into $self->{action}
-
- $self->{action} = [];
-
- my $fmt = $format;
- while ($fmt ne '') {
- if ($fmt =~ m{^ ([^%]*) % (.*) $}xms) {
- my ($literal, $portion) = ($1, $2);
- unless ($portion =~ m{^ (\d*) ([a-zA-Z]) (.*) $}xms) {
- $errcode = 100;
- $errmsg = qq{Can't parse '%[<number>]<alpha>' from '%$portion', total line is '$format'};
- die sprintf('Error-%04d: %s', $errcode, $errmsg);
- }
-
- my ($repeat, $disp_code, $remainder) = ($1, $2, $3);
-
- if ($repeat eq '') { $repeat = 1; }
- if ($repeat < 1) { $repeat = 1; }
-
- unless ($disp_code eq 'b'
- or $disp_code eq 'c'
- or $disp_code eq 'd'
- or $disp_code eq 'm'
- or $disp_code eq 'p'
- or $disp_code eq 'P'
- or $disp_code eq 't'
- or $disp_code eq 'k') {
- $errcode = 110;
- $errmsg = qq{Found invalid display-code ('$disp_code'), expected ('b', 'c', 'd', 'm', 'p', 'P' 't' or 'k') in '%$portion', total line is '$format'};
- die sprintf('Error-%04d: %s', $errcode, $errmsg);
- }
-
- push @{$self->{action}}, {type => '*lit', len => length($literal), lit => $literal} if length($literal) > 0;
- push @{$self->{action}}, {type => $disp_code, len => $repeat};
- $fmt = $remainder;
- }
- else {
- push @{$self->{action}}, {type => '*lit', len => length($fmt), lit => $fmt};
- $fmt = '';
- }
- }
-
- # End of format de-composition
-
- $self->{tick} = 0;
- $self->{out} = 0;
- $self->{sec_begin} = $self->{mock_tm} ? $self->{mock_tm} : time;
- $self->{sec_print} = 0;
-
- $self->show;
-
- return $self;
-}
-
-sub mock_time {
- my $self = shift;
-
- $self->{mock_tm} = $_[0];
-}
-
-sub whisper {
- my $self = shift;
-
- my $back = qq{\010} x length $self->{oldtext};
- my $blank = q{ } x length $self->{oldtext};
-
- $self->{line} = join('', $back, $blank, $back, @_, $self->{oldtext});
-
- unless ($self->{test}) {
- local $| = 1;
- if ($self->{quiet}) {
- print @_;
- }
- else {
- print $self->{line};
- }
- }
-}
-
-sub get_line {
- my $self = shift;
-
- return $self->{line};
-}
-
-sub up { my $self = shift; $self->{value} += defined $_[0] ? $_[0] : 1; $self->show_maybe; }
-sub down { my $self = shift; $self->{value} -= defined $_[0] ? $_[0] : 1; $self->show_maybe; }
-sub close { my $self = shift; $self->{value} = undef; $self->show; }
-
-sub ticks { my $self = shift; return $self->{tick} }
-
-sub token {
- my $self = shift;
- my $tk = shift;
- $self->{token} = ref($tk) eq 'ARRAY' ? $tk : [$tk];
- $self->show;
-}
-
-sub tok_maybe {
- my $self = shift;
- my $tk = shift;
- $self->{token} = ref($tk) eq 'ARRAY' ? $tk : [$tk];
- $self->show_maybe;
-}
-
-sub DESTROY {
- my $self = shift;
- $self->close;
-}
-
-sub show_maybe {
- my $self = shift;
-
- $self->{line} = '';
-
- my $sec_now = ($self->{mock_tm} ? $self->{mock_tm} : time) - $self->{sec_begin};
- my $sec_prev = $self->{sec_print};
-
- $self->{sec_print} = $sec_now;
- $self->{tick}++;
-
- if ($self->{freq} eq 's') {
- if (int($sec_prev) != int($sec_now)) {
- $self->show;
- }
- }
- elsif ($self->{freq} eq 'd') {
- if (int($sec_prev * 10) != int($sec_now * 10)) {
- $self->show;
- }
- }
- else {
- unless ($self->{tick} % $self->{freq}) {
- $self->show;
- }
- }
-}
-
-sub show {
- my $self = shift;
- $self->{out}++;
-
- my $back = qq{\010} x length $self->{oldtext};
- my $blank = q{ } x length $self->{oldtext};
-
- my $text = '';
- if (defined $self->{value}) {
-
- # Here we compose a string based on $self->{action} (which, of course, is the previously de-composed format)
-
- my $tok_ind = 0;
-
- for my $act (@{$self->{action}}) {
- my ($type, $lit, $len) = ($act->{type}, $act->{lit}, $act->{len});
-
- if ($type eq '*lit') { # print (= append to $text) a simple literal
- $text .= $lit;
- next;
- }
- if ($type eq 't') { # print (= append to $text) time elapsed in format 'hh:mm:ss'
- my $unit = int($self->{sec_print});
- my $hour = int($unit / 3600);
- my $min = int(($unit % 3600) / 60);
- my $sec = $unit % 60;
- my $stamp = sprintf '%02d:%02d:%02d', $hour, $min, $sec;
- $text .= sprintf "%${len}.${len}s", $stamp;
- next;
- }
- if ($type eq 'd') { # print (= append to $text) a revolving dash in format '/-\|'
- $text .= substr('/-\|', $self->{out} % 4, 1) x $len;
- next;
- }
- if ($type eq 'b') { # print (= append to $text) progress indicator format '#####_____'
- my $progress = $self->{target} == $self->{base} ? 0 :
- int ($len * ($self->{value} - $self->{base}) / ($self->{target} - $self->{base}) + 0.5);
- if ($progress < 0) { $progress = 0 }
- elsif ($progress > $len) { $progress = $len }
- $text .= $self->{pdisp} x $progress.'_' x ($len - $progress);
- next;
- }
- if ($type eq 'p') { # print (= append to $text) progress in percentage format '999%'
- my $percent = $self->{target} == $self->{base} ? 0 :
- 100 * ($self->{value} - $self->{base}) / ($self->{target} - $self->{base});
- $text .= sprintf "%${len}.${len}s", sprintf("%.0f%%", $percent);
- next;
- }
- if ($type eq 'P') { # print (= append to $text) literally '%' characters
- $text .= '%' x $len;
- next;
- }
- if ($type eq 'c') { # print (= append to $text) actual counter value (commified)
- $text .= sprintf "%${len}s", commify($self->{commify}, $self->{value}, $self->{sep}, $self->{group});
- next;
- }
- if ($type eq 'm') { # print (= append to $text) target (commified)
- $text .= sprintf "%${len}s", commify($self->{commify}, $self->{target}, $self->{sep}, $self->{group});
- next;
- }
- if ($type eq 'k') { # print (= append to $text) token
- $text .= sprintf "%-${len}s", $self->{token}[$tok_ind];
- $tok_ind++;
- next;
- }
- # default: do nothing, in the (impossible) event that $type is none of '*lit', 't', 'b', 'p', 'P', 'c', 'm' or 'k'
- }
-
- # End of string composition
- }
-
- $self->{line} = join('', $back, $blank, $back, $text);
-
- unless ($self->{test} or $self->{quiet}) {
- local $| = 1;
- print $self->{line};
- }
-
- $self->{oldtext} = $text;
-}
-
-sub commify {
- my $com = shift;
- if ($com) { return $com->($_[0]); }
-
- local $_ = shift;
- my ($sep, $group) = @_;
-
- if ($group > 0) {
- my $len = length($_);
- for my $i (1..$len) {
- last unless s/^([-+]?\d+)(\d{$group})/$1$sep$2/;
- }
- }
- return $_;
-}
-
-my $chunk_size = 10000;
-my $bkup_size = 80;
-
-# Decision by Klaus Eichner, 31-MAY-2011:
-# ---------------------------------------
-# Make subs log_info(), set_chunk_size() and set_bkup_size() effectively dummy operations (i.e. they
-# don't have any effect whatsoever)
-
-sub log_info { }
-sub set_chunk_size { }
-sub set_bkup_size { }
-
-sub rem_backspace {
- my ($fname) = @_;
-
- open my $ifh, '<', $fname or die "Error-0200: Can't open < '$fname' because $!";
- open my $tfh, '+>', undef or die "Error-0210: Can't open +> undef (tempfile) because $!";
-
- my $out_buf = '';
-
- while (read($ifh, my $inp_buf, $chunk_size)) {
- $out_buf .= $inp_buf;
-
- # here we are removing the backspaces:
- while ($out_buf =~ m{\010+}xms) {
- my $pos_left = $-[0] * 2 - $+[0];
- if ($pos_left < 0) {
- $pos_left = 0;
- }
- $out_buf = substr($out_buf, 0, $pos_left).substr($out_buf, $+[0]);
- }
-
- if (length($out_buf) > $bkup_size) {
- print {$tfh} substr($out_buf, 0, -$bkup_size);
- $out_buf = substr($out_buf, -$bkup_size);
- }
- }
-
- CORE::close $ifh; # We need to employ CORE::close because there is already another close subroutine defined in the current namespace "Term::Sk"
-
- print {$tfh} $out_buf;
-
- # Now copy back temp-file to original file:
-
- seek $tfh, 0, SEEK_SET or die "Error-0220: Can't seek tempfile to 0 because $!";
- open my $ofh, '>', $fname or die "Error-0230: Can't open > '$fname' because $!";
-
- while (read($tfh, my $buf, $chunk_size)) { print {$ofh} $buf; }
-
- CORE::close $ofh;
- CORE::close $tfh;
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Term::Sk - Perl extension for displaying a progress indicator on a terminal.
-
-=head1 SYNOPSIS
-
- use Term::Sk;
-
- my $ctr = Term::Sk->new('%d Elapsed: %8t %21b %4p %2d (%8c of %11m)',
- {quiet => 0, freq => 10, base => 0, target => 100, pdisp => '!'});
-
- $ctr->up for (1..100);
-
- $ctr->down for (1..100);
-
- $ctr->whisper('abc');
-
- my last_line = $ctr->get_line;
-
- $ctr->close;
-
- print "Number of ticks: ", $ctr->ticks, "\n";
-
-=head1 EXAMPLES
-
-Term::Sk is a class to implement a progress indicator ("Sk" is a short form for "Show Key"). This is used to provide immediate feedback for
-long running processes.
-
-A sample code fragment that uses Term::Sk:
-
- use Term::Sk;
-
- print qq{This is a test of "Term::Sk"\n\n};
-
- my $target = 2_845;
- my $format = '%2d Elapsed: %8t %21b %4p %2d (%8c of %11m)';
-
- my $ctr = Term::Sk->new($format,
- {freq => 10, base => 0, target => $target, pdisp => '!'});
-
- for (1..$target) {
- $ctr->up;
- do_something();
- }
-
- $ctr->close;
-
- sub do_something {
- my $test = 0;
- for my $i (0..10_000) {
- $test += sin($i) * cos($i);
- }
- }
-
-Another example that counts upwards:
-
- use Term::Sk;
-
- my $format = '%21b %4p';
-
- my $ctr = Term::Sk->new($format, {freq => 's', base => 0, target => 70});
-
- for (1..10) {
- $ctr->up(7);
- sleep 1;
- }
-
- $ctr->close;
-
-At any time, after Term::Sk->new(), you can query the number of ticks (i.e. number of calls to
-$ctr->up or $ctr->down) using the method 'ticks':
-
- use Term::Sk;
-
- my $ctr = Term::Sk->new('%6c', {freq => 's', base => 0, target => 70});
-
- for (1..4288) {
- $ctr->up;
- }
-
- $ctr->close;
-
- print "Number of ticks: ", $ctr->ticks, "\n";
-
-This example uses a simple progress bar in quiet mode (nothing is printed to STDOUT), but
-instead, the content of what would have been printed can now be extracted using the get_line() method:
-
- use Term::Sk;
-
- my $format = 'Ctr %4c';
-
- my $ctr = Term::Sk->new($format, {freq => 2, base => 0, target => 10, quiet => 1});
-
- my $line = $ctr->get_line;
- $line =~ s/\010/</g;
- print "This is what would have been printed upon new(): [$line]\n";
-
- for my $i (1..10) {
- $ctr->up;
-
- $line = $ctr->get_line;
- $line =~ s/\010/</g;
- print "This is what would have been printed upon $i. call to up(): [$line]\n";
- }
-
- $ctr->close;
-
- $line = $ctr->get_line;
- $line =~ s/\010/</g;
- print "This is what would have been printed upon close(): [$line]\n";
-
-Here are some examples that show different values for option {num => ...}
-
- my $format = 'act %c max %m';
-
- my $ctr1 = Term::Sk->new($format, {base => 1234567, target => 2345678});
- # The following numbers are shown: act 1_234_567 max 2_345_678
-
- my $ctr2 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9,999}});
- # The following numbers are shown: act 1,234,567 max 2,345,678
-
- my $ctr3 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9'99}});
- # The following numbers are shown: act 1'23'45'67 max 2'34'56'78
-
- my $ctr4 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9}});
- # The following numbers are shown: act 1234567 max 2345678
-
- my $ctr5 = Term::Sk->new($format, {base => 1234567, target => 2345678,
- commify => sub{ join '!', split m{}xms, $_[0]; }});
- # The following numbers are shown: act 1!2!3!4!5!6!7 max 2!3!4!5!6!7!8
-
-=head1 DESCRIPTION
-
-=head2 Format strings
-
-The first parameter to new() is the format string which contains the following
-special characters:
-
-=over
-
-=item characters '%d'
-
-a revolving dash, format '/-\|'
-
-=item characters '%t'
-
-time elapsed, format 'hh:mm:ss'
-
-=item characters '%b'
-
-progress bar, format '#####_____'
-
-=item characters '%p'
-
-Progress in percentage, format '999%'
-
-=item characters '%c'
-
-Actual counter value (commified by '_'), format '99_999_999'
-
-=item characters '%m'
-
-Target maximum value (commified by '_'), format '99_999_999'
-
-=item characters '%k'
-
-Token which updates its value before being displayed. An example use
-of this would be a loop wherein every step of the loop could be
-identified by a particular string. For example:
-
- my $ctr = Term::Sk->new('Processing %k counter %c',
- {base => 0, token => 'Albania'});
- foreach my $country (@list_of_european_nations) {
- $ctr->token($country);
- for (1..500) {
- $ctr->up;
- ## do something...
- }
- };
- $ctr->close;
-
-You can also have more than one token on a single line. Here is an example:
-
- my $ctr = Term::Sk->new('Processing %k Region %k counter %c',
- {base => 0, token => ['Albania', 'South']});
- foreach my $country (@list_of_european_nations) {
- $ctr->token([$country, 'North']);
- for (1..500) {
- $ctr->up;
- ## do something...
- }
- };
- $ctr->close;
-
-The C<token> method is used to update the token value immediately on the screen.
-
-The C<tok_maybe> method is used to set the token value, but the screen is not refreshed immediately.
-
-If '%k' is used, then the counter must be instantiated with an initial value for the token.
-
-=item characters '%P'
-
-The '%' character itself
-
-=back
-
-=head2 Options
-
-The second parameter are the following options:
-
-=over
-
-=item option {freq => 999}
-
-This option sets the refresh-frequency on STDOUT to every 999 up() or
-down() calls. If {freq => 999} is not specified at all, then the
-refresh-frequency is set by default to every up() or down() call.
-
-=item option {freq => 's'}
-
-This is a special case whereby the refresh-frequency on STDOUT is set to every
-second.
-
-=item option {freq => 'd'}
-
-This is a special case whereby the refresh-frequency on STDOUT is set to every
-1/10th of a second.
-
-=item option {base => 0}
-
-This specifies the base value from which to count. The default is 0
-
-=item option {target => 10_000}
-
-This specifies the maximum value to which to count. The default is 10_000.
-
-=item option {pdisp => '!'}
-
-This option (with the exclamation mark) is obsolete and has no effect whatsoever. The
-progressbar will always be displayed using the hash-symbol "#".
-
-=item option {quiet => 1}
-
-This option disables most printing to STDOUT, but the content of the would be printed
-line is still available using the method get_line(). The whisper-method, however,
-still shows its output.
-
-The default is in fact {quiet => !-t STDOUT}
-
-=item option {num => '9_999'}
-
-This option configures the output number format for the counters.
-
-=item option {commify => sub{...}}
-
-This option allows one to register a subroutine that formats the counters.
-
-=item option {test => 1}
-
-This option is used for testing purposes only, it disables all printing to STDOUT, even
-the whisper shows no output. But again, the content of the would be printed line is
-still available using the method get_line().
-
-=back
-
-=head2 Processing
-
-The new() method immediately displays the initial values on screen. From now on,
-nothing must be printed to STDOUT and/or STDERR. However, you can write to STDOUT during
-the operation using the method whisper().
-
-We can either count upwards, $ctr->up, or downwards, $ctr->down. Everytime we do so, the
-value is either incremented or decremented and the new value is replaced on STDOUT. We should
-do so regularly during the process. Both methods, $ctr->up(99) and $ctr->down(99) can take an
-optional argument, in which case the value is incremented/decremented by the specified amount.
-
-When our process has finished, we must close the counter ($ctr->close). By doing so, the last
-displayed value is removed from STDOUT, as if nothing had happened. Now we are allowed to print
-again to STDOUT and/or STDERR.
-
-=head2 Post hoc transformation
-
-In some cases it makes sense to redirected STDOUT to a flat file. In this case, the backspace
-characters remain in the flat file.
-
-There is a function "rem_backspace()" that removes the backspaces (including the characters that
-they are supposed to remove) from a redirected file.
-
-Here is a simplified example:
-
- use Term::Sk qw(rem_backspace);
-
- my $flatfile = "Test hijabc\010\010\010xyzklmttt\010\010yzz";
-
- printf "before (len=%3d): '%s'\n", length($flatfile), $flatfile;
-
- rem_backspace(\$flatfile);
-
- printf "after (len=%3d): '%s'\n", length($flatfile), $flatfile;
-
-=head1 AUTHOR
-
-Klaus Eichner, January 2008
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2008-2011 by Klaus Eichner
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
+package Term::Sk;
+$Term::Sk::VERSION = '0.17';
+use strict;
+use warnings;
+
+use Time::HiRes qw( time );
+use Fcntl qw(:seek);
+
+require Exporter;
+
+our @ISA = qw(Exporter);
+our %EXPORT_TAGS = ( 'all' => [ qw(set_chunk_size set_bkup_size rem_backspace) ] );
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+our @EXPORT = qw();
+
+our $errcode = 0;
+our $errmsg = '';
+
+sub new {
+ shift;
+ my $self = {};
+ bless $self;
+
+ $errcode = 0;
+ $errmsg = '';
+
+ my %hash = (freq => 1, base => 0, target => 1_000, quiet => 0, test => 0, num => q{9_999});
+ %hash = (%hash, %{$_[1]}) if defined $_[1];
+
+ my $format = defined $_[0] ? $_[0] : '%8c';
+
+ $self->{base} = $hash{base};
+ $self->{target} = $hash{target};
+ $self->{quiet} = $hash{quiet};
+ $self->{test} = $hash{test};
+ $self->{format} = $format;
+ $self->{freq} = $hash{freq};
+ $self->{value} = $hash{base};
+ $self->{mock_tm} = $hash{mock_tm};
+ $self->{oldtext} = '';
+ $self->{line} = '';
+ $self->{pdisp} = '#';
+ $self->{commify} = $hash{commify};
+ $self->{token} = defined($hash{token}) ? ref($hash{token}) eq 'ARRAY' ? $hash{token} : [$hash{token}] : [];
+
+ unless (defined $self->{quiet}) {
+ $self->{quiet} = !-t STDOUT;
+ }
+
+ if ($hash{num} eq '9') {
+ $self->{sep} = '';
+ $self->{group} = 0;
+ }
+ else {
+ my ($sep, $group) = $hash{num} =~ m{\A 9 ([^\d\+\-]) (9+) \z}xms or do {
+ $errcode = 95;
+ $errmsg = qq{Can't parse num => '$hash{num}'};
+ die sprintf('Error-%04d: %s', $errcode, $errmsg);
+ };
+ $self->{sep} = $sep;
+ $self->{group} = length($group);
+ }
+
+ # Here we de-compose the format into $self->{action}
+
+ $self->{action} = [];
+
+ my $fmt = $format;
+ while ($fmt ne '') {
+ if ($fmt =~ m{^ ([^%]*) % (.*) $}xms) {
+ my ($literal, $portion) = ($1, $2);
+ unless ($portion =~ m{^ (\d*) ([a-zA-Z]) (.*) $}xms) {
+ $errcode = 100;
+ $errmsg = qq{Can't parse '%[<number>]<alpha>' from '%$portion', total line is '$format'};
+ die sprintf('Error-%04d: %s', $errcode, $errmsg);
+ }
+
+ my ($repeat, $disp_code, $remainder) = ($1, $2, $3);
+
+ if ($repeat eq '') { $repeat = 1; }
+ if ($repeat < 1) { $repeat = 1; }
+
+ unless ($disp_code eq 'b'
+ or $disp_code eq 'c'
+ or $disp_code eq 'd'
+ or $disp_code eq 'm'
+ or $disp_code eq 'p'
+ or $disp_code eq 'P'
+ or $disp_code eq 't'
+ or $disp_code eq 'k') {
+ $errcode = 110;
+ $errmsg = qq{Found invalid display-code ('$disp_code'), expected ('b', 'c', 'd', 'm', 'p', 'P' 't' or 'k') in '%$portion', total line is '$format'};
+ die sprintf('Error-%04d: %s', $errcode, $errmsg);
+ }
+
+ push @{$self->{action}}, {type => '*lit', len => length($literal), lit => $literal} if length($literal) > 0;
+ push @{$self->{action}}, {type => $disp_code, len => $repeat};
+ $fmt = $remainder;
+ }
+ else {
+ push @{$self->{action}}, {type => '*lit', len => length($fmt), lit => $fmt};
+ $fmt = '';
+ }
+ }
+
+ # End of format de-composition
+
+ $self->{tick} = 0;
+ $self->{out} = 0;
+ $self->{sec_begin} = $self->{mock_tm} ? $self->{mock_tm} : time;
+ $self->{sec_print} = 0;
+
+ $self->show;
+
+ return $self;
+}
+
+sub mock_time {
+ my $self = shift;
+
+ $self->{mock_tm} = $_[0];
+}
+
+sub whisper {
+ my $self = shift;
+
+ my $back = qq{\010} x length $self->{oldtext};
+ my $blank = q{ } x length $self->{oldtext};
+
+ $self->{line} = join('', $back, $blank, $back, @_, $self->{oldtext});
+
+ unless ($self->{test}) {
+ local $| = 1;
+ if ($self->{quiet}) {
+ print @_;
+ }
+ else {
+ print $self->{line};
+ }
+ }
+}
+
+sub get_line {
+ my $self = shift;
+
+ return $self->{line};
+}
+
+sub up { my $self = shift; $self->{value} += defined $_[0] ? $_[0] : 1; $self->show_maybe; }
+sub down { my $self = shift; $self->{value} -= defined $_[0] ? $_[0] : 1; $self->show_maybe; }
+sub close { my $self = shift; $self->{value} = undef; $self->show; }
+
+sub ticks { my $self = shift; return $self->{tick} }
+
+sub token {
+ my $self = shift;
+ my $tk = shift;
+ $self->{token} = ref($tk) eq 'ARRAY' ? $tk : [$tk];
+ $self->show;
+}
+
+sub tok_maybe {
+ my $self = shift;
+ my $tk = shift;
+ $self->{token} = ref($tk) eq 'ARRAY' ? $tk : [$tk];
+ $self->show_maybe;
+}
+
+sub DESTROY {
+ my $self = shift;
+ $self->close;
+}
+
+sub show_maybe {
+ my $self = shift;
+
+ $self->{line} = '';
+
+ my $sec_now = ($self->{mock_tm} ? $self->{mock_tm} : time) - $self->{sec_begin};
+ my $sec_prev = $self->{sec_print};
+
+ $self->{sec_print} = $sec_now;
+ $self->{tick}++;
+
+ if ($self->{freq} eq 's') {
+ if (int($sec_prev) != int($sec_now)) {
+ $self->show;
+ }
+ }
+ elsif ($self->{freq} eq 'd') {
+ if (int($sec_prev * 10) != int($sec_now * 10)) {
+ $self->show;
+ }
+ }
+ else {
+ unless ($self->{tick} % $self->{freq}) {
+ $self->show;
+ }
+ }
+}
+
+sub show {
+ my $self = shift;
+ $self->{out}++;
+
+ my $back = qq{\010} x length $self->{oldtext};
+ my $blank = q{ } x length $self->{oldtext};
+
+ my $text = '';
+ if (defined $self->{value}) {
+
+ # Here we compose a string based on $self->{action} (which, of course, is the previously de-composed format)
+
+ my $tok_ind = 0;
+
+ for my $act (@{$self->{action}}) {
+ my ($type, $lit, $len) = ($act->{type}, $act->{lit}, $act->{len});
+
+ if ($type eq '*lit') { # print (= append to $text) a simple literal
+ $text .= $lit;
+ next;
+ }
+ if ($type eq 't') { # print (= append to $text) time elapsed in format 'hh:mm:ss'
+ my $unit = int($self->{sec_print});
+ my $hour = int($unit / 3600);
+ my $min = int(($unit % 3600) / 60);
+ my $sec = $unit % 60;
+ my $stamp = sprintf '%02d:%02d:%02d', $hour, $min, $sec;
+
+ $stamp = substr($stamp, -$len) if length($stamp) > $len;
+
+ $text .= sprintf "%${len}.${len}s", $stamp;
+ next;
+ }
+ if ($type eq 'd') { # print (= append to $text) a revolving dash in format '/-\|'
+ $text .= substr('/-\|', $self->{out} % 4, 1) x $len;
+ next;
+ }
+ if ($type eq 'b') { # print (= append to $text) progress indicator format '#####_____'
+ my $progress = $self->{target} == $self->{base} ? 0 :
+ int ($len * ($self->{value} - $self->{base}) / ($self->{target} - $self->{base}) + 0.5);
+ if ($progress < 0) { $progress = 0 }
+ elsif ($progress > $len) { $progress = $len }
+ $text .= $self->{pdisp} x $progress.'_' x ($len - $progress);
+ next;
+ }
+ if ($type eq 'p') { # print (= append to $text) progress in percentage format '999%'
+ my $percent = $self->{target} == $self->{base} ? 0 :
+ 100 * ($self->{value} - $self->{base}) / ($self->{target} - $self->{base});
+ $text .= sprintf "%${len}.${len}s", sprintf("%.0f%%", $percent);
+ next;
+ }
+ if ($type eq 'P') { # print (= append to $text) literally '%' characters
+ $text .= '%' x $len;
+ next;
+ }
+ if ($type eq 'c') { # print (= append to $text) actual counter value (commified)
+ $text .= sprintf "%${len}s", commify($self->{commify}, $self->{value}, $self->{sep}, $self->{group});
+ next;
+ }
+ if ($type eq 'm') { # print (= append to $text) target (commified)
+ $text .= sprintf "%${len}s", commify($self->{commify}, $self->{target}, $self->{sep}, $self->{group});
+ next;
+ }
+ if ($type eq 'k') { # print (= append to $text) token
+ $text .= sprintf "%-${len}s", $self->{token}[$tok_ind];
+ $tok_ind++;
+ next;
+ }
+ # default: do nothing, in the (impossible) event that $type is none of '*lit', 't', 'b', 'p', 'P', 'c', 'm' or 'k'
+ }
+
+ # End of string composition
+ }
+
+ $self->{line} = join('', $back, $blank, $back, $text);
+
+ unless ($self->{test} or $self->{quiet}) {
+ local $| = 1;
+ print $self->{line};
+ }
+
+ $self->{oldtext} = $text;
+}
+
+sub commify {
+ my $com = shift;
+ if ($com) { return $com->($_[0]); }
+
+ local $_ = shift;
+ my ($sep, $group) = @_;
+
+ if ($group > 0) {
+ my $len = length($_);
+ for my $i (1..$len) {
+ last unless s/^([-+]?\d+)(\d{$group})/$1$sep$2/;
+ }
+ }
+ return $_;
+}
+
+my $chunk_size = 10000;
+my $bkup_size = 80;
+
+# Decision by Klaus Eichner, 31-MAY-2011:
+# ---------------------------------------
+# Make subs log_info(), set_chunk_size() and set_bkup_size() effectively dummy operations (i.e. they
+# don't have any effect whatsoever)
+
+sub log_info { }
+sub set_chunk_size { }
+sub set_bkup_size { }
+
+sub rem_backspace {
+ my ($fname) = @_;
+
+ open my $ifh, '<', $fname or die "Error-0200: Can't open < '$fname' because $!";
+ open my $tfh, '+>', undef or die "Error-0210: Can't open +> undef (tempfile) because $!";
+
+ my $out_buf = '';
+
+ while (read($ifh, my $inp_buf, $chunk_size)) {
+ $out_buf .= $inp_buf;
+
+ # here we are removing the backspaces:
+ while ($out_buf =~ m{\010+}xms) {
+ my $pos_left = $-[0] * 2 - $+[0];
+ if ($pos_left < 0) {
+ $pos_left = 0;
+ }
+ $out_buf = substr($out_buf, 0, $pos_left).substr($out_buf, $+[0]);
+ }
+
+ if (length($out_buf) > $bkup_size) {
+ print {$tfh} substr($out_buf, 0, -$bkup_size);
+ $out_buf = substr($out_buf, -$bkup_size);
+ }
+ }
+
+ CORE::close $ifh; # We need to employ CORE::close because there is already another close subroutine defined in the current namespace "Term::Sk"
+
+ print {$tfh} $out_buf;
+
+ # Now copy back temp-file to original file:
+
+ seek $tfh, 0, SEEK_SET or die "Error-0220: Can't seek tempfile to 0 because $!";
+ open my $ofh, '>', $fname or die "Error-0230: Can't open > '$fname' because $!";
+
+ while (read($tfh, my $buf, $chunk_size)) { print {$ofh} $buf; }
+
+ CORE::close $ofh;
+ CORE::close $tfh;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Term::Sk - Perl extension for displaying a progress indicator on a terminal.
+
+=head1 SYNOPSIS
+
+ use Term::Sk;
+
+ my $ctr = Term::Sk->new('%d Elapsed: %8t %21b %4p %2d (%8c of %11m)',
+ {quiet => 0, freq => 10, base => 0, target => 100, pdisp => '!'});
+
+ $ctr->up for (1..100);
+
+ $ctr->down for (1..100);
+
+ $ctr->whisper('abc');
+
+ my last_line = $ctr->get_line;
+
+ $ctr->close;
+
+ print "Number of ticks: ", $ctr->ticks, "\n";
+
+=head1 EXAMPLES
+
+Term::Sk is a class to implement a progress indicator ("Sk" is a short form for "Show Key"). This is used to provide immediate feedback for
+long running processes.
+
+A sample code fragment that uses Term::Sk:
+
+ use Term::Sk;
+
+ print qq{This is a test of "Term::Sk"\n\n};
+
+ my $target = 2_845;
+ my $format = '%2d Elapsed: %8t %21b %4p %2d (%8c of %11m)';
+
+ my $ctr = Term::Sk->new($format,
+ {freq => 10, base => 0, target => $target, pdisp => '!'});
+
+ for (1..$target) {
+ $ctr->up;
+ do_something();
+ }
+
+ $ctr->close;
+
+ sub do_something {
+ my $test = 0;
+ for my $i (0..10_000) {
+ $test += sin($i) * cos($i);
+ }
+ }
+
+Another example that counts upwards:
+
+ use Term::Sk;
+
+ my $format = '%21b %4p';
+
+ my $ctr = Term::Sk->new($format, {freq => 's', base => 0, target => 70});
+
+ for (1..10) {
+ $ctr->up(7);
+ sleep 1;
+ }
+
+ $ctr->close;
+
+At any time, after Term::Sk->new(), you can query the number of ticks (i.e. number of calls to
+$ctr->up or $ctr->down) using the method 'ticks':
+
+ use Term::Sk;
+
+ my $ctr = Term::Sk->new('%6c', {freq => 's', base => 0, target => 70});
+
+ for (1..4288) {
+ $ctr->up;
+ }
+
+ $ctr->close;
+
+ print "Number of ticks: ", $ctr->ticks, "\n";
+
+This example uses a simple progress bar in quiet mode (nothing is printed to STDOUT), but
+instead, the content of what would have been printed can now be extracted using the get_line() method:
+
+ use Term::Sk;
+
+ my $format = 'Ctr %4c';
+
+ my $ctr = Term::Sk->new($format, {freq => 2, base => 0, target => 10, quiet => 1});
+
+ my $line = $ctr->get_line;
+ $line =~ s/\010/</g;
+ print "This is what would have been printed upon new(): [$line]\n";
+
+ for my $i (1..10) {
+ $ctr->up;
+
+ $line = $ctr->get_line;
+ $line =~ s/\010/</g;
+ print "This is what would have been printed upon $i. call to up(): [$line]\n";
+ }
+
+ $ctr->close;
+
+ $line = $ctr->get_line;
+ $line =~ s/\010/</g;
+ print "This is what would have been printed upon close(): [$line]\n";
+
+Here are some examples that show different values for option {num => ...}
+
+ my $format = 'act %c max %m';
+
+ my $ctr1 = Term::Sk->new($format, {base => 1234567, target => 2345678});
+ # The following numbers are shown: act 1_234_567 max 2_345_678
+
+ my $ctr2 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9,999}});
+ # The following numbers are shown: act 1,234,567 max 2,345,678
+
+ my $ctr3 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9'99}});
+ # The following numbers are shown: act 1'23'45'67 max 2'34'56'78
+
+ my $ctr4 = Term::Sk->new($format, {base => 1234567, target => 2345678, num => q{9}});
+ # The following numbers are shown: act 1234567 max 2345678
+
+ my $ctr5 = Term::Sk->new($format, {base => 1234567, target => 2345678,
+ commify => sub{ join '!', split m{}xms, $_[0]; }});
+ # The following numbers are shown: act 1!2!3!4!5!6!7 max 2!3!4!5!6!7!8
+
+=head1 DESCRIPTION
+
+=head2 Format strings
+
+The first parameter to new() is the format string which contains the following
+special characters:
+
+=over
+
+=item characters '%d'
+
+a revolving dash, format '/-\|'
+
+=item characters '%t'
+
+time elapsed, format 'hh:mm:ss'
+
+=item characters '%b'
+
+progress bar, format '#####_____'
+
+=item characters '%p'
+
+Progress in percentage, format '999%'
+
+=item characters '%c'
+
+Actual counter value (commified by '_'), format '99_999_999'
+
+=item characters '%m'
+
+Target maximum value (commified by '_'), format '99_999_999'
+
+=item characters '%k'
+
+Token which updates its value before being displayed. An example use
+of this would be a loop wherein every step of the loop could be
+identified by a particular string. For example:
+
+ my $ctr = Term::Sk->new('Processing %k counter %c',
+ {base => 0, token => 'Albania'});
+ foreach my $country (@list_of_european_nations) {
+ $ctr->token($country);
+ for (1..500) {
+ $ctr->up;
+ ## do something...
+ }
+ };
+ $ctr->close;
+
+You can also have more than one token on a single line. Here is an example:
+
+ my $ctr = Term::Sk->new('Processing %k Region %k counter %c',
+ {base => 0, token => ['Albania', 'South']});
+ foreach my $country (@list_of_european_nations) {
+ $ctr->token([$country, 'North']);
+ for (1..500) {
+ $ctr->up;
+ ## do something...
+ }
+ };
+ $ctr->close;
+
+The C<token> method is used to update the token value immediately on the screen.
+
+The C<tok_maybe> method is used to set the token value, but the screen is not refreshed immediately.
+
+If '%k' is used, then the counter must be instantiated with an initial value for the token.
+
+=item characters '%P'
+
+The '%' character itself
+
+=back
+
+=head2 Options
+
+The second parameter are the following options:
+
+=over
+
+=item option {freq => 999}
+
+This option sets the refresh-frequency on STDOUT to every 999 up() or
+down() calls. If {freq => 999} is not specified at all, then the
+refresh-frequency is set by default to every up() or down() call.
+
+=item option {freq => 's'}
+
+This is a special case whereby the refresh-frequency on STDOUT is set to every
+second.
+
+=item option {freq => 'd'}
+
+This is a special case whereby the refresh-frequency on STDOUT is set to every
+1/10th of a second.
+
+=item option {base => 0}
+
+This specifies the base value from which to count. The default is 0
+
+=item option {target => 10_000}
+
+This specifies the maximum value to which to count. The default is 10_000.
+
+=item option {pdisp => '!'}
+
+This option (with the exclamation mark) is obsolete and has no effect whatsoever. The
+progressbar will always be displayed using the hash-symbol "#".
+
+=item option {quiet => 1}
+
+This option disables most printing to STDOUT, but the content of the would be printed
+line is still available using the method get_line(). The whisper-method, however,
+still shows its output.
+
+The default is in fact {quiet => !-t STDOUT}
+
+=item option {num => '9_999'}
+
+This option configures the output number format for the counters.
+
+=item option {commify => sub{...}}
+
+This option allows one to register a subroutine that formats the counters.
+
+=item option {test => 1}
+
+This option is used for testing purposes only, it disables all printing to STDOUT, even
+the whisper shows no output. But again, the content of the would be printed line is
+still available using the method get_line().
+
+=back
+
+=head2 Processing
+
+The new() method immediately displays the initial values on screen. From now on,
+nothing must be printed to STDOUT and/or STDERR. However, you can write to STDOUT during
+the operation using the method whisper().
+
+We can either count upwards, $ctr->up, or downwards, $ctr->down. Everytime we do so, the
+value is either incremented or decremented and the new value is replaced on STDOUT. We should
+do so regularly during the process. Both methods, $ctr->up(99) and $ctr->down(99) can take an
+optional argument, in which case the value is incremented/decremented by the specified amount.
+
+When our process has finished, we must close the counter ($ctr->close). By doing so, the last
+displayed value is removed from STDOUT, as if nothing had happened. Now we are allowed to print
+again to STDOUT and/or STDERR.
+
+=head2 Post hoc transformation
+
+In some cases it makes sense to redirected STDOUT to a flat file. In this case, the backspace
+characters remain in the flat file.
+
+There is a function "rem_backspace()" that removes the backspaces (including the characters that
+they are supposed to remove) from a redirected file.
+
+Here is a simplified example:
+
+ use Term::Sk qw(rem_backspace);
+
+ my $flatfile = "Test hijabc\010\010\010xyzklmttt\010\010yzz";
+
+ printf "before (len=%3d): '%s'\n", length($flatfile), $flatfile;
+
+ rem_backspace(\$flatfile);
+
+ printf "after (len=%3d): '%s'\n", length($flatfile), $flatfile;
+
+=head1 AUTHOR
+
+Klaus Eichner, January 2008
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (C) 2008-2011 by Klaus Eichner
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use Test::More tests => 71;
+use Test::More tests => 74;
use_ok('Term::Sk');
@@ -235,6 +235,20 @@ use_ok('Term::Sk');
is(content($ctr->get_line), q{Token1 ghi Token2 jkl Ctr 1}, 'Test-0760: second double Token displayed correctly');
}
+# Test for version 0.15:
+# **********************
+
+{
+ # mock-time = Tue Jun 21 14:21:02-28 2011
+ my $ctr = Term::Sk->new('T(%5t)', { test => 1, base => 1, mock_tm => 1308658862.287032} );
+ ok(defined($ctr), 'Test-0770: %t works ok');
+ is(content($ctr->get_line), q{T(00:00)}, 'Test-0780: first time displays "00:00"');
+ # mock-time = Tue Jun 21 14:21:26-29 2011
+ $ctr->mock_time(1308658885.4382647);
+ $ctr->up;
+ is(content($ctr->get_line), q{T(00:23)}, 'Test-0790: second time displays "00:23"');
+}
+
sub content {
my ($text) = @_;
@@ -0,0 +1,14 @@
+#!perl
+
+BEGIN {
+ unless ($ENV{RELEASE_TESTING}) {
+ require Test::More;
+ Test::More::plan(skip_all => 'these tests are for release candidate testing');
+ }
+}
+
+# This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests.
+use Test::More;
+use Test::Pod 1.41;
+
+all_pod_files_ok();