diff --git a/docs/commands.md b/docs/commands.md index 2eda14a7..1893dbc4 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -234,7 +234,9 @@ Display question details. With `-g`/`-l`/`-x`, the code template would be auto g * golang * java * javascript + * kotlin * mysql + * php * python * python3 * ruby @@ -465,7 +467,7 @@ Display version information. Short: $ leetcode version - 2.6.1 + 2.6.2 Verbose: @@ -475,7 +477,7 @@ Verbose: | | ___ ___| |_ ___ ___ __| | ___ | |/ _ \/ _ \ __|/ __|/ _ \ / _` |/ _ \ | | __/ __/ |_ (__| (_) | (_| | __/ - |_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.1 + |_|\___|\___|\__|\___|\___/ \__,_|\___| CLI v2.6.2 [Environment] Node v8.1.4 diff --git a/docs/releases.md b/docs/releases.md index 7b78a5f3..77cce5eb 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -2,6 +2,10 @@ layout: default title: Release Notes --- +# 2.6.2 +* `submit` + * fixes beta ratio issue + # 2.6.1 * `submit` * fixes 500 error on windows. diff --git a/lib/commands/stat.js b/lib/commands/stat.js index 3c51ab98..772499c4 100644 --- a/lib/commands/stat.js +++ b/lib/commands/stat.js @@ -104,7 +104,8 @@ function showGraph(problems) { for (let problem of problems) graph[problem.fid] = ICONS[problem.state] || ICONS.none; - let line = [sprintf(' %03s', 0)]; + let rowNumFormat = ' %04s'; + let line = [sprintf(rowNumFormat, 0)]; for (let i = 1, n = graph.length; i <= n; ++i) { // padding before group if (i % 10 === 1) line.push(' '); @@ -114,7 +115,7 @@ function showGraph(problems) { // time to start new row if (i % (10 * groups) === 0 || i === n) { log.info(line.join(' ')); - line = [sprintf(' %03s', i)]; + line = [sprintf(rowNumFormat, i)]; } } diff --git a/lib/commands/submit.js b/lib/commands/submit.js index 7376598b..56f5ed04 100644 --- a/lib/commands/submit.js +++ b/lib/commands/submit.js @@ -76,7 +76,7 @@ cmd.handler = function(argv) { let ratio = 0.0; for (let score of scores) { - if (parseFloat(score[0]) > myRuntime) + if (parseFloat(score[0]) >= myRuntime) ratio += parseFloat(score[1]); } diff --git a/lib/config.js b/lib/config.js index a427b8f3..373b9f0f 100644 --- a/lib/config.js +++ b/lib/config.js @@ -22,6 +22,7 @@ const DEFAULT_CONFIG = { 'javascript', 'kotlin', 'mysql', + 'php', 'python', 'python3', 'ruby', diff --git a/lib/helper.js b/lib/helper.js index c2085134..8806086e 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -39,6 +39,7 @@ const LANGS = [ {lang: 'javascript', ext: '.js', style: 'c'}, {lang: 'kotlin', ext: '.kt', style: 'c'}, {lang: 'mysql', ext: '.sql', style: '--'}, + {lang: 'php', ext: '.php', style: 'c'}, {lang: 'python', ext: '.py', style: '#'}, {lang: 'python3', ext: '.py', style: '#'}, {lang: 'ruby', ext: '.rb', style: '#'}, diff --git a/lib/plugins/leetcode.js b/lib/plugins/leetcode.js index 0ce3a66e..24331ec6 100644 --- a/lib/plugins/leetcode.js +++ b/lib/plugins/leetcode.js @@ -261,7 +261,13 @@ function formatResult(result) { x.expected_answer = result.expected_output; x.stdout = result.std_output; } else { - x.stdout = util.inspect((result.code_output || []).join('\n')); + if (typeof(result.code_output) === 'string') { + x.stdout = util.inspect(result.code_output); + } else if (Array.isArray(result.code_output)) { + x.stdout = util.inspect(result.code_output.join('\n')); + } else { + x.stdout = util.inspect(''); + } } // make sure we pass eveything! @@ -336,7 +342,7 @@ plugin.getSubmission = function(submission, cb) { let re = body.match(/submissionCode:\s('[^']*')/); if (re) submission.code = eval(re[1]); - re = body.match(/distribution_formatted:\s('[^']+')/); + re = body.match(/runtimeDistributionFormatted:\s('[^']+')/); if (re) submission.distributionChart = JSON.parse(eval(re[1])); return cb(null, submission); }); diff --git a/package.json b/package.json index ee8f2414..a9af9f7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "leetcode-cli", - "version": "2.6.1", + "version": "2.6.2", "description": "A cli tool to enjoy leetcode!", "preferGlobal": "true", "engines": { diff --git a/test/test_helper.js b/test/test_helper.js index 6eb6e106..143bda9e 100644 --- a/test/test_helper.js +++ b/test/test_helper.js @@ -128,12 +128,13 @@ describe('helper', function() { assert.equal(h.langToExt('java'), '.java'); assert.equal(h.langToExt('javascript'), '.js'); assert.equal(h.langToExt('mysql'), '.sql'); + assert.equal(h.langToExt('php'), '.php'); assert.equal(h.langToExt('python'), '.py'); assert.equal(h.langToExt('python3'), '.py'); assert.equal(h.langToExt('ruby'), '.rb'); + assert.equal(h.langToExt('rust'), '.rs'); assert.equal(h.langToExt('scala'), '.scala'); assert.equal(h.langToExt('swift'), '.swift'); - assert.equal(h.langToExt('rust'), '.rs'); }); }); // #langToExt @@ -146,13 +147,14 @@ describe('helper', function() { assert.equal(h.extToLang('../file.go'), 'golang'); assert.equal(h.extToLang('file.java'), 'java'); assert.equal(h.extToLang('c:/file.js'), 'javascript'); + assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql'); + assert.equal(h.extToLang('~/leetcode/hello.php'), 'php'); assert.equal(h.extToLang('c:/Users/skygragon/file.py'), 'python'); assert.equal(h.extToLang('~/file.rb'), 'ruby'); + assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust'); assert.equal(h.extToLang('/tmp/file.scala'), 'scala'); assert.equal(h.extToLang('~/leetcode/file.swift'), 'swift'); - assert.equal(h.extToLang('~/leetcode/../file.sql'), 'mysql'); assert.equal(h.extToLang('/home/skygragon/file.dat'), 'unknown'); - assert.equal(h.extToLang('~/leetcode/file.rs'), 'rust'); }); }); // #extToLang @@ -170,9 +172,11 @@ describe('helper', function() { assert.deepEqual(h.langToCommentStyle('java'), C_STYLE); assert.deepEqual(h.langToCommentStyle('javascript'), C_STYLE); assert.deepEqual(h.langToCommentStyle('mysql'), SQL_STYLE); + assert.deepEqual(h.langToCommentStyle('php'), C_STYLE); assert.deepEqual(h.langToCommentStyle('python'), RUBY_STYLE); assert.deepEqual(h.langToCommentStyle('python3'), RUBY_STYLE); assert.deepEqual(h.langToCommentStyle('ruby'), RUBY_STYLE); + assert.deepEqual(h.langToCommentStyle('rust'), C_STYLE); assert.deepEqual(h.langToCommentStyle('scala'), C_STYLE); assert.deepEqual(h.langToCommentStyle('swift'), C_STYLE); });