File Coverage

blib/lib/Devel/IntelliPerl/Editor/TextMate.pm
Criterion Covered Total %
statement 9 20 45.0
branch 0 4 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 29 44.8


line stmt bran cond sub pod time code
1             package Devel::IntelliPerl::Editor::TextMate;
2             our $VERSION = '0.04';
3              
4 1     1   28546 use Moose;
  1         580914  
  1         10  
5              
6 1     1   8277 use Exporter qw(import);
  1         3  
  1         34  
7 1     1   743 use Devel::IntelliPerl;
  1         3  
  1         366  
8              
9             extends 'Devel::IntelliPerl::Editor';
10              
11             our @EXPORT = qw(run);
12              
13             has editor => ( isa => 'Str', is => 'ro', default => 'TextMate' );
14              
15             sub run {
16 0     0 1   my ($self) = @_;
17 0           my @source;
18 0           my ( $line_number, $column, $filename ) = @ARGV;
19 0           push( @source, $_ ) while (<STDIN>);
20 0           my $ip = Devel::IntelliPerl->new(
21             line_number => $line_number,
22             column => $column + 1,
23             source => join( '', @source ),
24             filename => $filename
25             );
26 0           my @methods = $ip->methods;
27 0 0         if(@methods) {
    0          
28 0           print map {$_.$/} @methods;
  0            
29             } elsif (my $error = $ip->error) {
30 0           print '$error$The following error occured:'.$/.$error;
31             }
32 0           return;
33              
34             }
35              
36             __PACKAGE__->meta->make_immutable;
37              
38              
39             =head1 NAME
40              
41             Devel::IntelliPerl::Editor::TextMate - IntelliPerl integration for TextMate
42              
43             =head1 VERSION
44              
45             version 0.04
46              
47             =head1 SYNOPSIS
48              
49             #!/usr/bin/env ruby -wKU
50             require ENV["TM_SUPPORT_PATH"] + "/lib/ui.rb"
51             require ENV["TM_SUPPORT_PATH"] + "/lib/exit_codes.rb"
52              
53             out=`perl -MDevel::IntelliPerl::Editor::TextMate -e 'run' $TM_LINE_NUMBER $TM_LINE_INDEX "$TM_FILEPATH" 2>&1`
54              
55             if /^\$error\$/.match(out) then
56             out = out.sub("$error$", "")
57             TextMate.exit_show_tool_tip out
58             end
59              
60             choices = out.split("\n")
61             ENV['TM_CURRENT_WORD'] ||= ""
62              
63             if choices.size == 1 then
64             print choices.first.sub(ENV['TM_CURRENT_WORD'], "")
65             else
66             choice = TextMate::UI.menu(choices)
67             if choice then
68             print choices[choice].sub(ENV['TM_CURRENT_WORD'], "")
69             end
70             end
71              
72             Create a new Command in the Bundle Editor and paste this bash script. Set "Input" to B<Entire Document> and "Output" to B<Insert as Text>.
73             If you set "Scope Selector" to C<source.perl> this script is run only if you are editing a perl file.
74              
75             To run this command using a key set "Activation" to "Key Equivalent" and type the desired key in the box next to it.
76              
77             =head1 METHODS
78              
79             =head2 editor
80              
81             Set to C<TextMate>.
82              
83             =head2 run
84              
85             This method is exported and invokes L<Devel::IntelliPerl>.
86              
87             =head1 SEE ALSO
88              
89             L<http://macromates.com/>, L<Devel::IntelliSense>
90              
91             =head1 COPYRIGHT & LICENSE
92              
93             Copyright 2009 Moritz Onken, all rights reserved.
94              
95             This program is free software; you can redistribute it and/or modify it
96             under the same terms as Perl itself.
97              
98              
99             =cut