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   8342 use strict;
  6         11  
  6         141  
15 6     6   18 use warnings;
  6         6  
  6         130  
16 6     6   490 use utf8;
  6         16  
  6         30  
17              
18             package Devel::PerlySense::Editor::Emacs;
19             $Devel::PerlySense::Editor::Emacs::VERSION = '0.0218';
20 6     6   217 use base "Devel::PerlySense::Editor";
  6         6  
  6         325  
21              
22              
23              
24              
25 6     6   25 use Spiffy -Base;
  6         7  
  6         26  
26 6     6   3045 use Data::Dumper;
  6     6   8  
  6     6   130  
  6         17  
  6         8  
  6         121  
  6         18  
  6         5  
  6         221  
27 6     6   22 use File::Basename;
  6         6  
  6         255  
28 6     6   19 use Graph::Easy;
  6         6  
  6         84  
29 6     6   17 use Text::Table;
  6         7  
  6         95  
30 6     6   16 use List::Util qw/ max first /;
  6         7  
  6         266  
31 6     6   20 use POSIX qw/ ceil /;
  6         11  
  6         32  
32 6     6   243 use Path::Class;
  6         7  
  6         198  
33              
34 6     6   20 use Devel::PerlySense;
  6         9  
  6         32  
35 6     6   1073 use Devel::PerlySense::Class;
  6         6  
  6         23  
36 6     6   920 use Devel::PerlySense::Util;
  6         7  
  6         240  
37 6     6   19 use Devel::PerlySense::Util::Log;
  6         7  
  6         172  
38 6     6   21 use Devel::PerlySense::Document::Api::Method;
  6         5  
  6         25  
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 7 sub formatOutputDataStructure {
56 3         9 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         6 my $keysValues = $self->formatOutputItem($rhData);
61              
62 3         13 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 9 sub formatOutputItem {
76 13         9 my ($value) = @_;
77              
78 13         12 my $output = "";
79 13 100       25 if(ref($value) eq "ARRAY") {
    100          
80 1         2 $output = "(" . join(" ", map { $self->formatOutputItem($_) } @$value) . ")"
  2         5  
81             }
82             elsif(ref($value) eq "HASH") {
83             $output = "(" . join(" ", map {
84 4         13 my $key = $_;
  8         7  
85 8         7 my $item_value = $value->{$_};
86 8         14 $item_value = $self->formatOutputItem($item_value);
87              
88 8         17 $key = $self->renameIdentifier($key);
89 8         9 $key = $self->escapeValue($key);
90              
91 8         21 qq|("$key" . $item_value)|;
92              
93             } sort keys %$value) . ")";
94             }
95             else {
96 8         10 $output = $self->escapeValue($value);
97 8         13 $output = qq|"$output"|;
98             }
99              
100 13         16 return $output;
101             }
102              
103              
104              
105              
106              
107             ###TODO: escape " and \ and fix newlines
108 16     16 0 9 sub escapeValue {
109 16         12 my ($value) = (@_);
110              
111 16         13 $value =~ s| ([\\"]) |\\$1|gsmx;
112              
113 16         13 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