Skip to content

Commit 62603b4

Browse files
committed
Add default path for multifile gists
Also make it configurable.
1 parent 90c0b66 commit 62603b4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

config-default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
"archives-location" : "./data/builds",
88
"builds-location" : "/tmp/whateverable/",
9+
"sandbox-path" : "./sandbox",
910

1011
"moarvm" : "./data/moarvm",
1112

lib/Whateverable/Config.pm6

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ sub ensure-required-config-values {
3636
$CONFIG<source> //= There is no public repo yet!;
3737
$CONFIG<wiki> //= There is no documentation for me yet!;
3838
$CONFIG<default-stdin> //= ;
39+
$CONFIG<sandbox-path> //= ~$*TMPDIR.add(whateverable).add(sandbox);
3940
}
4041

4142
sub ensure-config($handle = $*IN) is export {

lib/Whateverable/Processing.pm6

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use HTTP::UserAgent;
2121

2222
use Whateverable::Bits;
2323
use Whateverable::Builds;
24+
use Whateverable::Config;
2425
use Whateverable::Running;
2526

2627
unit module Whateverable::Processing;
@@ -102,7 +103,7 @@ sub process-gist($url, $msg) is export {
102103
my %data = from-json $response.decoded-content;
103104
grumble Refusing to handle truncated gist if %data<truncated>;
104105

105-
sub path($filename) { sandbox/$filename.IO }
106+
sub path($filename) { $CONFIG<sandbox-path>/$filename.IO }
106107

107108
for %data<files>.values {
108109
grumble Invalid filename returned if .<filename>.contains: /|\0;
@@ -121,10 +122,11 @@ sub process-gist($url, $msg) is export {
121122
if .<truncated> {
122123
$score -= 100;
123124
grumble Can't handle truncated files yet; # TODO?
124-
} else {
125-
spurt $path, .<content>;
126125
}
127126

127+
mkdir $path.parent;
128+
spurt $path, .<content>;
129+
128130
if .<filename>.ends-with: .md | .markdown {
129131
for perl6, perl, -> $type {
130132
if .<content> ~~ /‘```’ $type \s* \n ~ ‘```’ (.+?) / {
@@ -142,7 +144,7 @@ sub process-gist($url, $msg) is export {
142144

143145
my $main-file = %scores.max(*.value).key;
144146
if $msg and %scores > 1 {
145-
$msg.reply: Using file “$main-file” as a main file, other files are placed in “sandbox/
147+
$msg.reply: Using file “$main-file” as a main file, other files are placed in “$CONFIG<sandbox-path>
146148
}
147149
path $main-file
148150
}

0 commit comments

Comments
 (0)