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-03-03 Nuno Martins Nuno Martins [1099a2] Distribution dependencies point to distributions
Readme.md 2014-03-04 Nuno Martins Nuno Martins [ee3870] Merge remote-tracking branch 'opensourceproject...
test-modules.pl 2014-02-18 Nuno Martins Nuno Martins [1201d5] Merge branch 'develop'

Read Me

Perl Modules Extractor

Perl Modules Extractor is a tool to report which Perl Distributions and dependencies exist in a specific machine. That can be accomplished through several methods. Our apporach doesn't need to change any previously written code, therefore it uses Perl mechanisms to infer Perl Modules requirements.
The output format is JSON, the result will be the key result. That result has the key data, which is an array with all distributions and theirs dependencies. This will enable the converter to create a dependency graph.

 

Distribution specific package Manager vs CPAN(m/p)

To install Perl Distributions 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].

 

Usage Preconditions

Perl Modules Requirements

Devel::Modlist

File::Find::Rule

JSON

MetaCPAN::API

Moose

UUID::Tiny

 

Requirements Installion

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

 

It is recommended to install JSON::XS to have a better JSON graphical visualization.

1
cpanp install JSON::XS

 

Development and testing has been performed on a x86_64 Linux environment with Perl v5.14.

 

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

 

How to get the code ?

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

 

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 output.json content is the same as output_pretty.json, the latter is recommended for human readability.

 


 

Output Description

Output Ontology

Link to the output ontology

Generated Concepts and Properties

Bullet point list of generated ontology concepts and properties

Mapping to TIMBUS DIO

Link to mapping file

 

Use Cases

Use Case 1

Describe here how to use the extractor show excerpt of sample output or screenshots etc here.

 

Use Case Phaidra

 

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.