Module: SqlFormatterWebInterface
- Defined in:
- lib/sql_formatter_web_interface.rb,
lib/sql_formatter_web_interface/to_formatted_sql.rb
Overview
</b>
Defined Under Namespace
Modules: ToFormattedSql
Constant Summary collapse
- SQL_FORMATTER_URL =
'http://sqlformat.appspot.com/format/'
- DEFAULT_OPTIONS =
{ 'format' => 'text', 'remove_comments' => '', 'highlight' => '', 'keyword_case' => 'upper', 'identifier_case' => '', 'n_indents' => '2', 'right_margin' => '', 'output_format' => 'sql' }
Class Method Summary collapse
-
.format(sql, options = {}) ⇒ String
It makes a request to an online formatting service which will format a SQL string, according to the setted options (see sqlformat.appspot.com for details about the default SQL formatting service).
Class Method Details
.format(sql, options = {}) ⇒ String
It makes a request to an online formatting service which will format a SQL string, according to the setted options (see sqlformat.appspot.com for details about the default SQL formatting service)
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/sql_formatter_web_interface.rb', line 65 def self.format(sql, = {}) uri = URI([:url].nil? ? SQL_FORMATTER_URL : .delete(:url)) stringify_hash!() ['data'] = sql = DEFAULT_OPTIONS.merge() Net::HTTP.post_form(uri, ).body rescue SocketError raise SocketError.new "unable to resolve #{uri.to_s}" end |