From 21dca7babef13be8802bb0ee52d04b772d2f8db7 Mon Sep 17 00:00:00 2001 From: Tor Erik Linnerud Date: Fri, 9 Oct 2020 13:21:08 +0200 Subject: [PATCH] Update to reflect that rubyfmt is now invoked as a standalone executable --- README.md | 11 +++++------ keymaps/test.rb | 6 ++++++ lib/rubyfmt.js | 17 +++++++---------- lib/spawn-format.js | 5 ++--- package.json | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 keymaps/test.rb diff --git a/README.md b/README.md index 37d21c1..1e9e08b 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,11 @@ ## Dependencies -`ruby` is assumed to be in path and `rubyfmt.rb` is assumed to be in `~/bin/rubyfmt.rb` but this can be overriden in the package settings. - +`rubyfmt` and `ruby` are assumed to be in path. Their locations can be overridden with absolute paths in the package settings. ## Plugin installation -Through [Atom packages](https://atom.io/packages), search for rubyfmt. +Through [Atom packages](https://atom.io/packages), search for rubyfmt. ## Formatting code @@ -21,13 +20,13 @@ With a file open and identified as Ruby or Ruby on Rails, hit the above combinat ## Format on Save / Other settings -Format on save is disabled by default but can be enabled from the Package Settings. +Format on save is enabled by default but can be disabled from the Package Settings. -![settings-screenshot](https://user-images.githubusercontent.com/13226/62165887-6d2a6900-b2ed-11e9-8cb4-5b08c29cb256.png) +![settings-screenshot](https://user-images.githubusercontent.com/13226/95577225-072d8b80-0a32-11eb-9b53-6f71a3a96b2c.png) ## Syntax errors -If the Ruby code contains a syntax error it cannot be formatted. The syntax error will be displayed in a notification window. +If the Ruby code contains a syntax error it cannot be formatted. The syntax error will be displayed in a notification window. ![syntax-error-screenshot](https://user-images.githubusercontent.com/13226/62164251-153e3300-b2ea-11e9-972d-c76e9de21fb2.png) diff --git a/keymaps/test.rb b/keymaps/test.rb new file mode 100644 index 0000000..e7c4eb8 --- /dev/null +++ b/keymaps/test.rb @@ -0,0 +1,6 @@ +# Foobar +class Foo + def foo + puts(:hi) + end +end diff --git a/lib/rubyfmt.js b/lib/rubyfmt.js index 1a2552d..a91f5d4 100644 --- a/lib/rubyfmt.js +++ b/lib/rubyfmt.js @@ -15,25 +15,22 @@ export default { title: 'Format on save', description: "Automatically format when file is saved", type: 'boolean', - default: false + default: true }, rubyExecutable: { order: 2, type: 'string', default: 'ruby', title: "Ruby executable", - description: "Can be overriden with an absolute path" + description: "Can be overridden with an absolute path" }, - rubyfmtArgs: { + rubyfmtExecutable: { order: 3, - type: 'array', - default: ['--disable=gems', '~/bin/rubyfmt.rb'], - items: { - type: 'string' - }, + type: 'string', + default: 'rubyfmt', title: "Rubyfmt executable", - description: "Can be overriden with additional parameters" - }, + description: "Can be overridden with an absolute path" + } }, activate(state) { diff --git a/lib/spawn-format.js b/lib/spawn-format.js index a0158e6..8607869 100644 --- a/lib/spawn-format.js +++ b/lib/spawn-format.js @@ -28,9 +28,8 @@ export function spawnFormat(sourceText) { var promise = new Promise(function(resolve, reject) { var formattedText = "" var rubyfmtErrorMsg = "" - rubyExecutable = atom.config.get('rubyfmt.rubyExecutable') - rubyfmtArgs = atom.config.get('rubyfmt.rubyfmtArgs') - rubyfmt = spawn(rubyExecutable, rubyfmtArgs, {windowsHide: true, shell: true}) + rubyfmtExecutable = atom.config.get('rubyfmt.rubyfmtExecutable') + rubyfmt = spawn(rubyfmtExecutable, [], {windowsHide: true, shell: true}) rubyfmt.stdout.on('data', (data) => { formattedText += data.toString('utf8'); }); diff --git a/package.json b/package.json index 825adc2..bcc00e4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "rubyfmt", "main": "./lib/rubyfmt", - "version": "0.6.2", + "version": "1.0.0", "description": "Atom package to autoformat Ruby code with Rubyfmt", "keywords": [ "formatter",