Successfully reported this slideshow.
Your SlideShare is downloading. ×

Publishing a Perl6 Module

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 47 Ad

More Related Content

Slideshows for you (20)

Viewers also liked (15)

Advertisement

Similar to Publishing a Perl6 Module (20)

Recently uploaded (20)

Advertisement

Publishing a Perl6 Module

  1. 1. Publishing a Perl6 Module 2016/12/10 YAPC::Hokkaido LT astj
  2. 2. astj (あさとじぇー) github @astj Twitter @ast_j hatena id:astj CPAN ASTJ
  3. 3. Perl 5 Scala Golang ! ……and Perl 6 (personally!)
  4. 4. Modules in perl6
  5. 5. https://docs.perl6.org/language/ modules.html
  6. 6. use v6;! ! unit module My::Module;! ! sub foo {! }! ! ...!
  7. 7. Package manager
  8. 8. panda / zef https://github.com/tadzik/panda https://github.com/ugexe/zef
  9. 9. $ 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
  10. 10. …from where?
  11. 11. panda install . zef install ! git://github.com/ugexe/zef.git zef install ! github:tony-o:CSV--Parser:0.1.2 panda install Task::Star
  12. 12. panda install . zef install ! git://github.com/ugexe/zef.git zef install ! github:tony-o:CSV--Parser:0.1.2 panda install Task::Star
  13. 13. ecosystem
  14. 14. https://modules.perl6.org
  15. 15. $ 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" } }
  16. 16. { "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" } }
  17. 17. Writing Modules
  18. 18. App::Mi6 is good! https://github.com/skaji/mi6
  19. 19. But I wrote one from scratch
  20. 20. SQL::NamedPlaceholder https://github.com/astj/p6-SQL-NamedPlaceholder Perl6 port of SQL::NamedPlaceholder of Perl5 ref: https://github.com/cho45/SQL-NamedPlaceholder
  21. 21. 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);
  22. 22. Write Perl6 code / tests
  23. 23. $ 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
  24. 24. Module Metadata
  25. 25. {! "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"! }
  26. 26. Testing Metadata
  27. 27. Test::META https://github.com/jonathanstowe/Test-META
  28. 28. $ 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
  29. 29. Does it work?
  30. 30. local ! git ! ecosystem panda install . panda install ! git://github.com/YOUR/MODULE.git panda install YOUR::MODULE
  31. 31. local ! git ! ecosystem panda install . panda install ! git://github.com/YOUR/MODULE.git panda install YOUR::MODULE
  32. 32. Release
  33. 33. (1) push to github
  34. 34. (2) p-r to ecosystem
  35. 35. (3) 🎉 🎉 🎉 🎉 🎉 🎉 🎉
  36. 36. local ! git ! ecosystem panda install . panda install ! git://github.com/YOUR/MODULE.git panda install YOUR::MODULE
  37. 37. (Update)
  38. 38. (0) edit META
  39. 39. (1) push to github
  40. 40. (2) 🎉 🎉 🎉 🎉 🎉 🎉 🎉
  41. 41. Have Fun!
  42. 42. Thank you for listening!

×