Created
March 11, 2014 20:25
-
-
Save rickcnagy/9494236 to your computer and use it in GitHub Desktop.
Format SQL text in TextMate via sqlformat.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'uri' | |
| require 'net/http' | |
| require 'json' | |
| uri = URI("http://sqlformat.org/api/v1/format") | |
| https = Net::HTTP.new(uri.host, uri.port) | |
| https.use_ssl = false | |
| body = URI.encode_www_form({:sql => "#{ENV['TM_SELECTED_TEXT']}", :reindent => 1}) | |
| response = https.post(uri.path, body) | |
| puts JSON.parse(response.body)["result"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment