redix 0.0.3 → 0.0.4
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/VERSION +1 -1
- data/lib/redix/logic.rb +31 -15
- data/lib/redix/qtui.rb +59 -15
- data/redix.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/redix/logic.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
2
|
module Redix
|
3
3
|
|
4
|
-
class Logic
|
5
|
-
|
4
|
+
class Logic < Qt::Object # =/
|
5
|
+
slots :reload, :help, :connect
|
6
6
|
|
7
7
|
class << self
|
8
8
|
|
@@ -24,6 +24,7 @@ module Redix
|
|
24
24
|
def failure(f)
|
25
25
|
@u.statusbar.showMessage(f)
|
26
26
|
end
|
27
|
+
alias :message :failure
|
27
28
|
|
28
29
|
def build_dbs
|
29
30
|
0.upto(15) do |i|
|
@@ -36,11 +37,13 @@ module Redix
|
|
36
37
|
end
|
37
38
|
|
38
39
|
def build_keys
|
40
|
+
all = r.keys.sort
|
39
41
|
@u.listWidget.clear
|
40
|
-
@u.listWidget.addItems(
|
41
|
-
|
42
|
+
@u.listWidget.addItems(all)
|
43
|
+
puts r.info
|
44
|
+
message "DB Loaded #{all.size} keys. Used memory #{r.info['used_memory_human']}"
|
45
|
+
rescue
|
42
46
|
failure "Could not conect to redis"
|
43
|
-
|
44
47
|
end
|
45
48
|
|
46
49
|
def connect
|
@@ -57,16 +60,32 @@ module Redix
|
|
57
60
|
a = AboutDialog.new
|
58
61
|
a.setupUi
|
59
62
|
# a.title.setText("RediX")
|
60
|
-
a.textBrowser.setHtml("About <a href='http://github.com/nofxx/redix'>Redix</a
|
63
|
+
a.textBrowser.setHtml("About <a href='http://github.com/nofxx/redix'>Redix</a><p>Marcos Piccinini</p>")
|
61
64
|
a.show
|
62
65
|
end
|
63
66
|
|
64
67
|
def new_key
|
65
68
|
k = NewKeyDialog.new
|
66
69
|
k.setupUi
|
70
|
+
k.buttonBox.connect(SIGNAL('accepted()')) { create_key(k) }
|
67
71
|
k.show
|
68
72
|
end
|
69
73
|
|
74
|
+
def create_key(k, type = nil, v = nil)
|
75
|
+
|
76
|
+
unless type
|
77
|
+
type = k.input_type.current_text
|
78
|
+
v = k.input_value.text
|
79
|
+
k = k.input_name.text
|
80
|
+
end
|
81
|
+
case type
|
82
|
+
when 'string' then r.set(k, v)
|
83
|
+
when 'hash' then r.hmset(k, v)
|
84
|
+
when 'list' then r.add(k, v)
|
85
|
+
when 'set' then r.sadd(k, v)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
70
89
|
def for(u)
|
71
90
|
@u = u
|
72
91
|
build_keys
|
@@ -153,24 +172,21 @@ module Redix
|
|
153
172
|
end
|
154
173
|
|
155
174
|
def setData(mid, var, *args)
|
156
|
-
p "SETDATA #{mid} | #{var}"
|
157
|
-
p mid
|
158
175
|
r = Logic.r
|
159
|
-
|
176
|
+
v = var.toString
|
160
177
|
case @type
|
161
|
-
when 'string' then r.set(@key,
|
162
|
-
when 'hash' then r.hset(@key, @header[mid.row],
|
163
|
-
when 'list' then r.lset(@key, mid.row,
|
178
|
+
when 'string' then r.set(@key, v)
|
179
|
+
when 'hash' then r.hset(@key, @header[mid.row], v)
|
180
|
+
when 'list' then r.lset(@key, mid.row, v)
|
164
181
|
when 'set'
|
165
182
|
r.srem(@key, @rows[mid.row])
|
166
|
-
r.sadd(@key,
|
183
|
+
r.sadd(@key, v)
|
167
184
|
end
|
168
|
-
p args
|
169
185
|
self.for(@key)
|
170
186
|
end
|
171
187
|
|
172
188
|
def setHeaderData(*args)
|
173
|
-
p args
|
189
|
+
p "Set Header -> #{args}"
|
174
190
|
end
|
175
191
|
|
176
192
|
def headerData sec, orient, role = Qt::DisplayRole
|
data/lib/redix/qtui.rb
CHANGED
@@ -10,8 +10,10 @@ class Ui_MainWindow < Qt::MainWindow
|
|
10
10
|
attr_reader :tableView, :lineEdit, :textBrowser
|
11
11
|
attr_reader :menubar, :menuKey, :menuDB, :menuChange, :menuHelp
|
12
12
|
attr_reader :statusbar, :mainWindow
|
13
|
+
KEYS = (0..9)
|
13
14
|
|
14
15
|
slots :reload, :help, :connect, :new_key
|
16
|
+
eval(("slots " + (KEYS.map { |i| ":connect#{i}" }.join ", ")))
|
15
17
|
|
16
18
|
def setupUi #(self)
|
17
19
|
if self.objectName.nil?
|
@@ -91,7 +93,11 @@ class Ui_MainWindow < Qt::MainWindow
|
|
91
93
|
|
92
94
|
retranslateUi
|
93
95
|
|
96
|
+
# 0-9 Keys Shortcuts
|
97
|
+
KEYS.each { |k| Qt::Shortcut.new(Qt::KeySequence.new(eval("Qt::Key_#{k}").to_i), self, SLOT("connect#{k}()")) }
|
98
|
+
|
94
99
|
Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_C.to_i), self, SLOT('connect()'))
|
100
|
+
Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_N.to_i), self, SLOT('new_key()'))
|
95
101
|
Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F1.to_i), self, SLOT('help()'))
|
96
102
|
Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F2.to_i), self, SLOT('new_key()'))
|
97
103
|
Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_F5.to_i), self, SLOT('reload()'))
|
@@ -99,20 +105,28 @@ class Ui_MainWindow < Qt::MainWindow
|
|
99
105
|
Qt::MetaObject.connectSlotsByName(self)
|
100
106
|
end # setupUi
|
101
107
|
|
102
|
-
def connect
|
103
|
-
Redix::Logic.
|
108
|
+
def connect(db = nil)
|
109
|
+
Redix::Logic.connect
|
104
110
|
end
|
105
111
|
|
106
112
|
def new_key
|
107
113
|
Redix::Logic.new_key
|
108
114
|
end
|
109
115
|
|
116
|
+
def method_missing(*args)
|
117
|
+
if args.join =~ /^connect/
|
118
|
+
Redix::Logic.reconnect(args.join.scan(/\d/)[0].to_i)
|
119
|
+
else
|
120
|
+
super
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
110
124
|
def reload
|
111
125
|
Redix::Logic.reconnect
|
112
126
|
end
|
113
127
|
|
114
128
|
def help
|
115
|
-
Redix::Logic.
|
129
|
+
Redix::Logic.help
|
116
130
|
end
|
117
131
|
|
118
132
|
def setup_ui
|
@@ -142,37 +156,55 @@ class Ui_MainWindow < Qt::MainWindow
|
|
142
156
|
|
143
157
|
end
|
144
158
|
|
145
|
-
|
159
|
+
#
|
160
|
+
#
|
161
|
+
# New Key
|
162
|
+
#
|
163
|
+
#
|
164
|
+
#
|
146
165
|
class NewKeyDialog < Qt::Dialog
|
147
166
|
attr_reader :data
|
148
167
|
attr_reader :buttonBox
|
149
168
|
attr_reader :input_name
|
150
169
|
attr_reader :input_type
|
170
|
+
attr_reader :input_value
|
151
171
|
|
152
172
|
|
153
173
|
def updateData(new)
|
154
174
|
@data = new
|
155
175
|
end
|
176
|
+
|
156
177
|
def setupUi(dialog = self)
|
157
178
|
|
158
179
|
@buttonBox = Qt::DialogButtonBox.new(dialog)
|
159
180
|
@buttonBox.objectName = "buttonBox"
|
160
|
-
@buttonBox.geometry = Qt::Rect.new(30,
|
181
|
+
@buttonBox.geometry = Qt::Rect.new(30, 130, 341, 32)
|
161
182
|
@buttonBox.orientation = Qt::Horizontal
|
162
183
|
@buttonBox.standardButtons = Qt::DialogButtonBox::Cancel|Qt::DialogButtonBox::Ok
|
184
|
+
|
185
|
+
@input_type = Qt::ComboBox.new(dialog)
|
186
|
+
@input_type.objectName = "input_type"
|
187
|
+
@input_type.geometry = Qt::Rect.new(70, 20, 311, 22)
|
188
|
+
@input_type.addItems(["string", "list", "set", "zset", "hash", "channel"])
|
189
|
+
@label_type = Qt::Label.new(dialog)
|
190
|
+
@label_type.objectName = "label_type"
|
191
|
+
@label_type.geometry = Qt::Rect.new(20, 23, 61, 21)
|
192
|
+
|
193
|
+
|
163
194
|
@input_name = Qt::LineEdit.new(dialog)
|
164
195
|
@input_name.objectName = "input_name"
|
165
|
-
@input_name.geometry = Qt::Rect.new(70,
|
196
|
+
@input_name.geometry = Qt::Rect.new(70, 50, 311, 22)
|
166
197
|
@label = Qt::Label.new(dialog)
|
167
198
|
@label.objectName = "label"
|
168
|
-
@label.geometry = Qt::Rect.new(20,
|
199
|
+
@label.geometry = Qt::Rect.new(20, 53, 61, 21)
|
200
|
+
|
201
|
+
@input_value = Qt::LineEdit.new(dialog)
|
202
|
+
@input_value.objectName = "input_value"
|
203
|
+
@input_value.geometry = Qt::Rect.new(70, 80, 311, 22)
|
204
|
+
@label_value = Qt::Label.new(dialog)
|
205
|
+
@label_value.objectName = "label_value"
|
206
|
+
@label_value.geometry = Qt::Rect.new(20, 83, 61, 21)
|
169
207
|
|
170
|
-
@input_type = Qt::LineEdit.new(dialog)
|
171
|
-
@input_type.objectName = "input_type"
|
172
|
-
@input_type.geometry = Qt::Rect.new(70, 50, 311, 22)
|
173
|
-
@label_type = Qt::Label.new(dialog)
|
174
|
-
@label_type.objectName = "label_type"
|
175
|
-
@label_type.geometry = Qt::Rect.new(20, 53, 61, 21)
|
176
208
|
|
177
209
|
retranslateUi(dialog)
|
178
210
|
Qt::Object.connect(@buttonBox, SIGNAL('accepted()'), dialog, SLOT('accept()'))
|
@@ -187,8 +219,9 @@ class NewKeyDialog < Qt::Dialog
|
|
187
219
|
|
188
220
|
def retranslateUi(dialog)
|
189
221
|
dialog.windowTitle = Qt::Application.translate("Dialog", "New Key", nil, Qt::Application::UnicodeUTF8)
|
190
|
-
@label.text = Qt::Application.translate("Dialog", "
|
222
|
+
@label.text = Qt::Application.translate("Dialog", "Key", nil, Qt::Application::UnicodeUTF8)
|
191
223
|
@label_type.text = Qt::Application.translate("Dialog", "Type", nil, Qt::Application::UnicodeUTF8)
|
224
|
+
@label_value.text = Qt::Application.translate("Dialog", "Value", nil, Qt::Application::UnicodeUTF8)
|
192
225
|
end # retranslateUi
|
193
226
|
|
194
227
|
def retranslate_ui(dialog)
|
@@ -197,6 +230,12 @@ class NewKeyDialog < Qt::Dialog
|
|
197
230
|
|
198
231
|
end
|
199
232
|
|
233
|
+
#
|
234
|
+
#
|
235
|
+
# Connect
|
236
|
+
#
|
237
|
+
#
|
238
|
+
#
|
200
239
|
class ConnectDialog < Qt::Dialog
|
201
240
|
attr_reader :data
|
202
241
|
attr_reader :buttonBox
|
@@ -254,7 +293,12 @@ class ConnectDialog < Qt::Dialog
|
|
254
293
|
|
255
294
|
end
|
256
295
|
|
257
|
-
|
296
|
+
#
|
297
|
+
#
|
298
|
+
# About
|
299
|
+
#
|
300
|
+
#
|
301
|
+
#
|
258
302
|
class AboutDialog < Qt::Dialog
|
259
303
|
attr_reader :data
|
260
304
|
attr_reader :title
|
data/redix.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{redix}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marcos Piccinini"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-21}
|
13
13
|
s.default_executable = %q{redix}
|
14
14
|
s.description = %q{QT GUI for Redis Beta}
|
15
15
|
s.email = %q{x@nofxx.com}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Marcos Piccinini
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-21 00:00:00 -02:00
|
18
18
|
default_executable: redix
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|