diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..ab53183 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,26 @@ +name: Linux + +on: + push: + branches: + - '*' + tags-ignore: + - '*' + pull_request: + +jobs: + raku: + strategy: + matrix: + os: + - ubuntu-latest + raku-version: + - 'latest' + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: Raku/setup-raku@v1 + with: + raku-version: ${{ matrix.raku-version }} + - name: Run Special Tests + run: raku run-tests -i diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..de79738 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,26 @@ +name: MacOS + +on: + push: + branches: + - '*' + tags-ignore: + - '*' + pull_request: + +jobs: + raku: + strategy: + matrix: + os: + - macos-latest + raku-version: + - 'latest' + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: Raku/setup-raku@v1 + with: + raku-version: ${{ matrix.raku-version }} + - name: Run Special Tests + run: raku run-tests -i diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..557c8d5 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,26 @@ +name: Windows + +on: + push: + branches: + - '*' + tags-ignore: + - '*' + pull_request: + +jobs: + raku: + strategy: + matrix: + os: + - windows-latest + raku-version: + - 'latest' + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - uses: Raku/setup-raku@v1 + with: + raku-version: ${{ matrix.raku-version }} + - name: Run Special Tests + run: raku run-tests -i diff --git a/Changes b/Changes new file mode 100644 index 0000000..5533b2d --- /dev/null +++ b/Changes @@ -0,0 +1,4 @@ +Revision history for URL::Find + +{{$NEXT}} + - Initial version as a Raku Community Module diff --git a/META6.json b/META6.json index 84cdb6b..1918fb4 100644 --- a/META6.json +++ b/META6.json @@ -1,28 +1,29 @@ { + "auth": "github:samcv", "authors": [ "Samantha McVey" ], - "auth": "github:samcv", "build-depends": [ - ], "depends": [ - ], - "description": "Find all the URL's in text", + "description": "find all the URLs in a set of text", + "license": "Artistic-2.0", "name": "URL::Find", "perl": "6", "provides": { - "URL::Find": "lib/URL/Find.pm6" + "URL::Find": "lib/URL/Find.rakumod" }, - "license": "Artistic-2.0", + "resources": [ + ], + "source-url": "https://github.com/raku-community-modules/URL-Find.git", "support": { - "license": "http://www.perlfoundation.org/artistic_license_2_0", - "bugtracker": "https://github.com/samcv/URL-Find/issues" + "bugtracker": "https://github.com/samcv/URL-Find/issues", + "license": "http://www.perlfoundation.org/artistic_license_2_0" }, - "source-url": "https://github.com/samcv/URL-Find.git", + "tags": [ + ], "test-depends": [ - ], "version": "0.2.2" } diff --git a/README.md b/README.md index 98e9f20..1426a7a 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,22 @@ -[![Build Status](https://travis-ci.org/samcv/URL-Find.svg?branch=master)](https://travis-ci.org/samcv/URL-Find) +[![Actions Status](https://github.com/raku-community-modules/URL-Find/actions/workflows/linux.yml/badge.svg)](https://github.com/raku-community-modules/URL-Find/actions) [![Actions Status](https://github.com/raku-community-modules/URL-Find/actions/workflows/macos.yml/badge.svg)](https://github.com/raku-community-modules/URL-Find/actions) [![Actions Status](https://github.com/raku-community-modules/URL-Find/actions/workflows/windows.yml/badge.svg)](https://github.com/raku-community-modules/URL-Find/actions) -TITLE -===== +NAME +==== -URL::Find - -SUBTITLE -======== - -A Perl 6 module to find all the URL's in a set of text. +URL::Find - find all the URLs in a set of text DESCRIPTION =========== -By default it will match domain names that use unicode characters such as http://правительство.рф. To only match ASCII domains use the :ascii option. It will also find URL's that end in one of the restricted characters, so `https://www.google.com, ` will pull out `https://www.google.com`. It will find all the URL's in a text by default, or you can specify a maximum number with the :limit option. By default it will only find http, https, ftp, git and ssh schemes, but you can specify `:any<1>` to match any schemes with legal characters.. +By default it will match domain names that use unicode characters such as http://правительство.рф. To only match ASCII domains use the :ascii option. It will also find URL's that end in one of the restricted characters, so `https://www.google.com, ` will pull out `https://www.google.com`. It will find all the URL's in a text by default, or you can specify a maximum number with the :limit option. By default it will only find http, https, ftp, git and ssh schemes, but you can specify `:any<1>` to match any schemes with legal characters. ### sub find-urls -```perl6 +```raku sub find-urls( - Str $string, - Num :$limit is copy, - :$ascii, + Str $string, + Num :$limit is copy, + :$ascii, :$any ) returns List ``` @@ -31,9 +26,16 @@ Accepts a string and returns a list of URL's. Optionally you can specify a limit AUTHOR ====== -Samantha McVey (samcv) samantham@posteo.net +Samantha McVey + +Source can be located at: https://github.com/raku-community-modules/URL-Find . Comments and Pull Requests are welcome. + +COPYRIGHT AND LICENSE +===================== + +Copyright 2016 - 2018 Samantha McVey + +Copyright 2024 The Raku Community -LICENSE -======= +This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0. -This is free software; you can redistribute it and/or modify it under the Artistic License 2.0. diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..4746aa0 --- /dev/null +++ b/dist.ini @@ -0,0 +1,11 @@ +name = URL::Find + +[ReadmeFromPod] +filename = lib/URL/Find.rakumod + +[UploadToZef] + +[Badges] +provider = github-actions/linux.yml +provider = github-actions/macos.yml +provider = github-actions/windows.yml diff --git a/example/example.p6 b/example/example.raku similarity index 73% rename from example/example.p6 rename to example/example.raku index 23f5f21..d5b4645 100644 --- a/example/example.p6 +++ b/example/example.raku @@ -1,6 +1,8 @@ -use lib 'lib'; use URL::Find; + sub MAIN ( Str $string ) { say $string; say find-urls($string); } + +# vim: expandtab shiftwidth=4 diff --git a/lib/URL/Find.pm6 b/lib/URL/Find.rakumod similarity index 77% rename from lib/URL/Find.pm6 rename to lib/URL/Find.rakumod index 08ae6a6..a402da6 100644 --- a/lib/URL/Find.pm6 +++ b/lib/URL/Find.rakumod @@ -1,15 +1,20 @@ -use v6; -=TITLE URL::Find -=SUBTITLE A Perl 6 module to find all the URL's in a set of text. +=begin pod + +=head1 NAME + +URL::Find - find all the URLs in a set of text + =head1 DESCRIPTION -=para + By default it will match domain names that use unicode characters such as http://правительство.рф. To only match ASCII domains use the :ascii option. It will also find URL's that end in one of the restricted characters, so `https://www.google.com, ` will pull out `https://www.google.com`. It will find all the URL's in a text by default, or you can specify a maximum number with the :limit option. By default it will only find http, https, ftp, git and ssh schemes, but you can specify `:any<1>` to match any schemes -with legal characters.. +with legal characters. + +=end pod my token anyprotocol { <[ a..z A..Z ]> <[ a..z A..Z 0..9 . + - ]>+ } my token protocol {:i [http|https|ftp|git|ssh] } @@ -32,7 +37,23 @@ sub find-urls ( Str $string, Num :$limit? is copy, :$ascii?, :$any? ) is export $string.comb($url-regex, $limit).List; } -=AUTHOR Samantha McVey (samcv) samantham@posteo.net -=LICENSE -This is free software; you can redistribute it and/or modify it under -the Artistic License 2.0. +=begin pod + +=head1 AUTHOR + +Samantha McVey + +Source can be located at: https://github.com/raku-community-modules/URL-Find . +Comments and Pull Requests are welcome. + +=head1 COPYRIGHT AND LICENSE + +Copyright 2016 - 2018 Samantha McVey + +Copyright 2024 The Raku Community + +This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0. + +=end pod + +# vim: expandtab shiftwidth=4 diff --git a/run-tests b/run-tests new file mode 100644 index 0000000..565dcf5 --- /dev/null +++ b/run-tests @@ -0,0 +1,66 @@ +unit sub MAIN(:a($author), :i($install)); + +say run(, :out).out.slurp.chomp; +say "Running on $*DISTRO.gist().\n"; + +say "Testing { + "dist.ini".IO.lines.head.substr(7) +}{ + " including author tests" if $author +}"; + +my @failed; +my $done = 0; + +sub process($proc, $filename) { + if $proc { + $proc.out.slurp; + } + else { + @failed.push($filename); + if $proc.out.slurp -> $stdout { + my @lines = $stdout.lines; + with @lines.first( + *.starts-with(" from gen/moar/stage2"),:k) + -> $index { + say @lines[^$index].join("\n"); + } + else { + say $stdout; + } + } + else { + say "No output received, exit-code $proc.exitcode() ($proc.signal()):\n$proc.os-error()"; + } + } +} + +sub install() { + my $zef := $*DISTRO.is-win ?? 'zef.bat' !! 'zef'; + my $proc := run $zef, "install", ".", "--verbose", "--/test", :out,:err,:merge; + process($proc, "*installation*"); +} + +sub test-dir($dir) { + for $dir.IO.dir(:test(*.ends-with: '.t' | '.rakutest')).map(*.Str).sort { + say "=== $_"; + my $proc := run "raku", "--ll-exception", "-I.", $_, :out,:err,:merge; + process($proc, $_); + $done++; + } +} + +test-dir("t"); +test-dir($_) for dir("t", :test({ !.starts-with(".") && "t/$_".IO.d})).map(*.Str).sort; +test-dir("xt") if $author && "xt".IO.e; +install if $install; + +if @failed { + say "\nFAILED: {+@failed} of $done:"; + say " $_" for @failed; + exit +@failed; +} + +say "\nALL {"$done " if $done > 1}OK"; + +# vim: expandtab shiftwidth=4 diff --git a/t/00-use.t b/t/00-use.rakutest similarity index 51% rename from t/00-use.t rename to t/00-use.rakutest index 166d80e..cf2d3a1 100644 --- a/t/00-use.t +++ b/t/00-use.rakutest @@ -1,7 +1,7 @@ -#!perl6 use Test; + plan 1; -use lib 'lib'; use-ok 'URL::Find'; -done-testing; + +# vim: expandtab shiftwidth=4 diff --git a/t/01-url-find-unicode.t b/t/01-url-find-unicode.rakutest similarity index 94% rename from t/01-url-find-unicode.t rename to t/01-url-find-unicode.rakutest index dfebf35..934947f 100644 --- a/t/01-url-find-unicode.t +++ b/t/01-url-find-unicode.rakutest @@ -1,9 +1,8 @@ -#!perl6 use Test; +use URL::Find; + plan 1; -use lib 'lib'; -use URL::Find; my $test-string = Q{ file://home/me/myfile.jpg @@ -21,4 +20,5 @@ my @correct = 'http://παράδειγμα.δοκιμή/'; is find-urls($test-string), @correct, "Test finding Unicode URL's"; -done-testing; + +# vim: expandtab shiftwidth=4 diff --git a/t/02-url-find-ascii.t b/t/02-url-find-ascii.rakutest similarity index 93% rename from t/02-url-find-ascii.t rename to t/02-url-find-ascii.rakutest index 1b2de96..10969b5 100644 --- a/t/02-url-find-ascii.t +++ b/t/02-url-find-ascii.rakutest @@ -1,9 +1,8 @@ -#!perl6 use Test; +use URL::Find; + plan 1; -use lib 'lib'; -use URL::Find; my $test-string = Q{http://www.com/commaæ, https://www.google.com/search?q=perl+6&oq=perl+6&aqs=chrome.0.69i59l3j69i60l3.742j0j1&sourceid=chrome&ie=UTF-8&,% @@ -16,4 +15,5 @@ my @correct = 'https://www.google.com/search?q=perl+6&oq=perl+6&aqs=chrome.0.69i59l3j69i60l3.742j0j1&sourceid=chrome&ie=UTF-8'; is find-urls($test-string, :ascii<1>), @correct, "Test finding only ASCII URL's"; -done-testing; + +# vim: expandtab shiftwidth=4 diff --git a/t/03-url-find-quoted.t b/t/03-url-find-quoted.rakutest similarity index 94% rename from t/03-url-find-quoted.t rename to t/03-url-find-quoted.rakutest index d2e75ca..352795d 100644 --- a/t/03-url-find-quoted.t +++ b/t/03-url-find-quoted.rakutest @@ -1,9 +1,8 @@ -#!perl6 use Test; +use URL::Find; + plan 1; -use lib 'lib'; -use URL::Find; my $test-string = Q{"http://www.com/commaæ", "https://www.google.com/search?q=perl+6&oq=perl+6&aqs=chrome.0.69i59l3j69i60l3.742j0j1&sourceid=chrome&ie=UTF-8" @@ -19,4 +18,5 @@ my @correct = 'http://παράδειγμα.δοκιμή/'; is find-urls($test-string), @correct, "Test finding single and double quoted URL's"; -done-testing; + +# vim: expandtab shiftwidth=4 diff --git a/t/04-url-any.t b/t/04-url-any.rakutest similarity index 94% rename from t/04-url-any.t rename to t/04-url-any.rakutest index 7022429..0b96145 100644 --- a/t/04-url-any.t +++ b/t/04-url-any.rakutest @@ -1,9 +1,8 @@ -#!perl6 use Test; +use URL::Find; + plan 1; -use lib 'lib'; -use URL::Find; my $test-string = Q{"file://home/me/myfile.jpg", "https://www.google.com/search?q=perl+6&oq=perl+6&aqs=chrome.0.69i59l3j69i60l3.742j0j1&sourceid=chrome&ie=UTF-8" @@ -19,4 +18,5 @@ my @correct = 'http://παράδειγμα.δοκιμή/'; is find-urls($test-string, :any<1>), @correct, "Test URL's with any scheme"; -done-testing; + +# vim: expandtab shiftwidth=4 diff --git a/t/05-non-lowercase-urls.t b/t/05-non-lowercase-urls.rakutest similarity index 94% rename from t/05-non-lowercase-urls.t rename to t/05-non-lowercase-urls.rakutest index fd2200a..ae9ebf2 100644 --- a/t/05-non-lowercase-urls.t +++ b/t/05-non-lowercase-urls.rakutest @@ -1,9 +1,8 @@ -#!perl6 use Test; +use URL::Find; + plan 1; -use lib 'lib'; -use URL::Find; my $test-string = Q{"FILE://home/me/myfile.jpg", "hTTPs://www.google.com/search?q=perl+6&oq=perl+6&aqs=chrome.0.69i59l3j69i60l3.742j0j1&sourceid=chrome&ie=UTF-8" @@ -18,4 +17,5 @@ my @correct = 'HtTp://παράδειγμα.δοκιμή/'; is find-urls($test-string), @correct, "Test finding mixed case URL's"; -done-testing; + +# vim: expandtab shiftwidth=4