File Coverage

lib/Devel/PerlySense/Editor/Emacs.pm
Criterion Covered Total %
statement 81 81 100.0
branch 4 4 100.0
condition n/a
subroutine 22 22 100.0
pod 2 3 66.6
total 109 110 99.0


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