db-gui 0.1.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/README.md +21 -2
- data/VERSION +1 -1
- data/app/db_gui/model/db.rb +56 -0
- data/app/db_gui/view/db_command_result_table.rb +6 -0
- data/app/db_gui/view/db_gui_application.rb +2 -57
- data/app/db_gui/view/db_gui_menu_bar.rb +75 -0
- metadata +20 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a23c4423702e92a9b634a90e32d385ac6482ebe1259656a467469c483bfb50e
|
4
|
+
data.tar.gz: a5dd6514f0d2dd0e0c06b9adc06b1df13ca36be01a3e205eb37aa101568c9117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3d60b076358330b17e79cc29f54e15f0fb72a7a5f2459bd1e319268d5c56dae9be0107bc0d3b6b3c1fcd7603c3e5666d7c9fecf3a83d7187b727cd8b8addc44
|
7
|
+
data.tar.gz: 01c2e579505a3f05aea916a5b977911bbd344844bab274e7d457f88e66d7626e6bee9f6addba5fbb15df1b273045242bf8f2d8a84743a4d23f6488d284ef136c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.2
|
4
|
+
|
5
|
+
- Edit -> Copy Table (with headers) menu item to copy table data with headers as a formatted string to the clipboard
|
6
|
+
- Edit -> Copy Selected Row (with headers) menu item to copy selected row data with headers as a formatted string to the clipboard
|
7
|
+
|
8
|
+
## 0.2.1
|
9
|
+
|
10
|
+
- Fix bug in 0.2.0 with crashing whenever running a DB query for the second time.
|
11
|
+
|
12
|
+
## 0.2.0
|
13
|
+
|
14
|
+
- Edit -> Copy Table menu item to copy table data as a formatted string to the clipboard
|
15
|
+
- Edit -> Copy Selected Row menu item to copy selected row data as a formatted string to the clipboard
|
16
|
+
|
3
17
|
## 0.1.1
|
4
18
|
|
5
19
|
- Automatically extend DB command timeout after timing out by retrying 6 times (7 times total) with exponential timeout increases
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# DB GUI (Database Graphical User Interface) 0.
|
1
|
+
# DB GUI (Database Graphical User Interface) 0.2.2
|
2
2
|
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer DSL for LibUI Application](https://github.com/AndyObtiva/glimmer-dsl-libui)
|
3
3
|
[](http://badge.fury.io/rb/db-gui)
|
4
4
|
|
@@ -12,7 +12,7 @@ It currently supports PostgreSQL as a start, with the potential of supporting ma
|
|
12
12
|
|
13
13
|
Run:
|
14
14
|
```
|
15
|
-
gem install db-gui -v0.
|
15
|
+
gem install db-gui -v0.2.2
|
16
16
|
```
|
17
17
|
|
18
18
|
## Usage
|
@@ -26,6 +26,25 @@ Or, run one of the aliases: `db-ui` / `dbgui` / `db-gui`
|
|
26
26
|
|
27
27
|
Note that it stores the last connection details under `~/.db_gui`, and will auto-connect using that configuration on startup for extra convenience (in the future, there is the potential to support multiple connection configurations).
|
28
28
|
|
29
|
+
### Menu Items
|
30
|
+
|
31
|
+
**Edit -> Copy Table**
|
32
|
+
|
33
|
+
Click on this menu item to copy the table data as a formatted string to the clipboard.
|
34
|
+
|
35
|
+
|
36
|
+
**Edit -> Copy Table (with headers)**
|
37
|
+
|
38
|
+
Click on this menu item to copy the table data with headers as a formatted string to the clipboard.
|
39
|
+
|
40
|
+
**Edit -> Copy Selected Row**
|
41
|
+
|
42
|
+
Click on this menu item to copy the selected row data as a formatted string to the clipboard.
|
43
|
+
|
44
|
+
**Edit -> Copy Selected Row (with headers)**
|
45
|
+
|
46
|
+
Click on this menu item to copy the selected row data with headers as a formatted string to the clipboard.
|
47
|
+
|
29
48
|
## Change Log
|
30
49
|
|
31
50
|
[CHANGELOG.md](/CHANGELOG.md)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.2
|
data/app/db_gui/model/db.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'timeout'
|
3
|
+
require 'clipboard'
|
3
4
|
|
4
5
|
class DbGui
|
5
6
|
module Model
|
@@ -12,11 +13,13 @@ class DbGui
|
|
12
13
|
COUNT_RETRIES = ENV.fetch('DB_COMMAND_COUNT_RETRIES', 7)
|
13
14
|
REGEX_ROW_COUNT = /^\((\d+) row/
|
14
15
|
ERROR_PREFIX = 'ERROR:'
|
16
|
+
NEW_LINE = OS.windows? ? "\r\n" : "\n"
|
15
17
|
|
16
18
|
attr_accessor :connected
|
17
19
|
alias connected? connected
|
18
20
|
attr_accessor :db_command_result
|
19
21
|
attr_accessor :db_command
|
22
|
+
attr_accessor :db_command_result_selection
|
20
23
|
|
21
24
|
def initialize
|
22
25
|
load_db_config
|
@@ -24,6 +27,7 @@ class DbGui
|
|
24
27
|
self.port ||= 5432 # PostgreSQL default port
|
25
28
|
self.db_command_result = ''
|
26
29
|
self.db_command_timeout ||= ENV.fetch('DB_COMMAND_TIMEOUT_IN_MILLISECONDS', 300).to_i
|
30
|
+
self.db_command_result_selection = 0
|
27
31
|
connect if to_h.except(:password).none? {|value| value.nil? || (value.respond_to?(:empty?) && value.empty?) }
|
28
32
|
end
|
29
33
|
|
@@ -94,6 +98,45 @@ class DbGui
|
|
94
98
|
db_command_result.to_s.strip.start_with?(ERROR_PREFIX)
|
95
99
|
end
|
96
100
|
|
101
|
+
def copy_table
|
102
|
+
return if db_command_result_rows.empty?
|
103
|
+
Clipboard.copy(formatted_table_string)
|
104
|
+
end
|
105
|
+
|
106
|
+
def copy_selected_row
|
107
|
+
return if db_command_result_rows.empty?
|
108
|
+
Clipboard.copy(formatted_selected_row_string)
|
109
|
+
end
|
110
|
+
|
111
|
+
def copy_table_with_headers
|
112
|
+
return if db_command_result_rows.empty?
|
113
|
+
Clipboard.copy(formatted_table_string(include_headers: true))
|
114
|
+
end
|
115
|
+
|
116
|
+
def copy_selected_row_with_headers
|
117
|
+
return if db_command_result_rows.empty?
|
118
|
+
Clipboard.copy(formatted_selected_row_string(include_headers: true))
|
119
|
+
end
|
120
|
+
|
121
|
+
def formatted_table_string(rows = nil, include_headers: false)
|
122
|
+
rows ||= db_command_result_rows
|
123
|
+
rows = rows.dup
|
124
|
+
rows.prepend(db_command_result_headers) if include_headers
|
125
|
+
column_max_lengths = row_column_max_lengths(rows) # TODO calculate those after prepending headers
|
126
|
+
rows.map do |row|
|
127
|
+
row.each_with_index.map do |data, column_index|
|
128
|
+
data.ljust(column_max_lengths[column_index])
|
129
|
+
end.join(" | ")
|
130
|
+
end.join(NEW_LINE)
|
131
|
+
end
|
132
|
+
|
133
|
+
def formatted_selected_row_string(include_headers: false)
|
134
|
+
selected_row = db_command_result_rows[db_command_result_selection]
|
135
|
+
selected_row.join(' | ')
|
136
|
+
rows = [selected_row]
|
137
|
+
formatted_table_string(rows, include_headers:)
|
138
|
+
end
|
139
|
+
|
97
140
|
private
|
98
141
|
|
99
142
|
def read_io_into_db_command_result
|
@@ -174,6 +217,19 @@ class DbGui
|
|
174
217
|
end
|
175
218
|
[count, headers, rows]
|
176
219
|
end
|
220
|
+
|
221
|
+
def row_column_max_lengths(rows = nil)
|
222
|
+
rows ||= db_command_result_rows
|
223
|
+
column_count = rows.first.size
|
224
|
+
column_max_lengths = []
|
225
|
+
rows.each do |row|
|
226
|
+
row.each_with_index do |value, column_index|
|
227
|
+
column_max_lengths[column_index] ||= 0
|
228
|
+
column_max_lengths[column_index] = [column_max_lengths[column_index], value.size].max
|
229
|
+
end
|
230
|
+
end
|
231
|
+
column_max_lengths
|
232
|
+
end
|
177
233
|
end
|
178
234
|
end
|
179
235
|
end
|
@@ -19,6 +19,12 @@ class DbGui
|
|
19
19
|
end
|
20
20
|
|
21
21
|
cell_rows db.db_command_result_rows
|
22
|
+
selection_mode :one
|
23
|
+
selection db.db_command_result_selection
|
24
|
+
|
25
|
+
on_selection_changed do |t, selection, added_selection, removed_selection|
|
26
|
+
db.db_command_result_selection = selection
|
27
|
+
end
|
22
28
|
}
|
23
29
|
else
|
24
30
|
label('No data')
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'db_gui/model/db'
|
2
2
|
|
3
|
+
require 'db_gui/view/db_gui_menu_bar'
|
3
4
|
require 'db_gui/view/db_config_form'
|
4
5
|
require 'db_gui/view/db_command_form'
|
5
6
|
require 'db_gui/view/db_command_result_table'
|
@@ -13,7 +14,7 @@ class DbGui
|
|
13
14
|
|
14
15
|
before_body do
|
15
16
|
@db = Model::Db.new
|
16
|
-
|
17
|
+
db_gui_menu_bar(db:)
|
17
18
|
end
|
18
19
|
|
19
20
|
body {
|
@@ -34,62 +35,6 @@ class DbGui
|
|
34
35
|
}
|
35
36
|
}
|
36
37
|
}
|
37
|
-
|
38
|
-
# def menu_bar
|
39
|
-
# menu('File') {
|
40
|
-
# menu_item('Preferences...') {
|
41
|
-
# on_clicked do
|
42
|
-
# display_preferences_dialog
|
43
|
-
# end
|
44
|
-
# }
|
45
|
-
#
|
46
|
-
# quit_menu_item if OS.mac?
|
47
|
-
# }
|
48
|
-
# menu('Help') {
|
49
|
-
# if OS.mac?
|
50
|
-
# about_menu_item {
|
51
|
-
# on_clicked do
|
52
|
-
# display_about_dialog
|
53
|
-
# end
|
54
|
-
# }
|
55
|
-
# end
|
56
|
-
#
|
57
|
-
# menu_item('About') {
|
58
|
-
# on_clicked do
|
59
|
-
# display_about_dialog
|
60
|
-
# end
|
61
|
-
# }
|
62
|
-
# }
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# def display_about_dialog
|
66
|
-
# message = "Db Gui #{VERSION}\n\n#{LICENSE}"
|
67
|
-
# msg_box('About', message)
|
68
|
-
# end
|
69
|
-
#
|
70
|
-
# def display_preferences_dialog
|
71
|
-
# window {
|
72
|
-
# title 'Preferences'
|
73
|
-
# content_size 200, 100
|
74
|
-
#
|
75
|
-
# margined true
|
76
|
-
#
|
77
|
-
# vertical_box {
|
78
|
-
# padded true
|
79
|
-
#
|
80
|
-
# label('Greeting:') {
|
81
|
-
# stretchy false
|
82
|
-
# }
|
83
|
-
#
|
84
|
-
# radio_buttons {
|
85
|
-
# stretchy false
|
86
|
-
#
|
87
|
-
# items Model::Greeting::GREETINGS
|
88
|
-
# selected <=> [@greeting, :text_index]
|
89
|
-
# }
|
90
|
-
# }
|
91
|
-
# }.show
|
92
|
-
# end
|
93
38
|
end
|
94
39
|
end
|
95
40
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class DbGui
|
2
|
+
module View
|
3
|
+
class DbGuiMenuBar
|
4
|
+
include Glimmer::LibUI::CustomControl
|
5
|
+
|
6
|
+
option :db
|
7
|
+
|
8
|
+
body {
|
9
|
+
menu('Query') {
|
10
|
+
menu_item('Run') {
|
11
|
+
on_clicked do
|
12
|
+
db.run_db_command
|
13
|
+
end
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
menu('Edit') {
|
18
|
+
menu_item('Copy Table') {
|
19
|
+
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
20
|
+
|
21
|
+
on_clicked do
|
22
|
+
db.copy_table
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
menu_item('Copy Table (with headers)') {
|
27
|
+
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
28
|
+
|
29
|
+
on_clicked do
|
30
|
+
db.copy_table_with_headers
|
31
|
+
end
|
32
|
+
}
|
33
|
+
|
34
|
+
menu_item('Copy Selected Row') {
|
35
|
+
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
36
|
+
|
37
|
+
on_clicked do
|
38
|
+
db.copy_selected_row
|
39
|
+
end
|
40
|
+
}
|
41
|
+
|
42
|
+
menu_item('Copy Selected Row (with headers)') {
|
43
|
+
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
44
|
+
|
45
|
+
on_clicked do
|
46
|
+
db.copy_selected_row_with_headers
|
47
|
+
end
|
48
|
+
}
|
49
|
+
|
50
|
+
quit_menu_item if OS.mac?
|
51
|
+
}
|
52
|
+
menu('Help') {
|
53
|
+
if OS.mac?
|
54
|
+
about_menu_item {
|
55
|
+
on_clicked do
|
56
|
+
display_about_dialog
|
57
|
+
end
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
menu_item('About') {
|
62
|
+
on_clicked do
|
63
|
+
display_about_dialog
|
64
|
+
end
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
def display_about_dialog
|
71
|
+
message = "DB GUI #{VERSION}\n\n#{LICENSE}"
|
72
|
+
msg_box('About', message)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-gui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: glimmer-dsl-libui
|
@@ -24,6 +23,20 @@ dependencies:
|
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: 0.12.7
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: clipboard
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 2.0.0
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
41
|
name: rspec
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,12 +80,12 @@ dependencies:
|
|
67
80
|
- !ruby/object:Gem::Version
|
68
81
|
version: '0'
|
69
82
|
description: DB GUI (Database Graphical User Interface) - Enables Interaction with
|
70
|
-
Relational SQL Databases
|
83
|
+
Relational SQL Databases. This alpha version only supports PostgreSQL at the moment.
|
71
84
|
email: andy.am@gmail.com
|
72
85
|
executables:
|
73
86
|
- db-gui
|
74
|
-
- dbgui
|
75
87
|
- db-ui
|
88
|
+
- dbgui
|
76
89
|
- dbui
|
77
90
|
extensions: []
|
78
91
|
extra_rdoc_files:
|
@@ -91,6 +104,7 @@ files:
|
|
91
104
|
- app/db_gui/view/db_command_result_table.rb
|
92
105
|
- app/db_gui/view/db_config_form.rb
|
93
106
|
- app/db_gui/view/db_gui_application.rb
|
107
|
+
- app/db_gui/view/db_gui_menu_bar.rb
|
94
108
|
- bin/db-gui
|
95
109
|
- bin/db-ui
|
96
110
|
- bin/dbgui
|
@@ -102,7 +116,6 @@ homepage: http://github.com/AndyObtiva/db-gui
|
|
102
116
|
licenses:
|
103
117
|
- MIT
|
104
118
|
metadata: {}
|
105
|
-
post_install_message:
|
106
119
|
rdoc_options: []
|
107
120
|
require_paths:
|
108
121
|
- lib
|
@@ -118,8 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
131
|
- !ruby/object:Gem::Version
|
119
132
|
version: '0'
|
120
133
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
122
|
-
signing_key:
|
134
|
+
rubygems_version: 3.6.7
|
123
135
|
specification_version: 4
|
124
136
|
summary: DB GUI
|
125
137
|
test_files: []
|