Class: DbBrowser::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- DbBrowser::Server
- Includes:
- TextUtils::HypertextHelper
- Defined in:
- lib/dbbrowser/server.rb
Constant Summary collapse
- PUBLIC_FOLDER =
"#{DbBrowser.root}/lib/dbbrowser/public"
- VIEWS_FOLDER =
"#{DbBrowser.root}/lib/dbbrowser/views"
Class Method Summary collapse
Instance Method Summary collapse
- #db_path(key) ⇒ Object
- #h(text) ⇒ Object
- #path_prefix ⇒ Object
- #render_spec_for(key, opts = {}) ⇒ Object
- #render_table_def(table, opts = {}) ⇒ Object
- #render_tables(tables, opts = {}) ⇒ Object
- #render_tables_for(key, opts = {}) ⇒ Object
- #root_path ⇒ Object
- #table_path(table) ⇒ Object
Class Method Details
.banner ⇒ Object
13 14 15 |
# File 'lib/dbbrowser/server.rb', line 13 def self. "dbbrowser/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})" end |
Instance Method Details
#db_path(key) ⇒ Object
40 41 42 |
# File 'lib/dbbrowser/server.rb', line 40 def db_path( key ) "#{path_prefix}/db/#{key}" end |
#h(text) ⇒ Object
52 53 54 |
# File 'lib/dbbrowser/server.rb', line 52 def h( text ) Rack::Utils.escape_html(text) end |
#path_prefix ⇒ Object
36 37 38 |
# File 'lib/dbbrowser/server.rb', line 36 def path_prefix request.script_name # request.env['SCRIPT_NAME'] end |
#render_spec_for(key, opts = {}) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/dbbrowser/server.rb', line 56 def render_spec_for( key, opts={} ) # render connection spec(ification) aka configuration spec = ActiveRecord::Base.configurations[ key ] erb( 'shared/_spec'.to_sym, layout: false, locals: { spec: spec }) end |
#render_table_def(table, opts = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/dbbrowser/server.rb', line 64 def render_table_def( table, opts={} ) erb( 'shared/_table_def'.to_sym, layout: false, locals: { table: table } ) end |
#render_tables(tables, opts = {}) ⇒ Object
70 71 72 73 74 |
# File 'lib/dbbrowser/server.rb', line 70 def render_tables( tables, opts={} ) erb( 'shared/_tables'.to_sym, layout: false, locals: { tables: tables } ) end |
#render_tables_for(key, opts = {}) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/dbbrowser/server.rb', line 76 def render_tables_for( key, opts={} ) con = settings.browser.connection_for( key ) erb( 'shared/_tables'.to_sym, layout: false, locals: { tables: con.tables } ) end |
#root_path ⇒ Object
48 49 50 |
# File 'lib/dbbrowser/server.rb', line 48 def root_path "#{path_prefix}/" end |
#table_path(table) ⇒ Object
44 45 46 |
# File 'lib/dbbrowser/server.rb', line 44 def table_path( table ) "#{path_prefix}/db/#{table.connection.key}/#{table.name.downcase}" end |