From a0e07c232dfb6ba251e63c75e2a519f57f98ee5f Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Wed, 10 Jun 2015 19:20:08 -0300 Subject: [PATCH] Closes #142. Add options (tabs, spaces, indent_count) for Ruby-Beautify --- docs/options.md | 57 ++++++++++++++++++++++++++-- src/beautifiers/ruby-beautify.coffee | 7 +++- src/languages/javascript.coffee | 1 - src/languages/ruby.coffee | 6 +++ 4 files changed, 64 insertions(+), 7 deletions(-) diff --git a/docs/options.md b/docs/options.md index e58bd77..080c041 100644 --- a/docs/options.md +++ b/docs/options.md @@ -819,11 +819,27 @@ do not fix these errors/warnings (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`Rubocop`](#rubocop) +**Supported Beautifiers**: [`Rubocop`](#rubocop) [`Ruby Beautify`](#ruby-beautify) **Description**: -Indentation size/length (Supported by Rubocop) +Indentation size/length (Supported by Rubocop, Ruby Beautify) + +#### [Ruby - Indent char](#ruby---indent-char) + +**Key**: `ruby_indent_char` + +**Default**: ` ` + +**Type**: `string` + +**Enum**: ` ` ` ` + +**Supported Beautifiers**: [`Ruby Beautify`](#ruby-beautify) + +**Description**: + +Indentation character (Supported by Ruby Beautify) #### [Rust - Rustfmt path](#rust---rustfmt-path) @@ -3173,11 +3189,44 @@ do not fix these errors/warnings (Supported by autopep8) **Type**: `integer` -**Supported Beautifiers**: [`Rubocop`](#rubocop) +**Supported Beautifiers**: [`Rubocop`](#rubocop) [`Ruby Beautify`](#ruby-beautify) **Description**: -Indentation size/length (Supported by Rubocop) +Indentation size/length (Supported by Rubocop, Ruby Beautify) + + +### Ruby Beautify + +#### [Ruby - Indent size](#ruby---indent-size) + +**Key**: `ruby_indent_size` + +**Default**: `4` + +**Type**: `integer` + +**Supported Beautifiers**: [`Rubocop`](#rubocop) [`Ruby Beautify`](#ruby-beautify) + +**Description**: + +Indentation size/length (Supported by Rubocop, Ruby Beautify) + +#### [Ruby - Indent char](#ruby---indent-char) + +**Key**: `ruby_indent_char` + +**Default**: ` ` + +**Type**: `string` + +**Enum**: ` ` ` ` + +**Supported Beautifiers**: [`Ruby Beautify`](#ruby-beautify) + +**Description**: + +Indentation character (Supported by Ruby Beautify) ### rustfmt diff --git a/src/beautifiers/ruby-beautify.coffee b/src/beautifiers/ruby-beautify.coffee index d42e472..19dfcb0 100644 --- a/src/beautifiers/ruby-beautify.coffee +++ b/src/beautifiers/ruby-beautify.coffee @@ -9,12 +9,15 @@ module.exports = class RubyBeautify extends Beautifier name: "Ruby Beautify" options: { - Ruby: false + Ruby: + indent_size: true + indent_char: true } beautify: (text, language, options) -> - @deprecate("Ruby-Beautify has been deprecated in favour of Rubocop beautifier.") @run("rbeautify", [ + if options.indent_char is '\t' then "--tabs" else "--spaces" + "--indent_count", options.indent_count @tempFile("input", text) ], help: { link: "https://github.com/erniebrodeur/ruby-beautify" diff --git a/src/languages/javascript.coffee b/src/languages/javascript.coffee index df270f9..f9e507e 100644 --- a/src/languages/javascript.coffee +++ b/src/languages/javascript.coffee @@ -39,7 +39,6 @@ module.exports = { indent_char: type: 'string' default: defaultIndentChar - minimum: 0 description: "Indentation character" indent_level: type: 'integer' diff --git a/src/languages/ruby.coffee b/src/languages/ruby.coffee index 9075b3d..9bab6eb 100644 --- a/src/languages/ruby.coffee +++ b/src/languages/ruby.coffee @@ -31,5 +31,11 @@ module.exports = { default: defaultIndentSize minimum: 0 description: "Indentation size/length" + indent_char: + type: 'string' + default: defaultIndentChar + description: "Indentation character" + enum: [" ", "\t"] + } \ No newline at end of file