Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
trapd00r committed Jan 29, 2019
0 parents commit 964a6a1
Show file tree
Hide file tree
Showing 18 changed files with 539 additions and 0 deletions.
18 changes: 18 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
lib/Term/ExtendedColor/Dzen.pm
Makefile.PL
MANIFEST
t/00-load.t
t/01-pod.t
t/10-strict.t
t/20-synopsis.t
t/30-eol.t
t/30-fixme.t
t/30-notabs.t
t/40-kwalitee.t
t/50-complexity.t
t/60-pod-coverage.t
t/60-pod-syntax.t
t/80-minperl.t
README
examples/dzen_load.pl
examples/fgonbg
58 changes: 58 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile1(
META_MERGE => {
resources => {
repository => q{https://github.com/trapd00r/Term-ExtendedColor-Dzen},
bugtracker => q{https://github.com/trapd00r/Term-ExtendedColor-Dzen/issues},
},
},

NAME => q{Term::ExtendedColor::Dzen},
AUTHOR => q{Magnus Woldrich <[email protected]>},
ABSTRACT => q{Color input and add dzen compatible attributes},
VERSION_FROM => q{lib/Term/ExtendedColor/Dzen.pm},
LICENSE => q{perl},
# EXE_FILES => [ glob('bin/*') ],
PREREQ_PM => { },
MIN_PERL_VERSION => 5.010,
MAN1PODS => { },
dist => { COMPRESS => q{gzip -9f}, SUFFIX => q{gz}, },
clean => { FILES => q{Term-ExtendedColor-Dzen-*}, },
);

sub WriteMakefile1 {
my %params = @_;
my $eumm_version = $ExtUtils::MakeMaker::VERSION;
$eumm_version = eval $eumm_version;
die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
die "License not specified" if not exists $params{LICENSE};
if ($params{AUTHOR} and ref($params{AUTHOR}) eq q{ARRAY}
and $eumm_version < 6.5705) {
$params{META_ADD}->{author}=$params{AUTHOR};
$params{AUTHOR}=join(', ',@{$params{AUTHOR}});
}
if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
#EUMM 6.5502 has problems with BUILD_REQUIRES
$params{PREREQ_PM}={
%{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}}
};
delete $params{BUILD_REQUIRES};
}
delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
delete $params{META_MERGE} if $eumm_version < 6.46;
delete $params{META_ADD} if $eumm_version < 6.46;
delete $params{LICENSE} if $eumm_version < 6.31;
delete $params{AUTHOR} if $] < 5.005;
delete $params{ABSTRACT_FROM} if $] < 5.005;
delete $params{BINARY_LOCATION} if $] < 5.005;

#delete $params{MAN3PODS}->{'README.pod'};

WriteMakefile(%params);
}


60 changes: 60 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
NAME
Term::ExtendedColor::Dzen - Color input and add dzen(2) compatible
attributes

SYNOPSIS
use Term::ExtendedColor::Dzen qw(fgd bgd);

print fgd('#ff0000', 'this is red foreground');
print bgd('#fff00', 'this is yellow background');

print fgd('#000', bgd('#ffffff', 'this is black on white background'));

DESCRIPTION
Term::ExtendedColor::Dzen provides functionality for coloring input data
with dzen compatible attributes.

EXPORTS
None by default.

FUNCTIONS
fgd('#fff', $string)
Sets foreground color. When called without arguments, returns the fg
reset string.

my $white_fg = fgd('#fff', 'white foreground');

bgd('#000', $string)
Sets background color. When called without arguments, returns the bg
reset string.

my $black_bg = bg('#000', 'black background');

Like "fgd()", but sets background colors.

These two can be combined:

my $str = fgd('#000', bgd('#ffffff', 'this is black on white background'));

which yields the combined string:

^fg(#000)^bg(#fff)this is black on white background^bg()^fg()

SEE ALSO
dzen <https://github.com/robm/dzen>

dzen2 <https://github.com/minos-org/dzen2>

AUTHOR
Magnus Woldrich
CPAN ID: WOLDRICH
[email protected]
http://japh.se

Copyright 2019- the Term::ExtendedColor::Dzen "AUTHOR" and
"CONTRIBUTORS" as listed above.

LICENSE
This library is free software; you may redistribute it and/or modify it
under the same terms as Perl itself.

40 changes: 40 additions & 0 deletions examples/dzen_load.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/perl
# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2:
use strict;
use vars qw($VERSION);
use autodie qw(:all);

my $APP = 'dzen-uptime';
$VERSION = '0.001';

# $ while true; do perl dzen_uptime.pl; sleep 1; done | dzen2

use Number::RGB;
use Term::ExtendedColor::Dzen qw(fgd bgd);


open(my $fh, '<', '/proc/loadavg') or die $!;
chomp(my $uptime = <$fh>);
close $fh;

my @avg = $uptime =~ m/(\d+[.]\d+)/g;

$avg[0] = fgd(Number::RGB->new(rgb => randhex())->hex, $avg[0]);
$avg[1] = fgd(Number::RGB->new(rgb => randhex())->hex, $avg[1]);
$avg[2] = fgd(Number::RGB->new(rgb => randhex())->hex, $avg[2]);

my $bg = Number::RGB->new(rgb => randhex())->hex;

$avg[0] = bgd($bg, $avg[0]);
$avg[1] = bgd($bg, $avg[1]);
$avg[2] = bgd($bg, $avg[2]);

print join('', @avg), "\n";

sub randhex {
return [
int(rand(255)),
int(rand(255)),
int(rand(255)),
]
}
11 changes: 11 additions & 0 deletions examples/fgonbg
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/perl
# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2:
use strict;
use vars qw($VERSION);
use autodie qw(:all);

use Term::ExtendedColor::Dzen qw(fgd bgd);

use feature 'say';

say fgd('#000', bgd('#fff', 'this is black on white background'));
119 changes: 119 additions & 0 deletions lib/Term/ExtendedColor/Dzen.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package Term::ExtendedColor::Dzen;
use strict;
use warnings;

BEGIN {
use Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);

$VERSION = '0.001';
@ISA = qw(Exporter);

@EXPORT_OK = qw(
fgd
bgd
);

%EXPORT_TAGS = (
attributes => [ qw(fgd bgd) ],
all => [ @EXPORT_OK ],
);
}


