Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add initial Pod::Htmlify
This currently only exports url-munge(); more to come. Also added tests of url-munge().
- Loading branch information
Paul Cochrane
committed
Feb 20, 2015
1 parent
1b44b51
commit 85e24fa
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| module Pod::Htmlify; | ||
|
|
||
| use URI::Escape; | ||
|
|
||
| sub url-munge($_) is export { | ||
| return $_ if m{^ <[a..z]>+ '://'}; | ||
| return "/type/{uri_escape $_}" if m/^<[A..Z]>/; | ||
| return "/routine/{uri_escape $_}" if m/^<[a..z]>|^<-alpha>*$/; | ||
| # poor man's <identifier> | ||
| if m/ ^ '&'( \w <[[\w'-]>* ) $/ { | ||
| return "/routine/{uri_escape $0}"; | ||
| } | ||
| return $_; | ||
| } | ||
|
|
||
| # vim: expandtab shiftwidth=4 ft=perl6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| use v6; | ||
| use Test; | ||
| use lib 'lib'; | ||
|
|
||
| plan 2; | ||
|
|
||
| use_ok('Pod::Htmlify'); | ||
| use Pod::Htmlify; | ||
|
|
||
| subtest { | ||
| plan 7; | ||
|
|
||
| eval_dies_ok('use Pod::Htmlify; url-munge();', "requires an argument"); | ||
| is(url-munge("http://www.example.com"), "http://www.example.com", | ||
| "plain url string with explicit protocol"); | ||
| is(url-munge("Class::Something"), "/type/Class%3A%3ASomething", | ||
| "type name input"); | ||
| is(url-munge("funky-routine"), "/routine/funky-routine", | ||
| "routine name input"); | ||
| is(url-munge('&stuff'), "/routine/stuff", "identifier (sub) input"); | ||
| is(url-munge("infix<+>"), "/routine/infix%3C%2B%3E", "operator input"); | ||
| is(url-munge('$*VAR'), '$*VAR', "sigil/twigil input"); | ||
| }, "url-munge"; | ||
|
|
||
| # vim: expandtab shiftwidth=4 ft=perl6 |