Skip to content

Commit

Permalink
Merge branch 'jney-master' into new-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed May 2, 2015
2 parents 20ff7e2 + 38b760e commit 4a5bcc1
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 13 additions & 14 deletions examples/simple-jsbeautifyrc/ruby/expected/test.rb
Original file line number Diff line number Diff line change
@@ -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,

}
}
14 changes: 7 additions & 7 deletions src/beautifiers/beautifier.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ module.exports = class Beautifier

###
Show deprecation warning to user.
TODO: implement this
###
deprecate: (warning) ->
atom.notifications?.addWarning(warning)

This comment has been minimized.

Copy link
@Glavin001

Glavin001 May 2, 2015

Author Owner

Add deprecate support: #282


###
Create temporary file
Expand Down Expand Up @@ -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)
)
)
Expand Down
1 change: 1 addition & 0 deletions src/beautifiers/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = class Beautifiers
'perltidy'
'php-cs-fixer'
'prettydiff'
'rubocop'
'ruby-beautify'
'sqlformat'
'tidy-markdown'
Expand Down
23 changes: 23 additions & 0 deletions src/beautifiers/rubocop.coffee
Original file line number Diff line number Diff line change
@@ -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)
)
3 changes: 2 additions & 1 deletion src/beautifiers/ruby-beautify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])

0 comments on commit 4a5bcc1

Please sign in to comment.