• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

author/H03-May-2022-9576

eg/H03-May-2022-7046

lib/Perl/PrereqScanner/H03-May-2022-768399

t/H03-May-2022-559436

xt/H07-May-2022-118

Build.PLH A D14-May-20151.6 KiB6646

ChangesH A D14-May-20151.5 KiB8143

LICENSEH A D14-May-201518 KiB379292

MANIFESTH A D14-May-2015937 4141

META.jsonH A D14-May-20152.6 KiB9796

META.ymlH A D14-May-20151.4 KiB5352

README.mdH A D14-May-20155 KiB13981

cpanfileH A D14-May-2015534 2521

minil.tomlH A D14-May-201566 32

README.md

1[![Build Status](https://travis-ci.org/moznion/Perl-PrereqScanner-Lite.svg?branch=master)](https://travis-ci.org/moznion/Perl-PrereqScanner-Lite) [![Coverage Status](https://img.shields.io/coveralls/moznion/Perl-PrereqScanner-Lite/master.svg)](https://coveralls.io/r/moznion/Perl-PrereqScanner-Lite?branch=master)
2# NAME
3
4Perl::PrereqScanner::Lite - Lightweight Prereqs Scanner for Perl
5
6# SYNOPSIS
7
8    use Perl::PrereqScanner::Lite;
9
10    my $scanner = Perl::PrereqScanner::Lite->new;
11    $scanner->add_extra_scanner('Moose'); # add extra scanner for moose style
12    my $modules = $scanner->scan_file('path/to/file');
13
14# DESCRIPTION
15
16Perl::PrereqScanner::Lite is the lightweight prereqs scanner for perl.
17This scanner uses [Compiler::Lexer](https://metacpan.org/pod/Compiler::Lexer) as tokenizer, therefore processing speed is really fast.
18
19# METHODS
20
21## new($opt)
22
23Create a scanner instance.
24
25`$opt` must be hash reference. It accepts following keys of hash:
26
27- extra\_scanners
28
29    It specifies extra scanners. This item must be array reference.
30
31    e.g.
32
33        my $scanner = Perl::PrereqScanner::Lite->new(
34            extra_scanners => [qw/Moose Version/]
35        );
36
37    See also ["add\_extra\_scanner($scanner\_name)"](#add_extra_scanner-scanner_name).
38
39- no\_prereq
40
41    It specifies to use `## no prereq` or not. Please see also ["ADDITIONAL NOTATION"](#additional-notation).
42
43## scan\_file($file\_path)
44
45Scan and figure out prereqs which is instance of `CPAN::Meta::Requirements` by file path.
46
47## scan\_string($string)
48
49Scan and figure out prereqs which is instance of `CPAN::Meta::Requirements` by source code string written in perl.
50
51e.g.
52
53    open my $fh, '<', __FILE__;
54    my $string = do { local $/; <$fh> };
55    my $modules = $scanner->scan_string($string);
56
57## scan\_module($module\_name)
58
59Scan and figure out prereqs which is instance of `CPAN::Meta::Requirements` by module name.
60
61e.g.
62
63    my $modules = $scanner->scan_module('Perl::PrereqScanner::Lite');
64
65## scan\_tokens($tokens)
66
67Scan and figure out prereqs which is instance of `CPAN::Meta::Requirements` by tokens of [Compiler::Lexer](https://metacpan.org/pod/Compiler::Lexer).
68
69e.g.
70
71    open my $fh, '<', __FILE__;
72    my $string = do { local $/; <$fh> };
73    my $tokens = Compiler::Lexer->new->tokenize($string);
74    my $modules = $scanner->scan_tokens($tokens);
75
76## add\_extra\_scanner($scanner\_name)
77
78Add extra scanner to scan and figure out prereqs. This module loads extra scanner such as `Perl::PrereqScanner::Lite::Scanner::$scanner_name` if specifying scanner name through this method.
79
80If you want to specify an extra scanner from external package without `Perl::PrereqScanner::Lite::` prefix, you can prepend `+` to `$scanner_name`. Like so `+Your::Awesome::Scanner`.
81
82Extra scanners that are default supported are followings;
83
84- [Perl::PrereqScanner::Lite::Scanner::Moose](https://metacpan.org/pod/Perl::PrereqScanner::Lite::Scanner::Moose)
85- [Perl::PrereqScanner::Lite::Scanner::Version](https://metacpan.org/pod/Perl::PrereqScanner::Lite::Scanner::Version)
86
87# ADDITIONAL NOTATION
88
89If `no_prereq` is enabled by `new()` (like so: `Perl::PrereqScanner::Lite->new({no_prereq => 1})`),
90this module recognize `## no prereq` optional comment. The requiring declaration with this comment on the same line will be ignored as prereq.
91
92For example
93
94    use Foo;
95    use Bar; ## no prereq
96
97In this case `Foo` is the prereq, however `Bar` is ignored.
98
99# SPEED COMPARISON
100
101## Plain
102
103                                Rate   Perl::PrereqScanner Perl::PrereqScanner::Lite
104    Perl::PrereqScanner       8.57/s                    --                      -97%
105    Perl::PrereqScanner::Lite  246/s                 2770%                        --
106
107## With Moose scanner
108
109                                Rate   Perl::PrereqScanner Perl::PrereqScanner::Lite
110    Perl::PrereqScanner       9.00/s                    --                      -94%
111    Perl::PrereqScanner::Lite  152/s                 1587%                        --
112
113# NOTES
114
115This is a quotation from [https://github.com/moznion/Perl-PrereqScanner-Lite/issues/13](https://github.com/moznion/Perl-PrereqScanner-Lite/issues/13).
116
117Yes, it's true. This design is so ugly and not smart.
118So I have to redesign and reimplement this module, and I have some plans.
119
120If you have a mind to expand this module by implementing external scanner,
121please be careful.
122Every `scan_*` calls must not affect to any others through the
123singleton of this module (called it `$c` in [https://github.com/moznion/Perl-PrereqScanner-Lite/blob/c03638b2e2a39d92f4d7df360af5a6be65dc417a/lib/Perl/PrereqScanner/Lite/Scanner/Moose.pm#L8](https://github.com/moznion/Perl-PrereqScanner-Lite/blob/c03638b2e2a39d92f4d7df360af5a6be65dc417a/lib/Perl/PrereqScanner/Lite/Scanner/Moose.pm#L8)).
124
125# SEE ALSO
126
127[Perl::PrereqScanner](https://metacpan.org/pod/Perl::PrereqScanner), [Compiler::Lexer](https://metacpan.org/pod/Compiler::Lexer)
128
129# LICENSE
130
131Copyright (C) moznion.
132
133This library is free software; you can redistribute it and/or modify
134it under the same terms as Perl itself.
135
136# AUTHOR
137
138moznion <moznion@gmail.com>
139