Class: SQLUI
- Inherits:
-
Object
- Object
- SQLUI
- Defined in:
- lib/sqlui.rb
Constant Summary collapse
- MAX_ROWS =
1_000
Instance Method Summary collapse
- #get(params) ⇒ Object
-
#initialize(name:, saved_path:, max_rows: MAX_ROWS, &block) ⇒ SQLUI
constructor
A new instance of SQLUI.
- #post(params) ⇒ Object
Constructor Details
#initialize(name:, saved_path:, max_rows: MAX_ROWS, &block) ⇒ SQLUI
Returns a new instance of SQLUI.
8 9 10 11 12 13 14 |
# File 'lib/sqlui.rb', line 8 def initialize(name:, saved_path:, max_rows: MAX_ROWS, &block) @name = name @saved_path = saved_path @max_rows = max_rows @queryer = block @resources_dir = File.join(File.('..', File.dirname(__FILE__)), 'resources') end |
Instance Method Details
#get(params) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sqlui.rb', line 16 def get(params) case params[:route] when 'app' { body: html, status: 200, content_type: 'text/html' } when 'sqlui.css' { body: css, status: 200, content_type: 'text/css' } when 'sqlui.js' { body: javascript, status: 200, content_type: 'text/javascript' } when 'metadata' { body: .to_json, status: 200, content_type: 'application/json' } when 'query_file' { body: query_file(params).to_json, status: 200, content_type: 'application/json' } else { body: "unknown route: #{params[:route]}", status: 404, content_type: 'text/plain' } end end |
#post(params) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/sqlui.rb', line 33 def post(params) case params[:route] when 'query' { body: query(params).to_json, status: 200, content_type: 'application/json' } else { body: "unknown route: #{params[:route]}", status: 404, content_type: 'text/plain' } end end |