diff --git a/CHANGES.rst b/CHANGES.rst index fb17ada..62bb4a3 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -9,6 +9,18 @@ Version 0.5 * Add ``coverage.json`` function. * Add ``coverage.lcov`` function. +* Improve ``language/vimscript`` module. + + * Add ``primula.annotate`` function. + * Add ``primula.combine`` function. + * Add ``primula.erase`` function. + * Add ``primula.html`` function. + * Add ``primula.json`` function. + * Add ``primula.lcov`` function. + * Add ``primula.report`` function. + * Add ``primula.run`` function. + * Add ``primula.xml`` function. + Version 0.4 ----------- diff --git a/doc/language/vimscript.rst b/doc/language/vimscript.rst index 59107c8..0019795 100644 --- a/doc/language/vimscript.rst +++ b/doc/language/vimscript.rst @@ -38,6 +38,70 @@ covimerage.xml(...args) ``covimerage.xml`` represents ``covimerage xml``. +vimscript.primula(...args) +-------------------------- + +``vimscript.primula`` represents ``primula``, and its commands are defined as +properties of this function. + +Requirements + - `Primula `_ + + +primula.annotate(...args) +~~~~~~~~~~~~~~~~~~~~~~~~~ + +``primula.annotate`` represents ``primula annotate``. + + +primula.combine(...args) +~~~~~~~~~~~~~~~~~~~~~~~~ + +``primula.combine`` represents ``primula combine``. + + +primula.erase(...args) +~~~~~~~~~~~~~~~~~~~~~~ + +``primula.erase`` represents ``primula erase``. + + +primula.html(...args) +~~~~~~~~~~~~~~~~~~~~~ + +``primula.html`` represents ``primula html``. + + +primula.json(...args) +~~~~~~~~~~~~~~~~~~~~~ + +``primula.json`` represents ``primula json``. + + +primula.lcov(...args) +~~~~~~~~~~~~~~~~~~~~~ + +``primula.lcov`` represents ``primula lcov``. + + +primula.report(...args) +~~~~~~~~~~~~~~~~~~~~~~~ + +``primula.report`` represents ``primula report``. + + +primula.run(...args) +~~~~~~~~~~~~~~~~~~~~ + +``primula.run`` represents ``primula run``. + + +primula.xml(...args) +~~~~~~~~~~~~~~~~~~~~ + +``primula.xml`` represents ``primula xml``. + + vimscript.themis(...args) ------------------------- diff --git a/lib/language/vimscript.js b/lib/language/vimscript.js index e7f0591..231cde3 100644 --- a/lib/language/vimscript.js +++ b/lib/language/vimscript.js @@ -1,7 +1,7 @@ // // aster :: language/vimscript.js // -// Copyright (c) 2017-2020 Akinori Hattori +// Copyright (c) 2017-2024 Akinori Hattori // // SPDX-License-Identifier: MIT // @@ -42,6 +42,56 @@ covimerage.xml = function() { return covimerage.apply(null, ['xml'].concat(Array.prototype.slice.call(arguments))); }; +var primula = exports.primula = function primula() { + if (!os.whence('primula')) { + aster.notify('failure', language.prefix + 'primula', 'primula not found!'); + return true; + } + + return language.system({ + args: ['primula'].concat(Array.prototype.slice.call(arguments)), + title: 'primula', + success: arguments[0] + ' passed', + failure: arguments[0] + ' failed', + }); +}; + +primula.annotate = function annotate() { + return primula.apply(null, ['annotate'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.combine = function combine() { + return primula.apply(null, ['combine'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.erase = function erase() { + return primula.apply(null, ['erase'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.html = function html() { + return primula.apply(null, ['html'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.json = function json() { + return primula.apply(null, ['json'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.lcov = function lcov() { + return primula.apply(null, ['lcov'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.report = function report() { + return primula.apply(null, ['report'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.run = function run() { + return primula.apply(null, ['run'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.xml = function xml() { + return primula.apply(null, ['xml'].concat(Array.prototype.slice.call(arguments))); +}; + exports.themis = function themis() { var script = 'themis'; if (!os.whence(script)) { diff --git a/std.go b/std.go index f7867f5..870690a 100644 --- a/std.go +++ b/std.go @@ -483,7 +483,7 @@ exports.rst2html = function rst2html(object) { "language/vimscript.js": []byte(`// // aster :: language/vimscript.js // -// Copyright (c) 2017-2020 Akinori Hattori +// Copyright (c) 2017-2024 Akinori Hattori // // SPDX-License-Identifier: MIT // @@ -524,6 +524,56 @@ covimerage.xml = function() { return covimerage.apply(null, ['xml'].concat(Array.prototype.slice.call(arguments))); }; +var primula = exports.primula = function primula() { + if (!os.whence('primula')) { + aster.notify('failure', language.prefix + 'primula', 'primula not found!'); + return true; + } + + return language.system({ + args: ['primula'].concat(Array.prototype.slice.call(arguments)), + title: 'primula', + success: arguments[0] + ' passed', + failure: arguments[0] + ' failed', + }); +}; + +primula.annotate = function annotate() { + return primula.apply(null, ['annotate'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.combine = function combine() { + return primula.apply(null, ['combine'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.erase = function erase() { + return primula.apply(null, ['erase'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.html = function html() { + return primula.apply(null, ['html'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.json = function json() { + return primula.apply(null, ['json'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.lcov = function lcov() { + return primula.apply(null, ['lcov'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.report = function report() { + return primula.apply(null, ['report'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.run = function run() { + return primula.apply(null, ['run'].concat(Array.prototype.slice.call(arguments))); +}; + +primula.xml = function xml() { + return primula.apply(null, ['xml'].concat(Array.prototype.slice.call(arguments))); +}; + exports.themis = function themis() { var script = 'themis'; if (!os.whence(script)) { diff --git a/test/language/vimscript.spec.js b/test/language/vimscript.spec.js index 6e55143..cca9d3e 100644 --- a/test/language/vimscript.spec.js +++ b/test/language/vimscript.spec.js @@ -1,7 +1,7 @@ // // aster :: language/vimscript.spec.js // -// Copyright (c) 2020-2021 Akinori Hattori +// Copyright (c) 2020-2024 Akinori Hattori // // SPDX-License-Identifier: MIT // @@ -100,6 +100,75 @@ describe('language', () => { }); }); + describe('.primula()', () => { + it('should notify "primula not found"', () => { + os.whence.mockReturnValueOnce(false); + + expect(vimscript.primula('--version')).toBe(true); + expect(os.whence).lastCalledWith('primula'); + expect(aster.notify).lastCalledWith('failure', 'aster: primula', 'primula not found!'); + }); + + it('should execute `primula --version`', () => { + os.whence.mockReturnValueOnce(true); + language.system.mockReturnValueOnce(false); + + expect(vimscript.primula('--version')).toBe(false); + expect(language.system).lastCalledWith({ + args: ['primula', '--version'], + options: undefined, + title: 'primula', + success: '--version passed', + failure: '--version failed', + }); + }); + }); + + describe('.primula', () => { + describe.each([ + ['annotate'], + ['combine'], + ['erase'], + ['html'], + ['json'], + ['lcov'], + ['report'], + ['xml'], + ])('.%s()', (cmd) => { + it(`should execute \`primula ${cmd}\``, () => { + os.whence.mockReturnValueOnce(true); + language.system.mockReturnValueOnce(false); + + expect(vimscript.primula[cmd]()).toBe(false); + expect(os.whence).lastCalledWith('primula'); + expect(language.system).lastCalledWith({ + args: ['primula', cmd], + options: undefined, + title: 'primula', + success: `${cmd} passed`, + failure: `${cmd} failed`, + }); + }); + }); + + describe('.run()', () => { + it('should execute `primula run themis --reporter dot`', () => { + os.whence.mockReturnValueOnce(true); + language.system.mockReturnValueOnce(false); + + expect(vimscript.primula.run('themis', '--reporter', 'dot')).toBe(false); + expect(os.whence).lastCalledWith('primula'); + expect(language.system).lastCalledWith({ + args: ['primula', 'run', 'themis', '--reporter', 'dot'], + options: undefined, + title: 'primula', + success: 'run passed', + failure: 'run failed', + }); + }); + }); + }); + describe('.themis()', () => { it('should notify "themis not found"', () => { os.whence.mockClear().mockReturnValue(false);