Skip to content

Commit

Permalink
Prepare for release as a Raku Community Module
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 17, 2024
1 parent 474233b commit 91e825d
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 61 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Revision history for URL::Find

{{$NEXT}}
- Initial version as a Raku Community Module
21 changes: 11 additions & 10 deletions META6.json
Original file line number Diff line number Diff line change
@@ -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"
}
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
Expand All @@ -31,9 +26,16 @@ Accepts a string and returns a list of URL's. Optionally you can specify a limit
AUTHOR
======

Samantha McVey (samcv) [email protected]
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.
11 changes: 11 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion example/example.p6 → example/example.raku
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use lib 'lib';
use URL::Find;

sub MAIN ( Str $string ) {
say $string;
say find-urls($string);
}

# vim: expandtab shiftwidth=4
39 changes: 30 additions & 9 deletions lib/URL/Find.pm6 → lib/URL/Find.rakumod
Original file line number Diff line number Diff line change
@@ -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] }
Expand All @@ -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) [email protected]
=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
66 changes: 66 additions & 0 deletions run-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
unit sub MAIN(:a($author), :i($install));

say run(<raku --version>, :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
6 changes: 3 additions & 3 deletions t/00-use.t → t/00-use.rakutest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!perl6
use Test;

plan 1;

use lib 'lib';
use-ok 'URL::Find';
done-testing;

# vim: expandtab shiftwidth=4
8 changes: 4 additions & 4 deletions t/01-url-find-unicode.t → t/01-url-find-unicode.rakutest
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,4 +20,5 @@ my @correct =
'http://παράδειγμα.δοκιμή/';

is find-urls($test-string), @correct, "Test finding Unicode URL's";
done-testing;

# vim: expandtab shiftwidth=4
8 changes: 4 additions & 4 deletions t/02-url-find-ascii.t → t/02-url-find-ascii.rakutest
Original file line number Diff line number Diff line change
@@ -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&,%
Expand All @@ -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
8 changes: 4 additions & 4 deletions t/03-url-find-quoted.t → t/03-url-find-quoted.rakutest
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Loading

0 comments on commit 91e825d

Please sign in to comment.