{"id":23552599,"url":"https://github.com/kiwiroy/devel-iperl-plugin-environmentmodules","last_synced_at":"2025-11-01T13:30:23.437Z","repository":{"id":56834793,"uuid":"120707183","full_name":"kiwiroy/Devel-IPerl-Plugin-EnvironmentModules","owner":"kiwiroy","description":null,"archived":false,"fork":false,"pushed_at":"2018-02-19T21:13:41.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-26T11:12:19.901Z","etag":null,"topics":["environment-modules","iperl","jupyter-notebook-extension","perl"],"latest_commit_sha":null,"homepage":"https://metacpan.org/pod/Devel::IPerl::Plugin::EnvironmentModules","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiwiroy.png","metadata":{"files":{"readme":"README.pod","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-08T03:45:08.000Z","updated_at":"2018-02-16T03:45:14.000Z","dependencies_parsed_at":"2022-09-02T03:40:37.023Z","dependency_job_id":null,"html_url":"https://github.com/kiwiroy/Devel-IPerl-Plugin-EnvironmentModules","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwiroy%2FDevel-IPerl-Plugin-EnvironmentModules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwiroy%2FDevel-IPerl-Plugin-EnvironmentModules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwiroy%2FDevel-IPerl-Plugin-EnvironmentModules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiwiroy%2FDevel-IPerl-Plugin-EnvironmentModules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiwiroy","download_url":"https://codeload.github.com/kiwiroy/Devel-IPerl-Plugin-EnvironmentModules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239293947,"owners_count":19615041,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["environment-modules","iperl","jupyter-notebook-extension","perl"],"created_at":"2024-12-26T11:12:21.199Z","updated_at":"2025-11-01T13:30:23.400Z","avatar_url":"https://github.com/kiwiroy.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"package Devel::IPerl::Plugin::EnvironmentModules;\n\nuse strict;\nuse warnings;\nuse Capture::Tiny ();\nuse Array::Diff ();\nuse Env::Modulecmd ();\nuse constant MODULECMD =\u003e $ENV{'PERL_MODULECMD'} || 'modulecmd';\n\nour $VERSION = '0.04';\n\nsub avail {\n  my @args = (MODULECMD, qw{perl avail});\n  my ($stderr, @result) = Capture::Tiny::capture_stderr { system { $args[0] } @args };\n  return $stderr;\n}\n\nsub load  {\n  shift-\u003e_env_diff(sub { local ($^W) = 1; Env::Modulecmd::_modulecmd('load', @_); }, @_);\n}\n\nsub list  {\n  my @args = (MODULECMD, qw{perl list});\n  my ($stderr, @result) = Capture::Tiny::capture_stderr { system { $args[0] } @args };\n  return $stderr;\n}\n\nsub list_array {\n  my $self  = shift;\n  my @lines = split m{\\n}, $self-\u003elist || '';\n  return [\n    grep { length }\n    map  { split m{(?:\\s*\\d+\\)\\s)} } @lines[1.. $#lines]\n    ];\n}\n\nsub new   { bless {}, ref($_[0]) || $_[0]; }\n\nsub register {\n    my ($class, $iperl) = @_;\n    my $self = $class-\u003enew;\n    for my $name(qw{avail load unload list list_array search show}) {\n      $iperl-\u003ehelper(\"module_$name\" =\u003e sub {\n          my ($ip, $ret) = (shift, -1);\n          return $ret if $name =~ /^(load|search|show|unload)$/ \u0026\u0026 @_ == 0;\n          my $cb = $self-\u003ecan($name);\n          return $ret unless $cb;\n          return $self-\u003e$cb(@_);\n      });\n    }\n    return 1;\n}\n\nsub search {\n  my ($self, $query) = @_;\n  my $regex = ref($query) eq 'Regexp' ? $query : qr{\\Q$query\\E};\n  my $hits  =\n    join $/ =\u003e sort { lc($a) cmp lc($b) }\n      grep { m/$regex/ } split m{(?:$/|\\s+)}, $self-\u003eavail || '';\n  return $hits || 'no match';\n}\n\nsub show {\n  shift;\n  my @args = (MODULECMD, qw{perl show}, @_);\n  my ($stderr, @result) = Capture::Tiny::capture_stderr { system { $args[0] } @args };\n  return $stderr;\n}\n\nsub unload {\n  shift-\u003e_env_diff(sub { local ($^W) = 1; Env::Modulecmd::_modulecmd('unload', @_); }, @_);\n}\n\n## like around, but explicitly called.\nsub _env_diff {\n  my ($self, $orig) = (shift, shift);\n  my %before = %ENV; # shallow copy\n\n  my $ret = $orig-\u003e(@_);\n\n  if (($before{PERL5LIB} || '') ne ($ENV{PERL5LIB} || '')) {\n    my $old = [ split /:/, $before{PERL5LIB} || '' ];\n    my $new = [ split /:/, $ENV{PERL5LIB}    || '' ];\n    my $ad  = Array::Diff-\u003enew;\n    $ad-\u003ediff($old, $new);\n    ## add or remove with lib\n    eval \"use lib q[$_];\" for (@{$ad-\u003eadded});\n    eval \"no lib q[$_];\" for (@{$ad-\u003edeleted});\n  }\n\n  return $ret;\n}\n\n1;\n\n=pod\n\n=head1 NAME\n\nDevel::IPerl::Plugin::EnvironmentModules - interact with L\u003cEnvironment Modules|http://modules.sourceforge.net\u003e in a L\u003cJupyter|https://jupyter.org/\u003e IPerl kernel\n\n=begin html\n\n\u003c!-- Travis --\u003e\n\u003ca href=\"https://travis-ci.org/kiwiroy/Devel-IPerl-Plugin-EnvironmentModules\"\u003e\n  \u003cimg src=\"https://travis-ci.org/kiwiroy/Devel-IPerl-Plugin-EnvironmentModules.svg?branch=master\"\n       alt=\"Build Status\" /\u003e\n\u003c/a\u003e\n\n\u003c!-- Coveralls --\u003e\n\u003ca href=\"https://coveralls.io/github/kiwiroy/Devel-IPerl-Plugin-EnvironmentModules?branch=master\"\u003e\n  \u003cimg src=\"https://coveralls.io/repos/github/kiwiroy/Devel-IPerl-Plugin-EnvironmentModules/badge.svg?branch=master\"\n       alt=\"Coverage Status\" /\u003e\n\u003c/a\u003e\n\n\u003c!-- Kritika --\u003e\n\u003ca href=\"https://kritika.io/users/kiwiroy/repos/6049167555239475/heads/master/\"\u003e\n  \u003cimg src=\"https://kritika.io/users/kiwiroy/repos/6049167555239475/heads/master/status.svg\"\n       alt=\"Kritika Analysis Status\" /\u003e\n\u003c/a\u003e\n\n\u003c!-- CPAN --\u003e\n\u003ca href=\"https://badge.fury.io/pl/Devel-IPerl-Plugin-EnvironmentModules\"\u003e\n  \u003cimg src=\"https://badge.fury.io/pl/Devel-IPerl-Plugin-EnvironmentModules.svg\"\n       alt=\"CPAN version\" /\u003e\n\u003c/a\u003e\n\n=end html\n\n=head1 DESCRIPTION\n\nA plugin to use when you have L\u003cenvironment modules|http://modules.sourceforge.net\u003e\nto work with.\n\nThe plugin is a wrapper for the L\u003cEnv::Modulecmd\u003e perl module.\n\n=head1 SYNOPSIS\n\n  IPerl-\u003eload_plugin('EnvironmentModules') unless IPerl-\u003ecan('module_load');\n  IPerl-\u003emodule_load('git');\n  IPerl-\u003emodule_unload('git');\n\n=head1 INSTALLATION AND REQUISITES\n\n=head1 IPerl Interface Method\n\n=head2 register\n\nCalled by C\u003c\u003c\u003c IPerl-\u003eload_plugin('EnvironmentModules') \u003e\u003e\u003e.\n\n=head1 REGISTERED METHODS\n\n=head2 module_avail\n\n  IPerl-\u003emodule_list;\n\nDisplay a list of environment modules that are available.\n\n=head2 module_list\n\n  IPerl-\u003emodule_list;\n\nDisplay the list of environment modules that are loaded.\n\n=head2 module_list_array\n\n  my $loaded = IPerl-\u003emodule_list_array;\n\nReturn an array reference to the list of loaded modules as returned by\nL\u003c/\"module_list\"\u003e.\n\n=head2 module_load\n\n  IPerl-\u003emodule_load('gcc');\n\nLoad a list of environment modules.\n\n=head2 module_search\n\n  IPerl-\u003emodule_search(qr/gcc/);\n  IPerl-\u003emodule_search('gcc');\n\nDisplay a list of matching modules. The query can either be a regular expression\nor a literal string.\n\n=head2 module_show\n\n  IPerl-\u003emodule_show('gcc');\n\nDisplay the environment modified by the given environment module.\n\n=head2 module_unload\n\n  IPerl-\u003emodule_unload('gcc');\n\nUnload a list of environment modules.\n\n=head1 INTERNAL METHODS\n\nNot for end user consumption.\n\n=head2 avail\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003eavail;\n\nA more longwinded C\u003c\u003c\u003c IPerl-\u003emodule_avail; \u003e\u003e\u003e.\n\n=head2 list\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003elist();\n\nA more longwinded C\u003c\u003c\u003c IPerl-\u003emodule_list; \u003e\u003e\u003e.\n\n=head2 list_array\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003elist_array();\n\nA more longwinded C\u003c\u003c\u003c IPerl-\u003emodule_list_array; \u003e\u003e\u003e.\n\n=head2 load\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003eload('gcc');\n\nA more longwinded C\u003c\u003c\u003c IPerl-\u003emodule_load; \u003e\u003e\u003e.\n\n=head2 new\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n\nCreate a new instance.\n\n=head2 search\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003esearch(qr/gcc/);\n  $p-\u003esearch('gcc');\n\n=head2 show\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003eshow('gcc');\n\nA more longwinded C\u003c\u003c\u003c IPerl-\u003emodule_show; \u003e\u003e\u003e.\n\n=head2 unload\n\n  my $p = Devel::IPerl::Plugin::EnvironmentModules-\u003enew();\n  $p-\u003eunload('gcc');\n\nA more longwinded C\u003c\u003c\u003c IPerl-\u003emodule_unload; \u003e\u003e\u003e.\n\n\n=head1 SEE ALSO\n\n=over 4\n\n=item L\u003cEnv::Modulecmd\u003e\n\n=item L\u003cDevel::IPerl\u003e\n\n=back\n\n=cut\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwiroy%2Fdevel-iperl-plugin-environmentmodules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiwiroy%2Fdevel-iperl-plugin-environmentmodules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiwiroy%2Fdevel-iperl-plugin-environmentmodules/lists"}