blib/lib/Vim/X/Line.pm

filter: Statementstmt 20.7% 11 / 53 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 15.0% 3 / 20 Podpod 87.5% 7 / 8 totaltotal 21.6% 21 / 97 SCAR 40.4
CC
9
Cov
16%
_search
30.0
__ANON__
6.0
content
6.0
CRAP 57.1
« blib/lib/Vim/X.pm ↑ Summary blib/lib/Vim/X/Range.pm »
1 package Vim::X::Line;
2 BEGIN {
3 5 ▶ $Vim::X::Line::AUTHORITY = 'cpan:YANICK';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
5 # ABSTRACT: A line in a Vim buffer
6 5 $Vim::X::Line::VERSION = '1.1.0';
7 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 use overload
11 0 ▶ '""' => sub { $_[0]->content },
Subroutine __ANON__: not called CC=1 SCAR=6.9
12 0 ▶ 'eq' => sub { $_[0]->content eq $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
13 0 ▶ '<<=' => sub { $_[0]->content( $_[1] ) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 0 ▶ '0+' => sub { return $_[0]->index },
Subroutine __ANON__: not called CC=1 SCAR=6.9
15 0 ▶ '+' => sub { return $_[0]->index + $_[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
16 '<=>' => sub {
17 0 ▶ return $_[0]->index <=> (ref $_[1] ? $_[1]->index : $_[1])
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[1] ? : 0 0 0
18 },
19 5 ▶ ;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22  
23 5 has buffer => (
24 is => 'ro',
25 required => 1,
26 );
27  
28  
29 5 has 'index' => (
30 is => 'rw',
31 required => 1,
32 );
33  
34  
35 sub clone {
36 0 ▶ my $self = shift;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
37 0 return Vim::X::Line->new( buffer => $self->buffer, index => $self->index );
38 }
39  
40  
41 sub content {
42 0 ▶ my $self = shift;
Subroutine content: not called CC=2 SCAR=17.9
Pod documented
43 0 ▶ $self->buffer->set_line( $self->index, map { split "\n" } @_ ) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
44 0 return $self->buffer->lines_content( $self->index );
45 }
46  
47  
48 sub append {
49 0 ▶ my( $self, @lines ) = @_;
Subroutine append: not called CC=1 SCAR=6.9
Pod documented
50 0 $self->buffer->append( $self->index, @lines );
51 }
52  
53  
54  
55 sub dec {
56 0 ▶ my $self = shift;
Subroutine dec: not called CC=2 SCAR=17.9
Pod documented
57  
58 0 ▶ return if $self->index == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->index == 1 0 0 0
59  
60 0 $self->index( $self->index - 1 );
61 0 return $self;
62 }
63  
64  
65 sub inc {
66 0 ▶ my $self = shift;
Subroutine inc: not called CC=2 SCAR=17.9
Pod documented
67  
68 0 ▶ return if $self->index == $self->buffer->size;
Branch: 1 branch
BranchTrueFalseTotal
if $self->index == $self->buffer->size 0 0 0
69  
70 0 $self->index( $self->index + 1 );
71 0 return $self;
72 }
73  
74 sub _search {
75 0 ▶ my( $self, $direction, $condition ) = @_;
Subroutine _search: not called CC=5 SCAR=34.0
76  
77 0 my $target = $self->clone;
78  
79 0 ▶ my $it = $direction > 0 ? sub { $target->inc } : sub { $target->dec };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$direction > 0 ? : 0 0 0
80  
81 0 my $cond = $condition;
82 0 ▶ $cond = sub { $_[0]->content =~ $condition } if ref $condition eq 'Regexp';
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if ref $condition eq "Regexp" 0 0 0
83  
84 0 $_ = $target;
85 0 ▶ $it->() or return until $cond->($target);
Branch: 2 branches
BranchTrueFalseTotal
&$cond($target) or do { &$it() or return } 0 0 0
&$it() or return 0 0 0
86  
87 0 $self->index( $target->index );
88 0 return $self;
89 }
90  
91  
92 sub rewind {
93 0 ▶ my( $self, $condition ) = @_;
Subroutine rewind: not called CC=1 SCAR=6.9
Pod documented
94  
95 0 return $self->_search(-1,$condition);
96 }
97  
98  
99  
100 sub ff {
101 0 ▶ my( $self, $condition ) = @_;
Subroutine ff: not called CC=1 SCAR=6.9
Pod documented
102  
103 0 return $self->_search(1,$condition);
104 }
105  
106 sub map {
107 0 ▶ my( $self, $code ) = @_;
Subroutine map: not called CC=1 SCAR=6.9
Pod undocumented
108  
109 0 $_ = "$self";
110 0 my @values = $code->();
111 0 $self &= $values[0];
112
113 }
114  
115 5 1;
116  
117 __END__
« blib/lib/Vim/X.pm ↑ Summary blib/lib/Vim/X/Range.pm »