File Coverage

lib/Devel/PerlySense/Editor/Vim.pm
Criterion Covered Total %
statement 82 82 100.0
branch 4 4 100.0
condition n/a
subroutine 22 22 100.0
pod 2 3 66.6
total 110 111 99.1


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             Devel::PerlySense::Editor::Vim - Integration with Vim
4              
5             =head1 DESCRIPTION
6              
7              
8             =cut
9              
10              
11              
12              
13              
14 1     1   5 use strict;
  1         1  
  1         58  
15 1     1   4 use warnings;
  1         1  
  1         28  
16 1     1   4 use utf8;
  1         1  
  1         8  
17              
18             package Devel::PerlySense::Editor::Vim;
19 1     1   36 use base "Devel::PerlySense::Editor";
  1         2  
  1         8  
20              
21              
22              
23              
24              
25 1     1   5 use Spiffy -Base;
  1         1  
  1         3  
26 1     1   544 use Data::Dumper;
  1     1   1  
  1     1   23  
  1         3  
  1         1  
  1         21  
  1         4  
  1         1  
  1         45  
27 1     1   5 use File::Basename;
  1         1  
  1         47  
28 1     1   3 use Graph::Easy;
  1         1  
  1         18  
29 1     1   3 use Text::Table;
  1         1  
  1         25  
30 1     1   3 use List::Util qw/ max first /;
  1         2  
  1         46  
31 1     1   4 use POSIX qw/ ceil /;
  1         1  
  1         5  
32 1     1   41 use Path::Class;
  1         1  
  1         41  
33              
34 1     1   4 use Devel::PerlySense;
  1         1  
  1         4  
35 1     1   191 use Devel::PerlySense::Class;
  1         1  
  1         6  
36 1     1   187 use Devel::PerlySense::Util;
  1         2  
  1         53  
37 1     1   3 use Devel::PerlySense::Util::Log;
  1         2  
  1         38  
38 1     1   4 use Devel::PerlySense::Document::Api::Method;
  1         1  
  1         6  
39              
40              
41              
42              
43              
44             =head1 PROPERTIES
45              
46             =head1 CLASS METHODS
47              
48             =head1 METHODS
49              
50             =head2 formatOutputDataStructure(rhData)
51              
52             Return stringification of $rhData suited for the Editor.
53              
54             =cut
55 3     3 1 3 sub formatOutputDataStructure {
56 3         7 my ($rhData) = Devel::PerlySense::Util::aNamedArg(["rhData"], @_);
57 3         7 my $keysValues = $self->formatOutputItem($rhData);
58 3         7 return $keysValues;
59             }
60              
61              
62              
63              
64              
65             =head2 formatOutputItem($item)
66              
67             Return stringification of $item suited for the Editor. $item can be a
68             scalar, array ref or hash ref.
69              
70             =cut
71 13     13 1 9 sub formatOutputItem {
72 13         11 my ($value) = @_;
73              
74 13         8 my $output = "";
75 13 100       24 if(ref($value) eq "ARRAY") {
    100          
76 1         1 $output = "[" . join(", ", map { $self->formatOutputItem($_) } @$value) . "]"
  2         5  
77             }
78             elsif(ref($value) eq "HASH") {
79 8         6 $output = "{" . join(", ", map {
80 4         12 my $key = $_;
81 8         6 my $item_value = $value->{$_};
82 8         12 $item_value = $self->formatOutputItem($item_value);
83              
84 8         12 $key = $self->renameIdentifier($key);
85 8         9 $key = $self->escapeValue($key);
86              
87 8         21 qq|"$key": $item_value|;
88              
89             } sort keys %$value) . "}";
90             }
91             else {
92 8         8 $output = $self->escapeValue($value);
93 8         10 $output = qq|"$output"|;
94             }
95              
96 13         20 return $output;
97             }
98              
99              
100              
101              
102              
103 16     16 0 13 sub escapeValue {
104 16         158 my ($value) = (@_);
105              
106 16         16 $value =~ s| ([\\"]) |\\$1|gsmx;
107 16         12 $value =~ s| \n |\\n|gsmx;
108              
109 16         20 return $value;
110             }
111              
112              
113              
114              
115              
116             1;
117              
118              
119              
120              
121              
122             __END__
123              
124             =encoding utf8
125              
126             =head1 AUTHOR
127              
128             Johan Lindström, C<< <johanl[ÄT]DarSerMan.com> >>
129              
130             =head1 BUGS
131              
132             Please report any bugs or feature requests to
133             C<bug-devel-perlysense@rt.cpan.org>, or through the web interface at
134             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Devel-PerlySense>.
135             I will be notified, and then you'll automatically be notified of progress on
136             your bug as I make changes.
137              
138             =head1 ACKNOWLEDGEMENTS
139              
140             =head1 COPYRIGHT & LICENSE
141              
142             Copyright 2005 Johan Lindström, All Rights Reserved.
143              
144             This program is free software; you can redistribute it and/or modify it
145             under the same terms as Perl itself.
146              
147             =cut