root/swish_website/Plugin/My/PathLocate.pm

Revision 1587, 0.7 kB (checked in by whmoseley, 4 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 package My::PathLocate;
2 use strict;
3 use base 'Template::Plugin';
4 use Config;
5 use File::Spec;
6
7
8 sub new {
9     my ( $class, $context ) = @_;
10
11     return bless { _CONTEXT => $context }, $class;
12
13 }
14
15 sub in_path {
16     my ( $self, $program ) = @_;
17
18     for my $dir  (split /$Config{path_sep}/, $ENV{PATH}) {
19         my $path = File::Spec->rel2abs( $program, $dir );
20         return $path if -x $path;
21     }
22     return;
23 }
24
25 sub swish_perl_lib {
26     my ( $self ) = @_;
27
28     my $lib = `swish-config --prefix`;
29
30     die "Failed to locate swish-config program in \$PATH"
31         unless $lib;
32
33     chomp $lib;
34
35     return File::Spec->catfile( $lib, qw[ lib swish-e perl ] );
36 }
37
38 1;
39
Note: See TracBrowser for help on using the browser.