forked from ISKU/BOJ-AutoCommit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.js
executable file
·115 lines (98 loc) · 3.15 KB
/
option.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
exports.commitMessage = function(info, userInfo) {
if (userInfo.hasOwnProperty('commitMessage'))
return replaceAll(userInfo.commitMessage, info.problemNumber, info.problemTitle);
return 'https://www.acmicpc.net/problem/' + info.problemNumber;
}
exports.sourceTree = function(problemNumber, userInfo) {
if (userInfo.hasOwnProperty('sourceTree')) {
if (userInfo.sourceTree.endsWith('/')) {
var sourceTree = userInfo.sourceTree.slice(0, userInfo.sourceTree.length - 1);
return sourceTree.replace(/\[NO\]/gi, problemNumber);
}
return userInfo.sourceTree.replace(/\[NO\]/gi, problemNumber);
}
return userInfo.repo;
}
exports.dirName = function(problemNumber, userInfo) {
if (userInfo.hasOwnProperty('dirName'))
return (userInfo.dirName.replace(/\[NO\]/gi, problemNumber)) + '/';
return problemNumber + '/';
}
exports.mkdir = function(problemNumber, userInfo) {
if (userInfo.hasOwnProperty('mkdir')) {
if (userInfo.mkdir)
return exports.dirName(problemNumber, userInfo);
else
return '';
}
return exports.dirName(problemNumber, userInfo);
}
exports.private = function(info, userInfo) {
if (userInfo.hasOwnProperty('private'))
if (userInfo.private && info.private)
return false;
return true;
}
exports.poll = function(userInfo) {
if (userInfo.hasOwnProperty('poll'))
return userInfo.poll;
return 600000;
}
exports.sourceName = function(problemNumber, language, userInfo) {
if (userInfo.hasOwnProperty('sourceName'))
return (userInfo.sourceName.replace(/\[NO\]/gi, problemNumber)) + getExt(language);
return problemNumber + getExt(language);
}
function replaceNumber(value, problemNumber) {
return value.replace(/\[NO\]/gi, problemNumber);
}
function replaceAll(value, problemNumber, problemTitle) {
return value.replace(/\[NO\]/gi, problemNumber).replace(/\[TITLE\]/gi, problemTitle);
}
function getExt(language) {
switch (language) {
case 'C': return '.c';
case 'C++': return '.cc';
case 'C++11': return '.cc';
case 'C++14': return '.cc';
case 'Java': return '.java';
case 'C11': return '.c';
case 'Python': return '.py';
case 'Python3': return '.py';
case 'PyPy': return '.py';
case 'PyPy3': return '.py';
case 'Ruby2.2': return '.rb';
case 'C#4.0': return '.cs';
case 'Text': return '.txt';
case 'Go': return '.go';
case 'F#': return '.fs';
case 'Pascal': return '.pas';
case 'Lua': return '.lua';
case 'Perl': return '.pl';
case 'C(Clang)': return '.c';
case 'C++11(Clang)': return '.cc';
case 'C++14(Clang)': return '.cc';
case 'Fortran': return '.f95';
case 'Scheme': return '.scm';
case 'Ada': return '.ada';
case 'awk': return '.awk';
case 'OCaml': return '.ml';
case 'Brainfuck': return '.bf';
case 'Whitespace': return '.ws';
case 'Tcl': return '.tcl';
case 'Assembly(32bit)': return '.asm';
case 'D': return '.d';
case 'Clojure': return '.clj';
case 'Rhino': return '.js';
case 'Cobol': return '.cob';
case 'SpiderMonkey': return '.js';
case 'Pike': return '.pike';
case 'sed': return '.sed';
case 'Rust': return '.rs';
case 'Intercal': return '.i';
case 'bc': return '.bc';
case 'VB.NET4.0': return '.vb';
case '아희': return '.aheui';
default: return '';
}
}