publishing a perl6 module

47
Publishing a Perl6 Module 2016/12/10 YAPC::Hokkaido LT astj

Upload: astj

Post on 16-Apr-2017

927 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Publishing a Perl6 Module

Publishing a Perl6 Module2016/12/10 YAPC::Hokkaido LT astj

Page 2: Publishing a Perl6 Module

astj (あさとじぇー) github @astj

Twitter @ast_j hatena id:astj

CPAN ASTJ

Page 3: Publishing a Perl6 Module

Perl 5

Scala

Golang

!

……and Perl 6 (personally!)

Page 4: Publishing a Perl6 Module
Page 5: Publishing a Perl6 Module

Modules in perl6

Page 6: Publishing a Perl6 Module

https://docs.perl6.org/language/modules.html

Page 7: Publishing a Perl6 Module

use v6;!!

unit module My::Module;!!

sub foo {!}!!

...!

Page 8: Publishing a Perl6 Module

Package manager

Page 9: Publishing a Perl6 Module

panda / zefhttps://github.com/tadzik/panda

https://github.com/ugexe/zef

Page 10: Publishing a Perl6 Module

$ 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

Page 11: Publishing a Perl6 Module

…from where?

Page 12: Publishing a Perl6 Module

panda install .

zef install \!git://github.com/ugexe/zef.git

zef install \!github:tony-o:CSV--Parser:0.1.2

panda install Task::Star

Page 13: Publishing a Perl6 Module

panda install .

zef install \!git://github.com/ugexe/zef.git

zef install \!github:tony-o:CSV--Parser:0.1.2

panda install Task::Star

Page 14: Publishing a Perl6 Module

ecosystem

Page 15: Publishing a Perl6 Module

https://modules.perl6.org

Page 16: Publishing a Perl6 Module

$ 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 <[email protected]>" ], "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" }}

Page 17: Publishing a Perl6 Module

{ "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" }}

Page 18: Publishing a Perl6 Module
Page 19: Publishing a Perl6 Module

Writing Modules

Page 20: Publishing a Perl6 Module

App::Mi6 is good!https://github.com/skaji/mi6

Page 21: Publishing a Perl6 Module

But I wrote one from scratch

Page 22: Publishing a Perl6 Module

SQL::NamedPlaceholderhttps://github.com/astj/p6-SQL-NamedPlaceholder

Perl6 port of SQL::NamedPlaceholder of Perl5 ref: https://github.com/cho45/SQL-NamedPlaceholder

Page 23: Publishing a Perl6 Module

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);

Page 24: Publishing a Perl6 Module

Write Perl6 code / tests

Page 25: Publishing a Perl6 Module

$ 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

Page 26: Publishing a Perl6 Module

Module Metadata

Page 27: Publishing a Perl6 Module

{! "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"! }

Page 28: Publishing a Perl6 Module

Testing Metadata

Page 29: Publishing a Perl6 Module

Test::METAhttps://github.com/jonathanstowe/Test-META

Page 30: Publishing a Perl6 Module

$ 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

Page 31: Publishing a Perl6 Module

Does it work?

Page 32: Publishing a Perl6 Module

local !

git

!

ecosystem

panda install .

panda install \!git://github.com/YOUR/MODULE.git

panda install YOUR::MODULE

Page 33: Publishing a Perl6 Module

local !

git

!

ecosystem

panda install .

panda install \!git://github.com/YOUR/MODULE.git

panda install YOUR::MODULE

Page 34: Publishing a Perl6 Module
Page 35: Publishing a Perl6 Module

Release

Page 36: Publishing a Perl6 Module

(1) push to github

Page 37: Publishing a Perl6 Module

(2) p-r to ecosystem

Page 38: Publishing a Perl6 Module

(3) 🎉 🎉 🎉 🎉 🎉 🎉 🎉

Page 39: Publishing a Perl6 Module
Page 40: Publishing a Perl6 Module

local !

git

!

ecosystem

panda install .

panda install \!git://github.com/YOUR/MODULE.git

panda install YOUR::MODULE

Page 41: Publishing a Perl6 Module

(Update)

Page 42: Publishing a Perl6 Module

(0) edit META

Page 43: Publishing a Perl6 Module

(1) push to github

Page 44: Publishing a Perl6 Module

(2) 🎉 🎉 🎉 🎉 🎉 🎉 🎉

Page 45: Publishing a Perl6 Module
Page 46: Publishing a Perl6 Module

Have Fun!

Page 47: Publishing a Perl6 Module

Thank you for listening!