File Coverage

blib/lib/App/PS1/Plugin/Node.pm
Criterion Covered Total %
statement 9 17 52.9
branch 0 6 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 28 46.4


line stmt bran cond sub pod time code
1             package App::PS1::Plugin::Node;
2              
3             # Created on: 2011-06-21 09:48:47
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 1     1   1112 use strict;
  1         3  
  1         32  
10 1     1   6 use warnings;
  1         2  
  1         31  
11 1     1   5 use English qw/ -no_match_vars /;
  1         2  
  1         6  
12              
13             our $VERSION = 0.08;
14             our @EXPORT_OK = qw//;
15             our %EXPORT_TAGS = ();
16              
17             sub node {
18 0     0 1   my ($self, $options) = @_;
19 0           my $version;
20             my $path;
21              
22 0 0         if ( $path = $ENV{NVM_BIN} ) {
    0          
23             # best guess for nvm
24 0           ($version) = $path =~ m{/([^/]+)/bin};
25             }
26             elsif ( $path = $ENV{NODE_PATH} ) {
27             # best guess for nave
28 0           ($version) = $path =~ /installed.(.*?).lib/;
29             }
30             else {
31 0           return;
32             }
33              
34 0 0         return if !$version;
35              
36 0           return $self->surround( 5 + length $version, $self->colour('branch_label') . 'node ' . $self->colour('branch') . $version );
37             }
38              
39             1;
40              
41             __END__
42              
43             =head1 NAME
44              
45             App::PS1::Plugin::Node - Shows current version of node if using nave
46              
47             =head1 VERSION
48              
49             This documentation refers to App::PS1::Plugin::Node version 0.08.
50              
51             =head1 SYNOPSIS
52              
53             use App::PS1::Plugin::Node;
54              
55             # Brief but working code example(s) here showing the most common usage(s)
56             # This section will be as far as many users bother reading, so make it as
57             # educational and exemplary as possible.
58              
59              
60             =head1 DESCRIPTION
61              
62             =head1 SUBROUTINES/METHODS
63              
64             =head2 C<node ()>
65              
66             Determines the current version of C<nodejs> if using C<nave> or C<nvm>.
67              
68             =head1 DIAGNOSTICS
69              
70             =head1 CONFIGURATION AND ENVIRONMENT
71              
72             =head1 DEPENDENCIES
73              
74             =head1 INCOMPATIBILITIES
75              
76             =head1 BUGS AND LIMITATIONS
77              
78             There are no known bugs in this module.
79              
80             Please report problems to Ivan Wills (ivan.wills@gmail.com).
81              
82             Patches are welcome.
83              
84             =head1 AUTHOR
85              
86             Ivan Wills - (ivan.wills@gmail.com)
87              
88             =head1 LICENSE AND COPYRIGHT
89              
90             Copyright (c) 2011 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
91             All rights reserved.
92              
93             This module is free software; you can redistribute it and/or modify it under
94             the same terms as Perl itself. See L<perlartistic>. This program is
95             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
96             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
97             PARTICULAR PURPOSE.
98              
99             =cut