sub fgd {
if(!@_) {
return "^fg()"
}
my ($color, $data) = @_;
return "^fg($color)$data^fg()";
}

sub bgd {
if(!@_) {
return "^bg()"
}
my ($color, $data) = @_;
return "^bg($color)$data^bg()";
}




1;

__END__
=pod
=head1 NAME
Term::ExtendedColor::Dzen - Color input and add dzen(2) compatible attributes
=head1 SYNOPSIS
use Term::ExtendedColor::Dzen qw(fgd bgd);
print fgd('#ff0000', 'this is red foreground');
print bgd('#fff00', 'this is yellow background');
print fgd('#000', bgd('#ffffff', 'this is black on white background'));
=head1 DESCRIPTION
B<Term::ExtendedColor::Dzen> provides functionality for coloring input data
with dzen compatible attributes.
=head1 EXPORTS
None by default.
=head1 FUNCTIONS
=head2 fgd('#fff', $string)
Sets foreground color. When called without arguments, returns the fg
reset string.
my $white_fg = fgd('#fff', 'white foreground');
=head2 bgd('#000', $string)
Sets background color. When called without arguments, returns the bg
reset string.
my $black_bg = bg('#000', 'black background');
Like C<fgd()>, but sets background colors.
These two can be combined:
my $str = fgd('#000', bgd('#ffffff', 'this is black on white background'));
which yields the combined string:
^fg(#000)^bg(#fff)this is black on white background^bg()^fg()
=head1 SEE ALSO
L<dzen|https://github.com/robm/dzen>
L<dzen2|https://github.com/minos-org/dzen2>
=head1 AUTHOR
Magnus Woldrich
CPAN ID: WOLDRICH
[email protected]
http://japh.se
Copyright 2019- the B<Term::ExtendedColor::Dzen> L</AUTHOR>
and L</CONTRIBUTORS> as listed above.
=head1 LICENSE
This library is free software; you may redistribute it and/or modify it under
the same terms as Perl itself.
=cut
9 changes: 9 additions & 0 deletions t/00-load.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;

BEGIN {
use_ok('Term::ExtendedColor::Dzen');
}

12 changes: 12 additions & 0 deletions t/01-pod.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;

unless(exists($ENV{RELEASE_TESTING})) {
plan skip_all => 'these tests are for release candidate testing';
}

eval "use Test::Pod 1.00"; ## no critic
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok( all_pod_files( qw(blib) ) );
20 changes: 20 additions & 0 deletions t/10-strict.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/perl
# test for syntax, strict and warnings

use strict;
use warnings;
use Test::More;

unless(exists($ENV{RELEASE_TESTING})) {
plan skip_all => 'these tests are for release candidate testing';
}

eval 'use Test::Strict'; ## no critic
plan skip_all => 'Test::Strict required' if $@;

{
no warnings 'once';
$Test::Strict::TEST_WARNINGS = 0;
}

all_perl_files_ok(qw/ lib t /);
14 changes: 14 additions & 0 deletions t/20-synopsis.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;

eval "use Test::Synopsis"; ## no critic

unless(exists($ENV{RELEASE_TESTING})) {
plan skip_all => 'these tests are for release candidate testing';
}

plan skip_all => 'Test::Synopsis required for testing synopsis' if $@;

all_synopsis_ok()
15 changes: 15 additions & 0 deletions t/30-eol.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/perl
# test for correct line endings

use strict;
use warnings;
use Test::More;

unless(exists($ENV{RELEASE_TESTING})) {
plan skip_all => 'these tests are for release candidate testing';
}

eval 'use Test::EOL'; ## no critic
plan skip_all => 'Test::EOL required' if $@;

all_perl_files_ok( { trailing_whitespace => 1 }, qw/ lib t / );
Loading

0 comments on commit 964a6a1

Please sign in to comment.