dbbrowser 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest.txt +1 -0
- data/lib/dbbrowser/connection.rb +19 -13
- data/lib/dbbrowser/server.rb +11 -4
- data/lib/dbbrowser/version.rb +1 -1
- data/lib/dbbrowser/views/db.erb +9 -3
- data/lib/dbbrowser/views/debug.erb +9 -0
- data/lib/dbbrowser/views/index.erb +2 -3
- data/lib/dbbrowser/views/shared/_spec.erb +17 -0
- metadata +9 -8
data/Manifest.txt
CHANGED
@@ -12,6 +12,7 @@ lib/dbbrowser/views/debug.erb
|
|
12
12
|
lib/dbbrowser/views/index.erb
|
13
13
|
lib/dbbrowser/views/layout.erb
|
14
14
|
lib/dbbrowser/views/shared/_debug.erb
|
15
|
+
lib/dbbrowser/views/shared/_spec.erb
|
15
16
|
lib/dbbrowser/views/shared/_table_def.erb
|
16
17
|
lib/dbbrowser/views/shared/_tables.erb
|
17
18
|
lib/dbbrowser/views/shared/_version.erb
|
data/lib/dbbrowser/connection.rb
CHANGED
@@ -7,13 +7,17 @@ class ConnectionMan # connection manager
|
|
7
7
|
# ActiveRecord::Base.configurations.keys
|
8
8
|
# end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
CONNECTS = {} # cache connections
|
11
|
+
|
12
|
+
def connection_for( key )
|
13
|
+
# cache connections - needed? why? why not??
|
14
|
+
con = CONNECTS[ key ] ||= AbstractModel.connection_for( key )
|
15
|
+
|
16
|
+
# note: make sure connection is active?
|
17
|
+
# use verify! - will try active? followed by reconnect!
|
18
|
+
# - todo: check ourselves if active? - why? why not??
|
19
|
+
con.verify!
|
20
|
+
|
17
21
|
# wrap ActiveRecord connection in our own connection class
|
18
22
|
Connection.new( con, key )
|
19
23
|
end
|
@@ -22,13 +26,11 @@ class ConnectionMan # connection manager
|
|
22
26
|
class AbstractModel < ActiveRecord::Base
|
23
27
|
self.abstract_class = true # no table; class just used for getting db connection
|
24
28
|
|
25
|
-
CONNECTS = {} # cache connections
|
26
29
|
def self.connection_for( key )
|
27
|
-
|
28
|
-
|
29
|
-
connection
|
30
|
-
end
|
30
|
+
establish_connection( key )
|
31
|
+
connection
|
31
32
|
end
|
33
|
+
|
32
34
|
end # class AbstractModel
|
33
35
|
|
34
36
|
|
@@ -42,9 +44,13 @@ class ConnectionMan # connection manager
|
|
42
44
|
attr_reader :connection
|
43
45
|
attr_reader :key
|
44
46
|
|
45
|
-
delegate :select_value, :select_all,
|
47
|
+
delegate :select_value, :select_all, :adapter_name,
|
46
48
|
:to => :connection
|
47
49
|
|
50
|
+
def class_name
|
51
|
+
@connection.class.name
|
52
|
+
end
|
53
|
+
|
48
54
|
# delegate :quote_table_name, :quote_column_name, :quote,
|
49
55
|
# :update, :insert, :delete,
|
50
56
|
# :add_limit_offset!,
|
data/lib/dbbrowser/server.rb
CHANGED
@@ -52,6 +52,13 @@ class Server < Sinatra::Base
|
|
52
52
|
Rack::Utils.escape_html(text)
|
53
53
|
end
|
54
54
|
|
55
|
+
def render_spec_for( key, opts={} )
|
56
|
+
# render connection spec(ification) aka configuration
|
57
|
+
spec = ActiveRecord::Base.configurations[ key ]
|
58
|
+
erb( 'shared/_spec'.to_sym,
|
59
|
+
layout: false,
|
60
|
+
locals: { spec: spec })
|
61
|
+
end
|
55
62
|
|
56
63
|
def render_table_def( table, opts={} )
|
57
64
|
erb( 'shared/_table_def'.to_sym,
|
@@ -66,7 +73,7 @@ class Server < Sinatra::Base
|
|
66
73
|
end
|
67
74
|
|
68
75
|
def render_tables_for( key, opts={} )
|
69
|
-
con = settings.man.
|
76
|
+
con = settings.man.connection_for( key )
|
70
77
|
erb( 'shared/_tables'.to_sym,
|
71
78
|
layout: false,
|
72
79
|
locals: { tables: con.tables } )
|
@@ -81,13 +88,13 @@ class Server < Sinatra::Base
|
|
81
88
|
end
|
82
89
|
|
83
90
|
get '/db/:key/:table_name' do |key,table_name|
|
84
|
-
con = settings.man.
|
91
|
+
con = settings.man.connection_for( key )
|
85
92
|
erb :table, locals: { table: con.table( table_name ) }
|
86
93
|
end
|
87
94
|
|
88
95
|
get '/db/:key' do |key|
|
89
|
-
con = settings.man.
|
90
|
-
erb :db, locals: { key: key, tables: con.tables }
|
96
|
+
con = settings.man.connection_for( key )
|
97
|
+
erb :db, locals: { key: key, tables: con.tables, con: con }
|
91
98
|
end
|
92
99
|
|
93
100
|
get '/d*' do
|
data/lib/dbbrowser/version.rb
CHANGED
data/lib/dbbrowser/views/db.erb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
|
2
2
|
<h2>## <%= key %> ##</h2>
|
3
3
|
|
4
|
-
<
|
5
|
-
|
6
|
-
</
|
4
|
+
<h3>Adapter Info</h3>
|
5
|
+
<table>
|
6
|
+
<tr><td>adapter name</td><td><%= con.adapter_name %></td></tr>
|
7
|
+
<tr><td>class name</td><td><%= con.class_name %></td></tr>
|
8
|
+
</table>
|
9
|
+
|
10
|
+
<%= render_spec_for( key ) %>
|
7
11
|
|
8
12
|
|
9
13
|
<%= render_tables( tables ) %>
|
@@ -14,3 +18,5 @@
|
|
14
18
|
|
15
19
|
<%= render_table_def( table ) %>
|
16
20
|
<% end %>
|
21
|
+
|
22
|
+
<!-- todo: add indexes, check for primary keys - how?? -->
|
@@ -1,7 +1,16 @@
|
|
1
|
+
<h3>ActiveRecord Configurations</h3>
|
2
|
+
|
3
|
+
<pre>
|
4
|
+
ActiveRecord::Base.configurations:
|
5
|
+
<%= ActiveRecord::Base.configurations.inspect %>
|
6
|
+
</pre>
|
7
|
+
|
8
|
+
|
1
9
|
<h3>Named Route Helpers</h3>
|
2
10
|
|
3
11
|
<pre>
|
4
12
|
root_path: <%= root_path %>
|
5
13
|
</pre>
|
6
14
|
|
15
|
+
|
7
16
|
<%= erb :'shared/_debug' %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbbrowser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: logutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &73238970 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *73238970
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
requirement: &
|
27
|
+
requirement: &73238710 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.10'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *73238710
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hoe
|
38
|
-
requirement: &
|
38
|
+
requirement: &73238390 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '3.3'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *73238390
|
47
47
|
description: dbbrowser - database browser (connections, schema, tables, records, etc.)
|
48
48
|
as mountable web app
|
49
49
|
email: webslideshow@googlegroups.com
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- lib/dbbrowser/views/index.erb
|
67
67
|
- lib/dbbrowser/views/layout.erb
|
68
68
|
- lib/dbbrowser/views/shared/_debug.erb
|
69
|
+
- lib/dbbrowser/views/shared/_spec.erb
|
69
70
|
- lib/dbbrowser/views/shared/_table_def.erb
|
70
71
|
- lib/dbbrowser/views/shared/_tables.erb
|
71
72
|
- lib/dbbrowser/views/shared/_version.erb
|