Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance #89

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9ee3149
s/Perl6/Raku/ in README
Altai-man Jan 12, 2020
d9e6b35
Update extensions
Altai-man Jan 12, 2020
4c45b00
Remove broken and unused module
Altai-man Jan 12, 2020
d4fda22
Rename runner and fix some issues
Altai-man Jan 12, 2020
85255ea
Draft out a new TODO
Altai-man Jan 12, 2020
f91f413
Make runner code more idiomatic
Altai-man Jan 12, 2020
c91a62f
Fix single category case
Altai-man Jan 12, 2020
407a5b9
Improve example
Altai-man Jan 12, 2020
2df0bec
Rename and skip (for now) interactive example
Altai-man Jan 12, 2020
da0578c
Replace two outdated examples with a single working one
Altai-man Jan 12, 2020
b8b7db5
Unlink a file after creation so that it doesn't mess up with vcs
Altai-man Jan 12, 2020
f2e28ef
Ignore interactive script
Altai-man Jan 12, 2020
b581600
More renaming and ignoring
Altai-man Jan 12, 2020
179b890
Even more renaming
Altai-man Jan 12, 2020
3c89368
Add some more files to longrunners section
Altai-man Jan 26, 2020
e3567b5
Fix instructions and rename a file
Altai-man Jan 26, 2020
de55fda
s/Mojo/Cro/
Altai-man Jan 26, 2020
4327ff6
Use newer rakudo
Altai-man Jan 26, 2020
e2df01f
Add .cro.yml config for Cro
Altai-man Mar 8, 2020
0b14926
Raku-ify footer
Altai-man Mar 8, 2020
fce5314
Fix channel name
Altai-man Mar 14, 2020
6e8c209
Raku-fy makefile
Altai-man Mar 14, 2020
18005e0
Use proper extensions
Altai-man Mar 14, 2020
27d294c
Minor style tweaks
Altai-man Mar 14, 2020
d3b35ca
Add info for incomplete examples
Altai-man Mar 14, 2020
259b48d
Great +x changes
Altai-man Mar 14, 2020
a30d3da
Revive links to docs
Altai-man Mar 14, 2020
6668952
More Raku-ifying
Altai-man Mar 14, 2020
d05e924
More Raku-ifying
Altai-man Mar 14, 2020
3e7d4da
More Cro-ifying
Altai-man Apr 8, 2020
36094c1
Extensions renaming, round 1
Altai-man Apr 12, 2020
06cdb38
Add fresh results
Altai-man Apr 12, 2020
10c76b0
Extensions renaming, round 2
Altai-man Apr 12, 2020
553f334
Extensions renaming, round 3
Altai-man Apr 12, 2020
c3b6fcc
Extensions renaming, round 4
Altai-man Apr 12, 2020
86a60c3
Add util script to validate examples
Altai-man Apr 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 15 additions & 0 deletions .cro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
env: []
endpoints:
-
protocol: http
id: http
host-env: EXAMPLES_HOST
name: HTTP
port-env: EXAMPLES_PORT
id: test
name: test
links: []
cro: 1
entrypoint: service.p6
...
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ language: perl6

perl6:
- latest
- '2018.06'
- '2019.11'

install:
- rakudobrew build zef
Expand Down
63 changes: 39 additions & 24 deletions META6.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
{
"perl" : "6.*",
"name" : "perl6-examples",
"version" : "0.0.1",
"auth" : "github:perl6",
"license" : "Artistic-2.0",
"description" : "Many examples of Perl 6 code",
"depends" : [ "URI", "Pod::To::HTML", "LWP::Simple", "Algorithm::Soundex",
"DBIish", "File::Find", "File::Temp", "Text::VimColour",
"HTTP::Easy", "Terminal::ANSIColor", "Web::Request", "HTML::Escape",
"Term::termios" ],
"test-depends" : [ "Test", "Test::META" ],
"source-url" : "git://github.com/perl6/perl6-examples.git",
"provides" : {
"Examples" : "lib/Examples.pm",
"Examples::Categories" : "lib/Examples/Categories.pm",
"Examples::Example" : "lib/Examples.pm",
"Text::Levenshtein" : "lib/Text/Levenshtein.pm",
"Pod6" : "lib/Pod/Parser.pm",
"Pod6Block" : "lib/Pod/Parser.pm",
"Context" : "lib/Pod/Parser.pm",
"Pod::Parser" : "lib/Pod/Parser.pm",
"Pod::To::Perl" : "lib/Pod/To/Perl.pm"
}
}
"name": "perl6-examples",
"description": "Many examples of Raku code",
"version": "0.0.1",
"perl": "6.*",
"auth": "github:Raku",
"depends": [
"URI",
"Pod::To::HTML",
"LWP::Simple",
"Algorithm::Soundex",
"DBIish",
"File::Find",
"File::Temp",
"HTTP::Easy",
"Terminal::ANSIColor",
"Web::Request",
"HTML::Escape",
"Term::termios",
"Cro::HTTP",
"Cro::WebApp",
"Terminal::Spinners"
],
"test-depends": [
"Test",
"Test::META"
],
"provides": {
"Context": "lib/Pod/Parser.pm",
"Examples": "lib/Examples.pm",
"Examples::Categories": "lib/Examples/Categories.pm",
"Examples::Example": "lib/Examples.pm",
"Pod6": "lib/Pod/Parser.pm",
"Pod6Block": "lib/Pod/Parser.pm",
"Pod::Parser": "lib/Pod/Parser.pm",
"Pod::To::Perl": "lib/Pod/To/Perl.pm"
},
"license": "Artistic-2.0",
"source-url": "git://github.com/perl6/perl6-examples.git"
}
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ help:

