1 | package VineLinux::VSS::Type::Elisp; |
---|
2 | |
---|
3 | use base qw( VineLinux::VSS::Type ); |
---|
4 | |
---|
5 | use VineLinux::VSS::Skeleton::Elisp::InitEl; |
---|
6 | use VineLinux::VSS::Skeleton::Elisp::Spec; |
---|
7 | use VineLinux::VSS::Skeleton::Elisp::InstallSh; |
---|
8 | use VineLinux::VSS::Skeleton::Elisp::RemoveSh; |
---|
9 | use VineLinux::VSS::Skeleton::Elisp::VineDefaultEl; |
---|
10 | |
---|
11 | sub generate { |
---|
12 | my $class = shift; |
---|
13 | my $vss = shift; |
---|
14 | |
---|
15 | my $filename = ''; |
---|
16 | my @skeleton_data; |
---|
17 | my $tmpl; |
---|
18 | |
---|
19 | my %params = ( |
---|
20 | package_name => $vss->package_name, |
---|
21 | packager_fullname => $vss->packager_fullname, |
---|
22 | packager_name => $vss->packager_name, |
---|
23 | packager_email => $vss->packager_email, |
---|
24 | generate_date => $class->_current_time |
---|
25 | ); |
---|
26 | |
---|
27 | # <package>-init.el |
---|
28 | @skeleton_data = <VineLinux::VSS::Skeleton::Elisp::InitEl::DATA>; |
---|
29 | $tmpl = HTML::Template->new(arrayref => \@skeleton_data, |
---|
30 | die_on_bad_params => 0); |
---|
31 | $tmpl->param(\%params); |
---|
32 | $filename = $vss->package_name . '-init.el'; |
---|
33 | $class->_generate_file($filename, $tmpl->output); |
---|
34 | |
---|
35 | |
---|
36 | # vine-default-<package>.el |
---|
37 | @skeleton_data = <VineLinux::VSS::Skeleton::Elisp::VineDefaultEl::DATA>; |
---|
38 | $tmpl = HTML::Template->new(arrayref => \@skeleton_data, |
---|
39 | die_on_bad_params => 0); |
---|
40 | $tmpl->param(\%params); |
---|
41 | $filename = 'vine-default-' . $vss->package_name . '.el'; |
---|
42 | $class->_generate_file($filename, $tmpl->output); |
---|
43 | |
---|
44 | |
---|
45 | # <package>.spec |
---|
46 | @skeleton_data = <VineLinux::VSS::Skeleton::Elisp::Spec::DATA>; |
---|
47 | $tmpl = HTML::Template->new(arrayref => \@skeleton_data, |
---|
48 | die_on_bad_params => 0); |
---|
49 | $tmpl->param(\%params); |
---|
50 | $filename = $vss->package_name . '.spec'; |
---|
51 | $class->_generate_file($filename, $tmpl->output); |
---|
52 | |
---|
53 | |
---|
54 | # <package>-install.sh |
---|
55 | @skeleton_data = <VineLinux::VSS::Skeleton::Elisp::InstallSh::DATA>; |
---|
56 | $tmpl = HTML::Template->new(arrayref => \@skeleton_data, |
---|
57 | die_on_bad_params => 0); |
---|
58 | $tmpl->param(\%params); |
---|
59 | $filename = $vss->package_name . '-install.sh'; |
---|
60 | $class->_generate_file($filename, $tmpl->output); |
---|
61 | |
---|
62 | |
---|
63 | # <package>-remove.sh |
---|
64 | @skeleton_data = <VineLinux::VSS::Skeleton::Elisp::RemoveSh::DATA>; |
---|
65 | $tmpl = HTML::Template->new(arrayref => \@skeleton_data, |
---|
66 | die_on_bad_params => 0); |
---|
67 | $tmpl->param(\%params); |
---|
68 | $filename = $vss->package_name . '-remove.sh'; |
---|
69 | $class->_generate_file($filename, $tmpl->output); |
---|
70 | } |
---|
71 | |
---|
72 | sub _current_time { |
---|
73 | my $class = shift; |
---|
74 | my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time); |
---|
75 | |
---|
76 | my $e_mon = sprintf("%s", |
---|
77 | ("Jan", "Feb", "Mar", "Apr", "May", "Jun", |
---|
78 | "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$mon]); |
---|
79 | my $e_week = sprintf("%s", |
---|
80 | ("Sun", "Mon", "Tue", "Wed", "The", "Fri", "Sat")[$wday]); |
---|
81 | |
---|
82 | return sprintf("%s %s %02d %04d", $e_week, $e_mon, $mday, $year + 1900); |
---|
83 | } |
---|
84 | |
---|
85 | 1; |
---|
86 | |
---|
87 | |
---|