Skip to content

Commit

Permalink
Update to reflect that rubyfmt is now invoked as a standalone executable
Browse files Browse the repository at this point in the history
  • Loading branch information
toreriklinnerud committed Oct 9, 2020
1 parent f82797c commit 21dca7b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
6 changes: 6 additions & 0 deletions keymaps/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Foobar
class Foo
def foo
puts(:hi)
end
end
17 changes: 7 additions & 10 deletions lib/rubyfmt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions lib/spawn-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 21dca7b

Please sign in to comment.