Publishing
a Perl6 Module
2016/12/10
YAPC::Hokkaido LT
astj
astj (あさとじぇー)
github @astj
Twitter @ast_j
hatena id:astj
CPAN ASTJ
Perl 5
Scala
Golang
!
……and Perl 6 (personally!)
Modules in perl6
https://docs.perl6.org/language/
modules.html
use v6;!
!
unit module My::Module;!
!
sub foo {!
}!
!
...!
Package manager
panda / zef
https://github.com/tadzik/panda
https://github.com/ugexe/zef
$ panda install SQL::NamedPlaceholder!
==> Fetching SQL::NamedPlaceholder!
==> Building SQL::NamedPlaceholder!
==> Testing SQL::NamedPlaceholder!
t/00-compile.t ..... ok!
t/01-basic.t ....... ok!
t/02-extend.t ...... ok!
t/03-array.t ....... ok!
t/04-name-id.t ..... ok!
t/05-exceptions.t .. ok!
t/99-meta.t ........ ok!
All tests successful.!
Files=7, Tests=58, 2 wallclock secs ( 0.03 usr
0.02 sys + 1.77 cusr 0.21 csys = 2.03 CPU)!
Result: PASS!
==> Installing SQL::NamedPlaceholder!
==> Successfully installed SQL::NamedPlaceholder
…from where?
panda install .
zef install !
git://github.com/ugexe/zef.git
zef install !
github:tony-o:CSV--Parser:0.1.2
panda install Task::Star
panda install .
zef install !
git://github.com/ugexe/zef.git
zef install !
github:tony-o:CSV--Parser:0.1.2
panda install Task::Star
ecosystem
https://modules.perl6.org
$ curl -s http://ecosystem-api.p6c.org/projects.json | jq '.[] | select( .provides | has("Monitor::Monit"))'	
{	
"resources": [],	
"support": {	
"source": "git://github.com/jonathanstowe/Monitor-Monit.git"	
},	
"tags": [	
"monitor",	
"api",	
"system"	
],	
"version": "0.0.1",	
"test-depends": [	
"Test",	
"CheckSocket"	
],	
"auth": "github:jonathanstowe",	
"license": "perl",	
"perl": "6.c",	
"meta6": "0",	
"name": "Monitor::Monit",	
"build-depends": [],	
"authors": [	
"Jonathan Stowe <jns+gh@gellyfish.co.uk>"	
],	
"description": "Provide an interface to the monit monitoring daemon",	
"depends": [	
"HTTP::UserAgent",	
"URI::Template",	
"XML::Class"	
],	
"source-url": "git://github.com/jonathanstowe/Monitor-Monit.git",	
"provides": {	
"Monitor::Monit": "lib/Monitor/Monit.pm"	
}	
}
{	
"resources": [],	
"support": {	
"source": "git://github.com/jonathanstowe/Monitor-Monit.git"	
},	
...	
"auth": "github:jonathanstowe",	
"license": "perl",	
"perl": "6.c",	
"meta6": "0",	
"name": "Monitor::Monit",	
...	
"depends": [	
"HTTP::UserAgent",	
"URI::Template",	
"XML::Class"	
],	
"source-url": "git://github.com/jonathanstowe/Monitor-Monit.git",	
"provides": {	
"Monitor::Monit": "lib/Monitor/Monit.pm"	
}	
}
Writing Modules
App::Mi6 is good!
https://github.com/skaji/mi6
But I wrote one
from scratch
SQL::NamedPlaceholder
https://github.com/astj/p6-SQL-NamedPlaceholder
Perl6 port of SQL::NamedPlaceholder of Perl5
ref: https://github.com/cho45/SQL-NamedPlaceholder
use SQL::NamedPlaceholder;!
!
my ($sql, $bind) = bind-named(q[!
SELECT *!
FROM entry!
WHERE!
user_id = :user_id!
], {!
user_id => $user_id!
});!
!
$dbh.prepare($sql).execute(|$bind);
Write Perl6 code / tests
$ tree ./!
./!
"## LICENSE!
"## META.info!
"## README.md!
"## lib!
$   %## SQL!
$   %## NamedPlaceholder.pm6!
%## t!
"## 00-compile.t!
"## 01-basic.t!
"## 02-extend.t!
"## 03-array.t!
"## 04-name-id.t!
"## 05-exceptions.t!
%## 99-meta.t!
!
3 directories, 11 files
Module Metadata
{!
"name": "SQL::NamedPlaceholder",!
"authors": [ "astj" ],!
"source-url": "ssh://(snip).git",!
"support": {!
"source": "ssh://(snip).git"!
},!
"perl": "6",!
"build-depends": [],!
"provides": {!
"SQL::NamedPlaceholder": "lib/SQL/NamedPlaceholder.pm6"!
},!
"depends": [],!
"test-depends": [!
"Test::META"!
],!
"description": "Perl6 port of p5 SQL::NamedPlaceholder",!
"version": "0.1.0"!
}
Testing Metadata
Test::META
https://github.com/jonathanstowe/Test-META
$ TEST_AUTHOR=1 prove -e 'perl6 -Ilib' -vr t/99-meta.t!
t/99-meta.t ..!
1..1!
ok 1 - have a META file!
ok 2 - META parses okay!
ok 3 - have all required entries!
ok 4 - 'provides' looks sane!
ok 5 - Optional 'authors' and not 'author'!
ok 6 - name has a hypen rather than '::' (if this is intentional
please pass :relaxed-name to meta-ok)!
ok 7 - no 'v' in version strings (meta6 version greater than 0)!
1..7!
ok 1 - Project META file is good!
ok!
All tests successful.!
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.27 cusr
0.04 csys = 0.33 CPU)!
Result: PASS
Does it work?
local
!
git
!
ecosystem
panda install .
panda install !
git://github.com/YOUR/MODULE.git
panda install YOUR::MODULE
local
!
git
!
ecosystem
panda install .
panda install !
git://github.com/YOUR/MODULE.git
panda install YOUR::MODULE
Release
(1) push to github
(2) p-r to ecosystem
(3) 🎉 🎉 🎉 🎉 🎉 🎉 🎉
local
!
git
!
ecosystem
panda install .
panda install !
git://github.com/YOUR/MODULE.git
panda install YOUR::MODULE
(Update)
(0) edit META
(1) push to github
(2) 🎉 🎉 🎉 🎉 🎉 🎉 🎉
Have Fun!
Thank you
for listening!

Publishing a Perl6 Module