LispPerl/CoreBindings.pm

filter: Statementstmt 73.6% 28 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 10 totaltotal 61.6% 37 / 60 CC 1 SCAR 2.2
CC
1
Cov
74%
readlines
2.0
file_exists
2.0
use_lib
2.0
CRAP 1.2
« LispPerl/Logger.pm ↑ Summary LispPerl.pm »
1 package Language::LispPerl::CoreBindings;
2 6 $Language::LispPerl::CoreBindings::VERSION = '0.007';
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Language::LispPerl::CoreBindings - Perl functions binded from core.clp or file.clp
9  
10 =head1 SYNOPSIS
11  
12 =head2 In lisp:
13  
14 (require "core.clp")
15 ( println (. env "USER") )
16  
17 =cut
18  
19 # Preloaded methods go here.
20  
21 # file
22 2 ▶sub print {
Subroutine print: called CC=1 SCAR=0.0
Pod undocumented
23 2 print @_;
24 }
25  
26 3 ▶sub openfile {
Subroutine openfile: called CC=1 SCAR=0.0
Pod undocumented
27 3 my $file = shift;
28 3 my $cb = shift;
29 3 my $fh;
30 3 open $fh, $file;
31 3 &{$cb}($fh);
32 3 close $fh;
33 }
34  
35 2 ▶sub puts {
Subroutine puts: called CC=1 SCAR=0.0
Pod undocumented
36 2 my $fh = shift;
37 2 my $str = shift;
38 2 print $fh $str;
39 }
40  
41 1 ▶sub readline {
Subroutine readline: called CC=1 SCAR=0.0
Pod undocumented
42 1 my $fh = shift;
43 1 return <$fh>;
44 }
45  
46 0 ▶sub readlines {
Subroutine readlines: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my $file = shift;
48 0 my $fh;
49 0 open $fh, "<$file";
50 0 my @lines = <$fh>;
51 0 close $fh;
52 0 return join( "\n", @lines );
53 }
54  
55 0 ▶sub file_exists {
Subroutine file_exists: not called CC=1 SCAR=6.9
Pod undocumented
56 0 my $file = shift;
57 0 return \( -e $file );
58 }
59  
60 # lib search path
61 0 ▶sub use_lib {
Subroutine use_lib: not called CC=1 SCAR=6.9
Pod undocumented
62 0 my $path = shift;
63 0 unshift @INC, $path;
64 }
65  
66 1 ▶sub gen_name {
Subroutine gen_name: called CC=1 SCAR=0.0
Pod undocumented
67 1 return "gen-" . rand;
68 }
69  
70 # regexp
71 4 ▶sub match {
Subroutine match: called CC=1 SCAR=0.0
Pod undocumented
72 4 my $regexp = shift;
73 4 my $str = shift;
74 4 my @m = ( $str =~ qr($regexp) );
75 4 return \@m;
76 }
77  
78 1 ▶sub get_env {
Subroutine get_env: called CC=1 SCAR=0.0
Pod undocumented
79 1 my $name = shift;
80 1 return $ENV{$name};
81 }
82  
83 6 1;
« LispPerl/Logger.pm ↑ Summary LispPerl.pm »