Class: ConceptQL::SqlFormatter
- Inherits:
-
Object
- Object
- ConceptQL::SqlFormatter
- Defined in:
- lib/conceptql/sql_formatter.rb
Instance Method Summary collapse
Instance Method Details
#command?(name) ⇒ Boolean
13 14 15 16 |
# File 'lib/conceptql/sql_formatter.rb', line 13 def command?(name) `which #{name}` $?.success? end |
#format(sql) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/conceptql/sql_formatter.rb', line 3 def format(sql) if command?(formatter) sql, _ = Open3.capture2(formatter, stdin_data: sql) return sql end return sql rescue return sql end |
#formatter ⇒ Object
18 19 20 |
# File 'lib/conceptql/sql_formatter.rb', line 18 def formatter 'pg_format' end |