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