html: install-deps
@echo "*** Generating HTML pages ***"
perl6 htmlify.pl
raku -Ilib htmlify.p6

html-nohighlight: install-deps
html-nohighlight:
@echo "*** Generating HTML pages (without syntax highlighting) ***"
perl6 htmlify.pl --no-highlight
raku -Ilib htmlify.p6 --no-highlight

run-all: install-deps
perl6 bin/run-examples.pl
run-all:
raku bin/run-examples.raku

web-server:
perl app.pl daemon
cro run .

test: install-deps
prove --exec perl6 -r t
test:
prove --exec raku -r t

install-deps:
@echo "*** Installing dependencies ***"
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Raku Examples

[![Build Status](https://travis-ci.org/perl6/perl6-examples.svg?branch=master)](https://travis-ci.org/perl6/perl6-examples)
[![Build Status](https://travis-ci.org/Raku/examples.svg?branch=master)](https://travis-ci.org/Raku/examples)

This is intended to be a repository for all kinds of Raku examples.

Expand All @@ -11,11 +11,11 @@ If an example needs an implementation specific version then it should end in
on Rakudo, it should end in .rakudo.

If you want to contribute, just ask! The quicker choice is to use IRC:
[join `#raku` on `irc.freenode.net`](https://webchat.freenode.net/?channels=#raku-dev>)
[join `#raku` on `irc.freenode.net`](https://webchat.freenode.net/?channels=#raku>)
and you'll be welcome.

Please use POD6 (mostly this template
https://github.com/perl6/perl6-examples/blob/master/doc/example-template.pl) when
https://github.com/Raku/examples/blob/master/doc/example-template.pl) when
adding a new example.

## Goals
Expand Down Expand Up @@ -52,7 +52,7 @@ adding a new example.
|tutorial | Tutorial examples |
|wsg | Answers for Winter Scripting Games |

Since you have a commit-bit (if not then talk to the folks at #perl6 on
Since you have a commit-bit (if not then talk to the folks at #raku on
irc.freenode.net) feel free to commit your changes to the main repository.
No need to submit a pull request!

Expand All @@ -62,7 +62,7 @@ To run all examples and tests, a number of modules need to be installed.

These are listed in `META6.json`.

They can be installed via [`zef`](https://modules.perl6.org/dist/zef):
They can be installed via [`zef`](https://modules.raku.org/dist/zef):

$ zef --depsonly install .

Expand All @@ -72,7 +72,7 @@ To run most examples (all examples excluding those which take a very long
time or are memory hogs) one can use the `run-examples.pl` script in the
`bin` directory:

$ perl6 bin/run-examples.pl
$ raku bin/run-examples.pl

or simply via the `run-all` target of the Makefle:

Expand All @@ -83,7 +83,7 @@ use the `--category=<category-dir>` option specifying the desired category's
directory name. For example, to run the examples for the `cookbook`
category, use the following:

$ perl6 bin/run-examples.pl --category=cookbook
$ raku bin/run-examples.pl --category=cookbook

## Building the examples documentation

Expand All @@ -93,15 +93,15 @@ To build the examples documentation web pages, simply run

or you can run the `htmlify.p6` script in the base directory:

$ perl6 htmlify.p6
$ raku -Ilib htmlify.p6

After the pages have been generated, you can view them on your local
computer by starting the included `app.pl` program:
computer by starting the included `service.p6` program:

$ perl app.pl daemon
$ raku service.p6

You can then view the examples documentation by pointing your web browser at
http://localhost:3000.
http://localhost:20000.

## License Information

Expand Down
3 changes: 0 additions & 3 deletions TODO

This file was deleted.

3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [x] Ensure run-examples runs without errors
- [ ] Update extensions
- [ ] Revise website generation
25 changes: 0 additions & 25 deletions app.pl

This file was deleted.

Empty file modified bin/rpn1
100644 → 100755
Empty file.
Empty file modified bin/rpn2
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion bin/rpn3
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/local/bin/perl6
#!/usr/bin/env perl6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there those two files above?


use v6;

# FROM: http://daniel.ruoso.com/categoria/perl/rpn-calculator-perl6 by [email protected]
Expand Down
52 changes: 20 additions & 32 deletions bin/run-examples.pl → bin/run-examples.raku
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,37 @@

=head1 NAME

run-all-examples.pl - run all current Perl 6 examples
run-all-examples.pl - run all current Raku examples

=head1 SYNOPSIS

$ perl6 run-all-examples.pl [--category=<category-name>]
$ raku run-all-examples.pl [--category=<category-name>]

=head1 DESCRIPTION

A script to run all current Perl 6 examples in the C<perl6-examples>
A script to run all current Raku examples in the C<examples>
repository and print their output. This is useful to check if the examples
compile and/or work as expected.

=end pod

use File::Find;

my @categories = qw{
99-problems
best-of-rosettacode
cookbook
euler
interpreters
module-management
parsers
perlmonks
rosalind
shootout
tutorial
wsg
};

# skip interactive examples; need to work out how to pass input data to
# interactive examples
my @interactive-examples = qw{
01-read-from-terminal.pl
15-05-get-char.p6
24-game.pl
balanced-brackets.pl
create-a-two-dimensional-array-at-runtime.pl
event10-dwhipp.p6
event005-eric256.pl
event008-eric256.pl
event008-j1n3l0.pl
16-18-catch-control-c.p6
19-01cgi-script.p6
calc.p6
};

# skip memory hogs
Expand All @@ -59,10 +48,13 @@ =head1 DESCRIPTION
# skip long-running examples
my @long-runners = qw{
prob010-polettix.pl
prob060-andreoss.pl
prob092-moritz.pl
prob104-moritz.pl
prob149-shlomif.pl
prob189-shlomif.pl
prob039-quinny.pl
prob284-shlomif.p6
};

# skip examples requiring internet access
Expand All @@ -76,28 +68,24 @@ =head1 DESCRIPTION
lcsq-grondilu.pl
};

my @examples-to-skip = @interactive-examples,
@memory-hogs,
@long-runners,
@internet-required,
@shared-lib-required,
;
my @examples-to-skip = flat |@interactive-examples,
|@memory-hogs,
|@long-runners,
|@internet-required,
|@shared-lib-required;

sub MAIN (:$category) {
@categories = [$category] if $category;
my $base-dir = $*CWD;
my @categories = $category ?? ["categories/$category"] !! 'categories'.IO.dir.grep({ $_.basename !~~ 'games' });
for @categories -> $dir {
my @example-files = find(dir => "categories/" ~ $dir).grep(/<?!after 'p5'>.p(l|6)$/).sort;
my @example-files = find(:$dir, name => / <?!after 'p5'> .p(l|6) $ /).sort;
for @example-files -> $example {
my $example-dir = $example.dirname;
my $example-name = $example.basename;
next if grep $example-name, @examples-to-skip;
say $example-dir ~ "/" ~ $example-name;
chdir $example-dir;
qqx{perl6 $example-name}.say;
chdir $base-dir;
indir($example-dir, {
shell "$*EXECUTABLE.absolute() $example-name";
});
}
}
}

# vim: expandtab shiftwidth=4 ft=perl6
2 changes: 1 addition & 1 deletion categories/99-problems/99-problems.pod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=encoding utf8

=head1 99 Perl 6 Problems
=head1 99 Raku Problems

Based on an original Prolog problem list by Werner Hett
L<http://sites.google.com/site/prologsite/prolog-problems>.
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P01-scottp.pl → categories/99-problems/P01-scottp.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P01-topo.pl → categories/99-problems/P01-topo.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
2 changes: 2 additions & 0 deletions categories/99-problems/P02-scottp.pl → categories/99-problems/P02-scottp.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env perl6

use v6;

=begin pod
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P02-topo.pl → categories/99-problems/P02-topo.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P03-scottp.pl → categories/99-problems/P03-scottp.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P03-topo.pl → categories/99-problems/P03-topo.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P04-scottp.pl → categories/99-problems/P04-scottp.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
1 change: 1 addition & 0 deletions categories/99-problems/P04-topo.pl → categories/99-problems/P04-topo.raku
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env perl6
use v6;

=begin pod
Expand Down
Loading