Closes #341. Add indent_size option to Rubocop beautifier

This commit is contained in:
Glavin Wiechert 2015-06-10 13:10:16 -03:00
parent 94553b0a23
commit 198f0770dd
4 changed files with 34 additions and 3 deletions

View File

@ -40,3 +40,5 @@
indent_class: true
indent_with_tabs: 0
indent_size: 1
ruby:
indent_size: 4

View File

@ -9,15 +9,32 @@ module.exports = class Rubocop extends Beautifier
name: "Rubocop"
options: {
Ruby: true
Ruby:
indent_size: true
}
beautify: (text, language, options) ->
# Generate config file
yaml = require("yaml-front-matter")
config = {
"Style/IndentationWidth":
"Width": options.indent_size
}
configStr = yaml.safeDump(config)
console.log("rubocop", config, configStr)
@run("rubocop", [
"--auto-correct"
"--config", @tempFile("rubocop-config", configStr)
tempFile = @tempFile("temp", text)
], {ignoreReturnCode: true})
.then(=>
# console.log('rubocop', arguments, tempFile)
@readFile(tempFile)
.then((text) ->
console.log('rubocop', text)
return text
)
)

View File

@ -9,7 +9,7 @@ module.exports = class RubyBeautify extends Beautifier
name: "Ruby Beautify"
options: {
Ruby: true
Ruby: false
}
beautify: (text, language, options) ->

View File

@ -1,3 +1,10 @@
# Get Atom defaults
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
module.exports = {
name: "Ruby"
@ -18,6 +25,11 @@ module.exports = {
"rb"
]
options: []
options:
indent_size:
type: 'integer'
default: defaultIndentSize
minimum: 0
description: "Indentation size/length"
}