db-gui 0.2.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 +5 -0
- data/README.md +11 -2
- data/VERSION +1 -1
- data/app/db_gui/model/db.rb +23 -7
- data/app/db_gui/view/db_gui_application.rb +2 -67
- data/app/db_gui/view/db_gui_menu_bar.rb +75 -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: 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,10 @@
|
|
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
|
+
|
3
8
|
## 0.2.1
|
4
9
|
|
5
10
|
- 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.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.2.
|
15
|
+
gem install db-gui -v0.2.2
|
16
16
|
```
|
17
17
|
|
18
18
|
## Usage
|
@@ -32,10 +32,19 @@ 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
|
+
|
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
|
+
|
35
40
|
**Edit -> Copy Selected Row**
|
36
41
|
|
37
42
|
Click on this menu item to copy the selected row data as a formatted string to the clipboard.
|
38
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
|
+
|
39
48
|
## Change Log
|
40
49
|
|
41
50
|
[CHANGELOG.md](/CHANGELOG.md)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/app/db_gui/model/db.rb
CHANGED
@@ -108,18 +108,33 @@ class DbGui
|
|
108
108
|
Clipboard.copy(formatted_selected_row_string)
|
109
109
|
end
|
110
110
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
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|
|
114
127
|
row.each_with_index.map do |data, column_index|
|
115
128
|
data.ljust(column_max_lengths[column_index])
|
116
129
|
end.join(" | ")
|
117
130
|
end.join(NEW_LINE)
|
118
131
|
end
|
119
132
|
|
120
|
-
def formatted_selected_row_string
|
133
|
+
def formatted_selected_row_string(include_headers: false)
|
121
134
|
selected_row = db_command_result_rows[db_command_result_selection]
|
122
135
|
selected_row.join(' | ')
|
136
|
+
rows = [selected_row]
|
137
|
+
formatted_table_string(rows, include_headers:)
|
123
138
|
end
|
124
139
|
|
125
140
|
private
|
@@ -203,10 +218,11 @@ class DbGui
|
|
203
218
|
[count, headers, rows]
|
204
219
|
end
|
205
220
|
|
206
|
-
def
|
207
|
-
|
221
|
+
def row_column_max_lengths(rows = nil)
|
222
|
+
rows ||= db_command_result_rows
|
223
|
+
column_count = rows.first.size
|
208
224
|
column_max_lengths = []
|
209
|
-
|
225
|
+
rows.each do |row|
|
210
226
|
row.each_with_index do |value, column_index|
|
211
227
|
column_max_lengths[column_index] ||= 0
|
212
228
|
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,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,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.2
|
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
|