git clone https://@opensourceprojects.eu/git/p/timbus/context-population/extractors/local/perl-modules timbus-context-population-extractors-local-perl-modules



File Date Author Commit
Modules 2014-02-24 Nuno Martins Nuno Martins [72ded4] Changing format using UUIDs
Readme.md 2014-02-21 Nuno Martins Nuno Martins [158616] [Readme.md] MetaCPAN API URL
test-modules.pl 2014-02-18 Nuno Martins Nuno Martins [1201d5] Merge branch 'develop'

Read Me

Perl Modules

Perl Module Extractor reports which Perl Distributions and dependencies exist in a specific machine.

 

Distribution specific package Manager vs CPAN(m/p)

To install Perl Distribution packages is necessary to have a Perl Distribution Manager. In Linux, the dificulty is which one to choose. The three Perl Distribution packages are CPAN, CPAN Minus and CPAN Plus. If we count with the Linux Package Managers we end up with many more. Linux Package Managers don't have all CPAN Perl Distributions, hence using them to install all your dependencies can be a dreadfull experience. CPAN, CPAN Minus and CPAN Plus, all download and install distributions from [REF].

 

Perl Modules Extractor Overview

Perl Modules Extractor has a well defined workflow, which is followed to give you a well formated report of which Perl Distributions exist on your system.
In the next paragraphs, each phase is explained briefly highlighting special key points to give you a broader insight of the tool.

 

Search Phase

During the first phase, Perl Module Extraction tool searches for files with extension "pm". When Perl searches for Modules it looks for them at specific folders. Those folders are pointed by a folder path array, which can be extracted by executing in a terminal:

1
perl -V

Folders can be added to this array by passing a -I "path" to perl executable, on each execution. Inside Perl Virtual Machine, programmatically it is also possible to change that folder path array, however that is not adviced.

Perl Modules Extraction tool to be faster and also capture all pm files, only searches "pm" files in that folder path array. Each "pm" file is added to an array which will be consumed by Acquisition phase.

 

Acquisition Phase

Through Acquisition phase each file, previously gathered in the Search phase, is scanned for dependencies. Each dependency is inserted, as a key, in a hashtable so that we don't end up with duplicates. After acquiring all module dependencies, the control is passed to the analysis phase.

 

Analysis Phase

Using the keys from dependency modules hashtable, one by one is checked to which Distribution it belongs to. This check is performed through MetaCPAN REST API, which is mapped into MetaCPAN::API Perl functions.

 

Reporting Phase

This module outputs each Distribution and its dependencies, that the tool found in the system through previous phases (find, acquisition and analysis).

 

Relation with Use Case Phaidra

 

How to get the code ?

1
git clone https://opensourceprojects.eu/git/p/timbus/context-population/extractors/local/perl-modules perl-modules

 

Perl Modules Requirements

Devel::Modlist

File::Find::Rule

JSON

MetaCPAN::API

Moose

 

Installion Requirements

1
2
3
4
cpanp install Devel::Modlist
cpanp install File::Find::Rule
cpanp install JSON
cpanp install Moose

 

It is recommended to install JSON::XS because it allows a better JSON graphical visualization.

1
cpanp install JSON::XS

 

How to Execute

1
perl test-modules.pl

 

Expected output

The Perl Modules output is JSON, and is printed in a single line. For a more visual comprehension is recommended to use the json_xs tool.

 

Example output

After a sucessfull Perl Information Extraction, is generated the file output.json. This file contains every information in a sigle line.

 

Better visualization

For a better information visualization, is recommended to install JSON::XS and use it as follow:

1
json_xs < output.json > output_pretty.json

Although the file output_pretty.json has the same content as output.json, it is recommended for human readability.

 

Author

Nuno Martins nuno.martins@caixamagica.pt

 

License

Copyright (c) 2014, Caixa Magica Software Lda (CMS).
The work has been developed in the TIMBUS Project and the above-mentioned are Members of the TIMBUS Consortium.
TIMBUS is supported by the European Union under the 7th Framework Programme for research and technological development and demonstration activities (FP7/2007-2013) under grant agreement no. 269940.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTIBITLY, or FITNESS FOR A PARTICULAR PURPOSE. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law or agreed to in writing, shall any Contributor be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work.
See the License for the specific language governing permissions and limitation under the License.