Skip to content

Commit

Permalink
1.24 - 2024-07-01
Browse files Browse the repository at this point in the history
Can be easily sub moduled.
Command "say" will always redirect to the terminal.
  • Loading branch information
Timofey Potapov committed Jul 1, 2024
1 parent 88f61b4 commit e81f960
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 114 deletions.
32 changes: 6 additions & 26 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
name: build and test

on:
# Automated:
push:
branches:
- "main"
- "test"
pull_request:
branches:
- "main"
# Manual:
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -54,34 +57,12 @@ jobs:
name: build_dir
path: build_dir

coverage-job:
needs: build-job
runs-on: ubuntu-20.04
container:
image: perldocker/perl-tester:5.38
steps:

- name: Checkout docker/package
uses: actions/checkout@v4 # codecov wants to be inside a Git repository

- name: Download artifact from build step
uses: actions/download-artifact@v4
with:
name: build_dir
path: .

- name: Install deps and test
run: cpan-install-dist-deps && test-dist
env:
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}

test-job:
needs: build-job
strategy:
fail-fast: true
matrix:
os: [ ubuntu-latest, macos-latest ]
distribution: [ default ]
perl-version:
- "5.16"
- "5.18"
Expand All @@ -95,9 +76,8 @@ jobs:
- "5.34"
- "5.36"
- "5.38"
# - "5.40" Not working!
- "5.40.0"
- "latest"
# - "latest"
runs-on: ${{ matrix.os }}
name: on ${{ matrix.os }} perl ${{ matrix.perl-version }}
steps:
Expand All @@ -106,7 +86,7 @@ jobs:
uses: shogo82148/[email protected]
with:
perl-version: ${{ matrix.perl-version }}
distribution: ${{ matrix.distribution }}
distribution: default

- name: Download artifact from build step
uses: actions/download-artifact@v4
Expand All @@ -121,7 +101,7 @@ jobs:
run: |
cpanm --notest Module::Build~0.4004
perl Build.PL
perl Build installdeps
perl Build installdeps --cpan_client 'cpan -T'
- name: Run tests
run: prove -lr t -v
Expand Down
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Revision history for e

=================
1.24 - 2024-07-01
=================

Can be easily sub moduled.
Command "say" will always redirect to the terminal.

=================
1.23 - 2024-06-22
=================
Expand Down
105 changes: 74 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
⠹⡽⣾⣿⠹⣿⣆⣾⢯⣿⣿ ⡞ ⠻⣿⣿⣿⠁ ⢠⣿⢏ ⡀ ⡟ ⢀⣴⣿⠃⢁⡼⠁ ⠈
⠈⠛ ⢻⣿⣧⢸⢟⠶⢾⡇ ⣸⡿⠁ ⢠⣾⡟⢼ ⣷ ⡇ ⣰⠋⠙⠁
⠈⣿⣻⣾⣦⣇⢸⣇⣀⣶⡿⠁⣀⣀⣾⢿⡇⢸ ⣟⡦⣧⣶⠏ unleashed
⠸⢿⡍⠛⠻⠿⠿⠿⠋⣠⡾⢋⣾⣏⣸⣷⡸⣇⢰⠟⠛⠻⡄ v1.22
⠸⢿⡍⠛⠻⠿⠿⠿⠋⣠⡾⢋⣾⣏⣸⣷⡸⣇⢰⠟⠛⠻⡄ v1.24
⢻⡄ ⠐⠚⠋⣠⡾⣧⣿⠁⠙⢳⣽⡟
⠈⠳⢦⣤⣤⣀⣤⡶⠛ ⠈⢿⡆ ⢿⡇
⠈ ⠈⠓ ⠈
Expand All @@ -46,24 +46,24 @@ Watch a reference for changes:
$ perl -Me -e 'my $v = {}; sub f1 { watch( $v ) } sub f2 { f1; $v->{a} = 1 } f2'

$ perl -Me -e '
package A {
use e;
my %h = ( aaa => 111 );
package A {
use e;
my %h = ( aaa => 111 );

watch(\%h);
watch(\%h);

sub f1 {
$h{b} = 1;
}
sub f1 {
$h{b} = 1;
}

sub f2 {
f1();
delete $h{aaa};
}
}
sub f2 {
f1();
delete $h{aaa};
}
}

A::f2();
'
A::f2();
'

Benchmark two snippets of code:

Expand Down Expand Up @@ -100,22 +100,22 @@ Devel::Peek dump a data structure:
Print data as a table:

$ perl -Me -e 'table( [qw(key value)], [qw(red 111)], [qw(blue 222)] )'
+------+-------+
| key | value |
+------+-------+
| red | 111 |
| blue | 222 |
+------+-------+
+------+-------+
| key | value |
+------+-------+
| red | 111 |
| blue | 222 |
+------+-------+

Encode/decode UTF-8:

$ perl -Me -e 'printf "%#X\n", ord for split //, enc "\x{5D0}"'
0XD7
0X90
0XD7
0X90

$ perl -C -Me -e 'say dec "\xD7\x90"'
$ perl -Me -e 'utf8; say dec "\xD7\x90"'
א
א

# DESCRIPTION

Expand Down Expand Up @@ -249,7 +249,7 @@ Convert YAML string to Perl object:

Encode UTF-8 code point to a byte stream:

$ perl -C -Me -e 'printf "%#X\n", ord for enc("\x{5D0}") =~ /./g'
$ perl -Me -e 'printf "%#X\n", ord for split //, enc "\x{5D0}"'
0XD7
0X90

Expand Down Expand Up @@ -303,6 +303,20 @@ Turn string into a [Mojo::File](https://metacpan.org/pod/Mojo%3A%3AFile) object.
Print with newline.

$ perl -Me -e 'say 123'
$ perl -Me -e 'say for 1..3'

Always sends output to the terminal even
when STDOUT and/or STDERR are redirected:

$ perl -Me -e '
close *STDOUT;
close *STDERR;
say 111;
print "999\n";
say 222;
'
111
222

### p

Expand All @@ -316,6 +330,15 @@ Return pretty printer data.

$ perl -Me -e 'my $v = np [1..3]; say "got: $v"'

Can be used with `say` to output to the terminal
(incase STDOUT/STDERR are redirected):

$ perl -Me -e '
close *STDOUT;
close *STDERR;
say np [ 1.. 3 ];
'

### d

Data dumper.
Expand All @@ -339,12 +362,12 @@ Color a string.
Print data as a table:

$ perl -Me -e 'table( [qw(key value)], [qw(red 111)], [qw(blue 222)] )'
+------+-------+
| key | value |
+------+-------+
| red | 111 |
| blue | 222 |
+------+-------+
+------+-------+
| key | value |
+------+-------+
| red | 111 |
| blue | 222 |
+------+-------+

Context sensitive!

Expand Down Expand Up @@ -405,6 +428,26 @@ Work with perl pod.

### import

\[Internal\] Imports the DSL into another package.

Can be used in a sub class to import this class
plus its own commands like this:

package e2;
use parent qw( e );

sub import {
my ( $class ) = @_;
my $class = caller;
$class->SUPER::import( $caller );
$class->can("monkey_patch")->(
$caller,
my_command_1 => sub {},
my_command_2 => sub {},
my_command_3 => sub {},
);
}

# AUTHOR

Tim Potapov, `<tim.potapov[AT]gmail.com>`
Expand Down
Loading

0 comments on commit e81f960

Please sign in to comment.