Skip to content

Commit 3f7eb3e

Browse files
committed
Add more testing modules
1 parent f516db6 commit 3f7eb3e

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

Local/MissingModule.pm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use strict;
2+
use warnings;
3+
4+
BEGIN {
5+
require Tie::Hash;
6+
$INC{'Tie/StdHash.pm'} = 1;
7+
8+
push @INC, sub {
9+
my ( undef, $module ) = @_;
10+
11+
$module =~ s/[.]pm$//;
12+
$module =~ s{/}{::}g;
13+
14+
die <<"END_DIE";
15+
You seem to be missing the $module module; please install it to run this
16+
script. If you have cpanminus, you can simply do this:
17+
18+
cpanm $module
19+
20+
END_DIE
21+
};
22+
}
23+
24+
1;

Local/VimColor.pm

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package Local::VimColor;
2+
3+
use strict;
4+
use warnings;
5+
6+
use File::Spec;
7+
use Text::VimColor;
8+
9+
{
10+
package TrueHash;
11+
use base 'Tie::StdHash';
12+
sub EXISTS { return 1 };
13+
}
14+
tie %Text::VimColor::SYNTAX_TYPE, 'TrueHash';
15+
16+
sub new {
17+
my ( $class, %params ) = @_;
18+
19+
my $lang = $params{'language'};
20+
21+
my $syntax_file = File::Spec->catfile('syntax', "$lang.vim");
22+
my $ftplugin_file = File::Spec->catfile('ftplugin', "$lang.vim");
23+
# XXX ???
24+
my $css_url = join('/', '..', '..', 't', 'vim_syntax.css');
25+
my $color_file = File::Spec->catfile('t', 'define_all.vim');
26+
27+
my $hilite = Text::VimColor->new(
28+
html_full_page => 1,
29+
html_inline_stylesheet => 0,
30+
html_stylesheet_url => $css_url,
31+
vim_options => [
32+
qw(-RXZ -i NONE -u NONE -U NONE -N -n), # for performance
33+
'+set nomodeline', # for performance
34+
'+set runtimepath=.', # don't consider system runtime files
35+
'+let perl_include_pod=1',
36+
"+source $ftplugin_file",
37+
"+source $syntax_file",
38+
"+source $color_file", # all syntax classes should be defined
39+
],
40+
);
41+
42+
return bless {
43+
hilite => $hilite,
44+
}, $class;
45+
}
46+
47+
sub color_file {
48+
my ( $self, $filename ) = @_;
49+
50+
return $self->{'hilite'}->syntax_mark_file($filename)->html;
51+
}
52+
53+
1;

0 commit comments

Comments
 (0)