blib/lib/Text/Editor/Vip/Buffer/Plugins/File.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 1 / 1 totaltotal 95.6% 44 / 46 CC 2 SCAR 2.0
CC
2
Cov
95%
InsertFile
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Text/Editor/Vip/View/Plugins/WordCompletion.pm ↑ Summary blib/lib/Text/Editor/Vip/Buffer/Plugins/Case.pm »
1  
2 package Text::Editor::Vip::Buffer::Plugins::File;
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings ;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Text::Editor::Vip::CommandBlock ;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Text::Editor::Vip::Buffer::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 BEGIN
11 2 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Exporter ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 $VERSION = 0.01;
16 2 @ISA = qw (Exporter);
17 2 @EXPORT = qw ();
18 2 @EXPORT_OK = qw ();
19 2 %EXPORT_TAGS = ();
20 }
21  
22 =head1 NAME
23  
24 Text::Editor::Vip::Buffer::Plugins::File - File handling plugin for Vip::Buffer
25  
26 =head1 SYNOPSIS
27  
28 use Text::Editor::Vip::Plugins::File
29
30 =head1 DESCRIPTION
31  
32 This modules adds File reading and wrtting capability to Vip::Buffer
33  
34 =head1 FUNCTIONS
35  
36 =cut
37  
38 #---------------------------------------------------------------------------
39  
40 sub InsertFile
41 2 ▶{
Subroutine InsertFile: called CC=2 SCAR=7.0
Pod documented
42  
43 =head2 InsertFile
44  
45 Inserts a file at the current modification position.
46  
47 =cut
48  
49 2 my $buffer = shift ;
50 2 my $a_file_name = shift ;
51  
52 2 my $undo_block = new Text::Editor::Vip::CommandBlock($buffer, "# InsertFile('$a_file_name')", ' ', "# undo for InsertFile('$a_file_name')", ' ') ;
53  
54 2 my $file_read_ok = 0 ;
55  
56 2 ▶if(open(SOURCE_CODE, "<", $a_file_name))
Branch: 1 branch
BranchTrueFalseTotal
if (open SOURCE_CODE, '<', $a_file_name) { } 2 0 2
57 {
58 2 my @text = <SOURCE_CODE> ;
59 2 close(SOURCE_CODE) ;
60
61 2 $buffer->Insert(\@text, NO_SMART_INDENTATION) ;
62 2 $file_read_ok = 1 ;
63 }
64 else
65 {
66 0 $buffer->PrintError("Can't open $a_file_name : $!") ;
67 }
68  
69 2 return($file_read_ok) ;
70 }
71  
72 #---------------------------------------------------------------------------
73  
74 2 1 ;
75  
76 =head1 AUTHOR
77  
78 Khemir Nadim ibn Hamouda
79 CPAN ID: NKH
80 mailto:nadim@khemir.net
81 http:// no web site
82  
83 =head1 COPYRIGHT
84  
85 This program is free software; you can redistribute
86 it and/or modify it under the same terms as Perl itself.
87  
88 The full text of the license can be found in the
89 LICENSE file included with this module.
90  
91 =cut
« blib/lib/Text/Editor/Vip/View/Plugins/WordCompletion.pm ↑ Summary blib/lib/Text/Editor/Vip/Buffer/Plugins/Case.pm »