Giter Site home page Giter Site logo

indent-form's Introduction

NAME
     Indent::Form - A perl module for form indenting.

SYNOPSIS
     use Indent::Form;

     my $indent = Indent::Form->new(%parametes);
     my $string = $indent->indent($data_ar, $actual_indent, $non_indent_flag);
     my @string = $indent->indent($data_ar, $actual_indent, $non_indent_flag);

METHODS
  "new"
     my $indent = Indent::Form->new(%parametes);

    Constructor.

    Returns instance of object.

    *       "ansi"

             Use with ANSI sequences.
             Default value is 0.

    *       "align"

             Align of left side of form.
             Default value is 'right'.

    *       "fill_character"

             Fill character for left side of form.
             Default value is ' '.

    *       "form_separator"

             Form separator.
             Default value of 'form_separator' is ': '.

    *       "line_size"

             Line size.
             Default value of 'line_size' is 79 chars.

    *       "next_indent"

             Next indent.
             Default value of 'next_indent' isn't define.

    *       "output_separator"

             Output separator.
             Default value of 'output_separator' is new line (\n).

  "indent"
     my $string = $indent->indent($data_ar, $actual_indent, $non_indent_flag);
     my @string = $indent->indent($data_ar, $actual_indent, $non_indent_flag);

    Indent data. Scalar output is controlled by 'output_separator'
    parameter.

     Arguments:
     $data_ar - Reference to data array ([['key' => 'value'], [..]]);
     $actual_indent - String to actual indent.
     $non_indent_flag - Flag, than says no-indent.

    Returns string or array of strings in array context.

ENVIRONMENT
    Output is controlled by env variable "NO_COLOR" via Term::ANSIColor Perl
    module. If we set 'ansi' parameter to 1 and env variable "NO_COLOR" will
    be 1, output will be without ANSI colors. See <https://no-color.org/>.

ERRORS
     new():
             'align' parameter must be a 'left' or 'right' string.
             'line_size' parameter must be a number.
             Cannot load 'Text::ANSI::Util' module.
             From Class::Utils:
                     Unknown parameter '%s'.

EXAMPLE1
     use strict;
     use warnings;

     use Indent::Form;

     # Indent object.
     my $indent = Indent::Form->new;

     # Input data.
     my $input_ar = [
             ['Filename', 'foo.bar'],
             ['Size', '1456kB'],
             ['Description', 'File'],
             ['Author', 'skim.cz'],
     ];

     # Indent.
     print $indent->indent($input_ar)."\n";

     # Output:
     #    Filename: foo.bar
     #        Size: 1456kB
     # Description: File
     #      Author: skim.cz

EXAMPLE2
     use strict;
     use warnings;

     use Indent::Form;

     # Indent object.
     my $indent = Indent::Form->new(
             'align' => 'left',
     );

     # Input data.
     my $input_ar = [
             ['Filename', 'foo.bar'],
             ['Size', '1456kB'],
             ['Description', 'File'],
             ['Author', 'skim.cz'],
     ];

     # Indent.
     print $indent->indent($input_ar)."\n";

     # Output:
     # Filename   : foo.bar
     # Size       : 1456kB
     # Description: File
     # Author     : skim.cz

EXAMPLE3
     use strict;
     use warnings;

     use Indent::Form;

     # Indent object.
     my $indent = Indent::Form->new(
             'align' => 'left',
             'fill_character' => '.',
     );

     # Input data.
     my $input_ar = [
             ['Filename', 'foo.bar'],
             ['Size', '1456kB'],
             ['Description', 'File'],
             ['Author', 'skim.cz'],
     ];

     # Indent.
     print $indent->indent($input_ar)."\n";

     # Output:
     # Filename...: foo.bar
     # Size.......: 1456kB
     # Description: File
     # Author.....: skim.cz

EXAMPLE4
     use strict;
     use warnings;

     use Encode qw(decode_utf8 encode_utf8);
     use Indent::Form;

     # Indent object.
     my $indent = Indent::Form->new;

     # Input data.
     my $input_ar = [
             ['Filename', 'foo.bar'],
             ['Size', '1456kB'],
             ['Description', 'File'],
             ['Author', 'skim.cz'],
     ];

     # Indent.
     print encode_utf8($indent->indent($input_ar, decode_utf8('|↔| ')))."\n";

     # Output:
     # |↔|    Filename: foo.bar
     # |↔|        Size: 1456kB
     # |↔| Description: File
     # |↔|      Author: skim.cz

EXAMPLE5
     use strict;
     use warnings;

     use Indent::Form;
     use Term::ANSIColor;

     # Indent object.
     my $indent = Indent::Form->new(
             'ansi' => 1,
     );

     # Input data.
     my $input_ar = [
             [
                     color('cyan').'Filename'.color('reset'),
                     color('bold cyan').'f'.color('reset').'oo.'.color('bold cyan').'b'.color('reset').'ar',
             ],
             [
                     color('cyan').'Size'.color('reset'),
                     '1456kB',
             ],
             [
                     color('cyan').'Description'.color('reset'),
                     color('bold cyan').'F'.color('reset').'ile',
             ],
             [
                     color('cyan').'Author'.color('reset'),
                     'skim.cz',
             ],
     ];

     # Indent.
     print $indent->indent($input_ar)."\n";

     # Output (with ANSI colors):
     #    Filename: foo.bar
     #        Size: 1456kB
     # Description: File
     #      Author: skim.cz

DEPENDENCIES
    Class::Utils, English, Error::Pure, Indent::Word, List::MoreUtils,
    Readonly.

    Text::ANSI::Util for situation with 'ansi' => 1.

SEE ALSO
    Indent
             Class for indent handling.

    Indent::Block
             Class for block indenting.

    Indent::Data
             Class for data indenting.

    Indent::String
             Class for text indenting.

    Indent::Utils
             Utilities for Indent classes.

    Indent::Word
             Class for word indenting.

REPOSITORY
    <https://github.com/michal-josef-spacek/Indent-Form>

AUTHOR
    Michal Josef Špaček <mailto:[email protected]>

    <http://skim.cz>

LICENSE AND COPYRIGHT
    © 2011-2023 Michal Josef Špaček

    Artistic License

    BSD 2-Clause License

VERSION
    0.09

indent-form's People

Contributors

michal-josef-spacek avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.