diff --git a/.travis.yml b/.travis.yml index d0ee5c0..1626ca1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,8 @@ before_install: - brew tap homebrew/dupes - brew tap homebrew/versions # Ruby language support - - gem install ruby-beautify --verbose + # - gem install ruby-beautify --verbose + - gem install rubocop # Python language support - brew install python - pip install --upgrade autopep8 diff --git a/examples/simple-jsbeautifyrc/ruby/expected/test.rb b/examples/simple-jsbeautifyrc/ruby/expected/test.rb index 3ad3012..e5e0c9d 100644 --- a/examples/simple-jsbeautifyrc/ruby/expected/test.rb +++ b/examples/simple-jsbeautifyrc/ruby/expected/test.rb @@ -1,25 +1,24 @@ #!/usr/bin/env ruby -conn_hash = { :hosts => [ +conn_hash = { hosts: [ - {:login => login, :passcode => passcode, :host => host, :port => port}, - ], - :reliable => false, # Override default - :connect_headers => conn_hdrs, + { login: login, passcode: passcode, host: host, port: port } +], + reliable: false, # Override default + connect_headers: conn_hdrs - } +} +hash = { hosts: [ -hash = { :hosts => [ + { login: user, passcode: password, host: 'noonehome', port: 2525 }, - {:login => user, :passcode => password, :host => 'noonehome', :port => 2525}, + { login: user, passcode: password, host: host, port: port } - {:login => user, :passcode => password, :host => host, :port => port}, +], - ], + logger: mylog, # This enables callback logging! - :logger => mylog, # This enables callback logging! + max_reconnect_attempts: 5 - :max_reconnect_attempts => 5, - - } + } diff --git a/examples/simple-jsbeautifyrc/ruby/original/_test.rb b/examples/simple-jsbeautifyrc/ruby/original/test.rb similarity index 100% rename from examples/simple-jsbeautifyrc/ruby/original/_test.rb rename to examples/simple-jsbeautifyrc/ruby/original/test.rb diff --git a/src/beautifiers/beautifier.coffee b/src/beautifiers/beautifier.coffee index c84a212..9b09139 100644 --- a/src/beautifiers/beautifier.coffee +++ b/src/beautifiers/beautifier.coffee @@ -40,10 +40,9 @@ module.exports = class Beautifier ### Show deprecation warning to user. - - TODO: implement this ### deprecate: (warning) -> + atom.notifications?.addWarning(warning) ### Create temporary file @@ -158,14 +157,15 @@ module.exports = class Beautifier cmd.stderr.on('data', (data) -> stderr += data ) # when the spawn child process exits, check if there were any errors and close the writeable stream cmd.on('exit', (code) -> - # console.log('spawn done', code, stderr, stdout) + console.log('spawn done', code, stderr, stdout) # If return code is not 0 then error occured - if code isnt 0 - reject(stderr) - else - resolve(stdout) + # if code isnt 0 + # reject(stderr) + # else + resolve(stdout) ) cmd.on('error', (err) -> + console.log('error', err) reject(err) ) ) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 64c5cf5..6f8d378 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -39,6 +39,7 @@ module.exports = class Beautifiers 'perltidy' 'php-cs-fixer' 'prettydiff' + 'rubocop' 'ruby-beautify' 'sqlformat' 'tidy-markdown' diff --git a/src/beautifiers/rubocop.coffee b/src/beautifiers/rubocop.coffee new file mode 100644 index 0000000..1b433e1 --- /dev/null +++ b/src/beautifiers/rubocop.coffee @@ -0,0 +1,23 @@ +### +Requires https://github.com/bbatsov/rubocop +### + +"use strict" +Beautifier = require('./beautifier') + +module.exports = class Rubocop extends Beautifier + name: "Rubocop" + + options: { + Ruby: true + } + + beautify: (text, language, options) -> + @run("rubocop", [ + "--auto-correct" + tempFile = @tempFile("temp", text) + ]) + .then(=> + console.log('rubocop', arguments, tempFile) + @readFile(tempFile) + ) diff --git a/src/beautifiers/ruby-beautify.coffee b/src/beautifiers/ruby-beautify.coffee index 4427faa..1d7764a 100644 --- a/src/beautifiers/ruby-beautify.coffee +++ b/src/beautifiers/ruby-beautify.coffee @@ -7,12 +7,13 @@ Beautifier = require('./beautifier') module.exports = class RubyBeautify extends Beautifier name: "Ruby Beautify" - + options: { Ruby: true } beautify: (text, language, options) -> + @deprecate("Ruby-Beautify has been deprecated in favour of Rubocop beautifier.") @run("rbeautify", [ @tempFile("input", text) ])