-
Notifications
You must be signed in to change notification settings - Fork 1
/
Daikufile
64 lines (50 loc) · 1.51 KB
/
Daikufile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use Path::Tiny;
use Crypt::CBC;
use MIME::Base64;
use Git::Repository;
use Plack::Runner;
my $config = require './etc/config.pl';
my $CIPHER = Crypt::CBC->new(
-key => $config->{key},
-cipher => $config->{cipher}
);
namespace site => sub {
desc 'サイトをビルド';
task build => sub {
system 'riji publish';
};
desc 'ビルドしたサイトを表示';
task preview => sub {
my @options = (
'-MPlack::App::Directory',
'-e',
'Plack::App::Directory->new({root => "./blog"})'
);
my $runner = Plack::Runner->new;
$runner->parse_options(@options);
$runner->run;
};
desc '開発サーバ起動';
task server => sub {
system 'riji server';
};
};
namespace info => sub {
my $info_file = sub { return (sprintf "./tmp/info.%s", shift); };
desc 'アカウント情報表示';
task view => sub {
unless (-e $info_file->('crypted')) {
Git::Repository->run(clone => $config->{gist} => 'tmp');
}
print $CIPHER->decrypt(decode_base64(path($info_file->('crypted'))->slurp));
};
desc 'アカウント情報暗号化保存';
task create => sub {
if (-e $info_file->('crypted')) {
unlink $info_file->('crypted');
}
my $fh = path($info_file->('crypted'))->filehandle({ locked => 1 }, '>>');
print $fh encode_base64($CIPHER->encrypt(path($info_file->('txt'))->slurp));
close $fh;
};
};