db-gui 0.2.1 → 0.2.3
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 +9 -0
- data/README.md +14 -2
- data/VERSION +1 -1
- data/app/db_gui/model/db.rb +30 -7
- data/app/db_gui/view/db_gui_application.rb +2 -67
- data/app/db_gui/view/db_gui_menu_bar.rb +83 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e8f8e99fbe6234688995ab9ba3c043520735be325f436d6a77b6645c000f949
|
4
|
+
data.tar.gz: ff6bbf33071bb6820260f6d583c448d218c448b9b304f242c2a448f197262c8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb7ca28a2bc3c176c364e2708b8c2793d2b1cb0bb13e117511b83d4c35a021b76a47621a43cd6e41dacc3995c8d1e2e326946205dcd879a89e882560a01923ef
|
7
|
+
data.tar.gz: 9266bf6fe826ca5045f0c0819c8a9a673d5cb654465f5fa0366c3103e27f3fd7d896d3ee47a2f533ff734bc1a41c93b5d0e728b7ed4ffb9e7aba94e062fbdb10
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 0.2.3
|
4
|
+
|
5
|
+
- Edit -> Copy Table (with query & headers) menu item to copy table data with query (e.g. SQL) & headers as a formatted string to the clipboard
|
6
|
+
|
7
|
+
## 0.2.2
|
8
|
+
|
9
|
+
- Edit -> Copy Table (with headers) menu item to copy table data with headers as a formatted string to the clipboard
|
10
|
+
- Edit -> Copy Selected Row (with headers) menu item to copy selected row data with headers as a formatted string to the clipboard
|
11
|
+
|
3
12
|
## 0.2.1
|
4
13
|
|
5
14
|
- Fix bug in 0.2.0 with crashing whenever running a DB query for the second time.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# DB GUI (Database Graphical User Interface) 0.2.
|
1
|
+
# DB GUI (Database Graphical User Interface) 0.2.3
|
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.2.
|
15
|
+
gem install db-gui -v0.2.3
|
16
16
|
```
|
17
17
|
|
18
18
|
## Usage
|
@@ -32,10 +32,22 @@ Note that it stores the last connection details under `~/.db_gui`, and will auto
|
|
32
32
|
|
33
33
|
Click on this menu item to copy the table data as a formatted string to the clipboard.
|
34
34
|
|
35
|
+
**Edit -> Copy Table (with headers)**
|
36
|
+
|
37
|
+
Click on this menu item to copy the table data with headers as a formatted string to the clipboard.
|
38
|
+
|
39
|
+
**Edit -> Copy Table (with query & headers)**
|
40
|
+
|
41
|
+
Click on this menu item to copy the table data with query (e.g. SQL) & headers as a formatted string to the clipboard.
|
42
|
+
|
35
43
|
**Edit -> Copy Selected Row**
|
36
44
|
|
37
45
|
Click on this menu item to copy the selected row data as a formatted string to the clipboard.
|
38
46
|
|
47
|
+
**Edit -> Copy Selected Row (with headers)**
|
48
|
+
|
49
|
+
Click on this menu item to copy the selected row data with headers as a formatted string to the clipboard.
|
50
|
+
|
39
51
|
## Change Log
|
40
52
|
|
41
53
|
[CHANGELOG.md](/CHANGELOG.md)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/app/db_gui/model/db.rb
CHANGED
@@ -103,23 +103,45 @@ class DbGui
|
|
103
103
|
Clipboard.copy(formatted_table_string)
|
104
104
|
end
|
105
105
|
|
106
|
+
def copy_table_with_headers
|
107
|
+
return if db_command_result_rows.empty?
|
108
|
+
Clipboard.copy(formatted_table_string(include_headers: true))
|
109
|
+
end
|
110
|
+
|
111
|
+
def copy_table_with_query_and_headers
|
112
|
+
return if db_command_result_rows.empty?
|
113
|
+
Clipboard.copy(formatted_table_string(include_query: true, include_headers: true))
|
114
|
+
end
|
115
|
+
|
106
116
|
def copy_selected_row
|
107
117
|
return if db_command_result_rows.empty?
|
108
118
|
Clipboard.copy(formatted_selected_row_string)
|
109
119
|
end
|
110
120
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
121
|
+
def copy_selected_row_with_headers
|
122
|
+
return if db_command_result_rows.empty?
|
123
|
+
Clipboard.copy(formatted_selected_row_string(include_headers: true))
|
124
|
+
end
|
125
|
+
|
126
|
+
def formatted_table_string(rows = nil, include_query: false, include_headers: false)
|
127
|
+
rows ||= db_command_result_rows
|
128
|
+
rows = rows.dup
|
129
|
+
rows.prepend(db_command_result_headers) if include_headers
|
130
|
+
column_max_lengths = row_column_max_lengths(rows) # TODO calculate those after prepending headers
|
131
|
+
formatted_string = rows.map do |row|
|
114
132
|
row.each_with_index.map do |data, column_index|
|
115
133
|
data.ljust(column_max_lengths[column_index])
|
116
134
|
end.join(" | ")
|
117
135
|
end.join(NEW_LINE)
|
136
|
+
formatted_string.prepend("#{db_command}\n\n") if include_query
|
137
|
+
formatted_string
|
118
138
|
end
|
119
139
|
|
120
|
-
def formatted_selected_row_string
|
140
|
+
def formatted_selected_row_string(include_headers: false)
|
121
141
|
selected_row = db_command_result_rows[db_command_result_selection]
|
122
142
|
selected_row.join(' | ')
|
143
|
+
rows = [selected_row]
|
144
|
+
formatted_table_string(rows, include_headers:)
|
123
145
|
end
|
124
146
|
|
125
147
|
private
|
@@ -203,10 +225,11 @@ class DbGui
|
|
203
225
|
[count, headers, rows]
|
204
226
|
end
|
205
227
|
|
206
|
-
def
|
207
|
-
|
228
|
+
def row_column_max_lengths(rows = nil)
|
229
|
+
rows ||= db_command_result_rows
|
230
|
+
column_count = rows.first.size
|
208
231
|
column_max_lengths = []
|
209
|
-
|
232
|
+
rows.each do |row|
|
210
233
|
row.each_with_index do |value, column_index|
|
211
234
|
column_max_lengths[column_index] ||= 0
|
212
235
|
column_max_lengths[column_index] = [column_max_lengths[column_index], value.size].max
|
@@ -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,72 +35,6 @@ class DbGui
|
|
34
35
|
}
|
35
36
|
}
|
36
37
|
}
|
37
|
-
|
38
|
-
def menu_bar
|
39
|
-
menu('Edit') {
|
40
|
-
menu_item('Copy Table') {
|
41
|
-
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
42
|
-
|
43
|
-
on_clicked do
|
44
|
-
db.copy_table
|
45
|
-
end
|
46
|
-
}
|
47
|
-
|
48
|
-
menu_item('Copy Selected Row') {
|
49
|
-
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
50
|
-
|
51
|
-
on_clicked do
|
52
|
-
db.copy_selected_row
|
53
|
-
end
|
54
|
-
}
|
55
|
-
|
56
|
-
quit_menu_item if OS.mac?
|
57
|
-
}
|
58
|
-
menu('Help') {
|
59
|
-
if OS.mac?
|
60
|
-
about_menu_item {
|
61
|
-
on_clicked do
|
62
|
-
display_about_dialog
|
63
|
-
end
|
64
|
-
}
|
65
|
-
end
|
66
|
-
|
67
|
-
menu_item('About') {
|
68
|
-
on_clicked do
|
69
|
-
display_about_dialog
|
70
|
-
end
|
71
|
-
}
|
72
|
-
}
|
73
|
-
end
|
74
|
-
|
75
|
-
def display_about_dialog
|
76
|
-
message = "DB GUI #{VERSION}\n\n#{LICENSE}"
|
77
|
-
msg_box('About', message)
|
78
|
-
end
|
79
|
-
|
80
|
-
# def display_preferences_dialog
|
81
|
-
# window {
|
82
|
-
# title 'Preferences'
|
83
|
-
# content_size 200, 100
|
84
|
-
#
|
85
|
-
# margined true
|
86
|
-
#
|
87
|
-
# vertical_box {
|
88
|
-
# padded true
|
89
|
-
#
|
90
|
-
# label('Greeting:') {
|
91
|
-
# stretchy false
|
92
|
-
# }
|
93
|
-
#
|
94
|
-
# radio_buttons {
|
95
|
-
# stretchy false
|
96
|
-
#
|
97
|
-
# items Model::Greeting::GREETINGS
|
98
|
-
# selected <=> [@greeting, :text_index]
|
99
|
-
# }
|
100
|
-
# }
|
101
|
-
# }.show
|
102
|
-
# end
|
103
38
|
end
|
104
39
|
end
|
105
40
|
end
|
@@ -0,0 +1,83 @@
|
|
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 Table (with query & headers)') {
|
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_table_with_query_and_headers
|
39
|
+
end
|
40
|
+
}
|
41
|
+
|
42
|
+
menu_item('Copy Selected Row') {
|
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
|
47
|
+
end
|
48
|
+
}
|
49
|
+
|
50
|
+
menu_item('Copy Selected Row (with headers)') {
|
51
|
+
enabled <= [db, :db_command_result_rows, computed_by: :db_command_result, on_read: -> (data) { !data.empty? }]
|
52
|
+
|
53
|
+
on_clicked do
|
54
|
+
db.copy_selected_row_with_headers
|
55
|
+
end
|
56
|
+
}
|
57
|
+
|
58
|
+
quit_menu_item if OS.mac?
|
59
|
+
}
|
60
|
+
menu('Help') {
|
61
|
+
if OS.mac?
|
62
|
+
about_menu_item {
|
63
|
+
on_clicked do
|
64
|
+
display_about_dialog
|
65
|
+
end
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
menu_item('About') {
|
70
|
+
on_clicked do
|
71
|
+
display_about_dialog
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def display_about_dialog
|
79
|
+
message = "DB GUI #{VERSION}\n\n#{LICENSE}"
|
80
|
+
msg_box('About', message)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-gui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- app/db_gui/view/db_command_result_table.rb
|
105
105
|
- app/db_gui/view/db_config_form.rb
|
106
106
|
- app/db_gui/view/db_gui_application.rb
|
107
|
+
- app/db_gui/view/db_gui_menu_bar.rb
|
107
108
|
- bin/db-gui
|
108
109
|
- bin/db-ui
|
109
110
|
- bin/dbgui
|