{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# cpanminus plugin\n", "\n", "Helpful addition to main class of [Devel::IPerl::Plugin::Perlbrew](https://metacpan.org/pod/Devel::IPerl::Plugin::Perlbrew)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "use feature 'say';\n", "IPerl->load_plugin('CpanMinus') unless IPerl->can('cpanm');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook uses the [Perlbrew](https://metacpan.org/pod/Devel::IPerl::Plugin::Perlbrew) plugin, so familiarity with the use of that plugin is assumed." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "lib 'perl-5.26.0@cpanm-test' is created.\n", " perl-5.26.0 (installed on Wed Jan 31 21:11:06 2018)\n", "* perl-5.26.0@cpanm-test\n" ] }, { "data": { "text/plain": [ "0" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# setting up a temporary library for this notebook\n", "IPerl->perlbrew_domain('/tmp');\n", "IPerl->perlbrew_lib_create('cpanm-test');\n", "IPerl->perlbrew('cpanm-test');\n", "IPerl->perlbrew_list();" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Installing dependencies\n", "\n", "The `cpanm_installdeps` helper is useful for installing the dependencies of modules." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "IPerl->cpanm_installdeps('Mojo::Collection::Role::UtilsBy');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Installing modules\n", "\n", "The modules themselves can be installed using the `cpanm` helper. It exposes the full functionality of `cpanm`." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Successfully installed Mojo-Collection-Role-UtilsBy-0.001\n", "1 distribution installed\n" ] } ], "source": [ "IPerl->cpanm('Mojo::Collection::Role::UtilsBy');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### check installation\n", "\n", "Slightly roundabout." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 192 modules installed.\n" ] }, { "data": { "text/plain": [ "Mojo::Collection::Role::UtilsBy\n", "MooseX::Role::Parameterized\n", "Role::Tiny" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" }, { "ename": "Warning", "evalue": "Attempting to create directory /tmp/libs/perl-5.26.0@cpanm-test\n", "output_type": "error", "traceback": [ "Attempting to create directory /tmp/libs/perl-5.26.0@cpanm-test\n" ] } ], "source": [ "use Mojo::File;\n", "use Mojo::Collection 'c';\n", "IPerl->perlbrew_list_modules('modules.list');\n", "c(split /\\n/, Mojo::File->new('modules.list')->slurp)\n", " ->tap(sub { say join ' ', \"There are\", $_->size, \"modules installed.\"; })\n", " ->grep(qr/Role/)->join(\"\\n\");" ] } ], "metadata": { "kernelspec": { "display_name": "IPerl 0.009", "language": "perl", "name": "iperl" }, "language_info": { "file_extension": ".pl", "mimetype": "text/x-perl", "name": "perl", "version": "5.26.0" } }, "nbformat": 4, "nbformat_minor": 2 }