kgem 0.1.0
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/MIT-LICENSE +19 -0
- data/README +36 -0
- data/Rakefile +79 -0
- data/bin/gemcmdwin-super.rb +0 -0
- data/bin/gemcmdwin.rb +342 -0
- data/bin/kgem.rb +327 -0
- data/ext/Rakefile +65 -0
- data/lib/downloadedwin.rb +251 -0
- data/lib/gemcmddlgs.rb +350 -0
- data/lib/gemhelpdlg.rb +74 -0
- data/lib/gemitem.rb +162 -0
- data/lib/gemviews.rb +554 -0
- data/lib/installedwin.rb +286 -0
- data/lib/mylibs.rb +407 -0
- data/lib/previewwin.rb +80 -0
- data/lib/searchwin.rb +151 -0
- data/lib/settings.rb +205 -0
- data/pkg_resources/gemcmdwin-super.rb.pam +8 -0
- metadata +89 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 ruby.twiddler@gmail.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "kgem"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Kgem is KDE GUI for ruby gem tool.
|
2
|
+
You can install/uninstall/update/download gems just clicking around,
|
3
|
+
search to find gem, browsing source files in gems without installing these gems.
|
4
|
+
You don't need to remember gem's command and options any more.
|
5
|
+
|
6
|
+
|
7
|
+
Prerequisite
|
8
|
+
================
|
9
|
+
kgem requires kdebindings4. (http://download.kde.org/download.php?url=stable/4.5.0/src/kdebindings-4.5.0.tar.bz2
|
10
|
+
)
|
11
|
+
Check your linux distro package to install. Major linux distros have kdebindings package.
|
12
|
+
Installing from distro package is the most easiest and safest way.
|
13
|
+
kgem also requires rubygems.
|
14
|
+
|
15
|
+
Install
|
16
|
+
===========
|
17
|
+
just type gem command.
|
18
|
+
gem install kgem
|
19
|
+
|
20
|
+
or download latest gems from github and rake to install gem.
|
21
|
+
git clone git@github.com:rubytwiddler/kgem.git
|
22
|
+
cd kgem
|
23
|
+
rake gem
|
24
|
+
sudo rake installgem
|
25
|
+
|
26
|
+
More informatin on Web
|
27
|
+
==========================
|
28
|
+
http://github.com/rubytwiddler/kgem/wiki
|
29
|
+
|
30
|
+
|
31
|
+
Bug report. feature request.
|
32
|
+
==========================
|
33
|
+
http://github.com/rubytwiddler/kgem/issues
|
34
|
+
|
35
|
+
|
36
|
+
License : MIT-LICENSE. read MIT-LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
|
7
|
+
spec = Gem::Specification.new do |s|
|
8
|
+
s.name = "kgem"
|
9
|
+
s.version = "0.1.0"
|
10
|
+
s.author = "ruby.twiddler"
|
11
|
+
s.email = "ruby.twiddler at gmail.com"
|
12
|
+
s.homepage = "http://github.com/rubytwiddler/kgem/wiki"
|
13
|
+
s.summary = "KDE GUI for ruby gem."
|
14
|
+
s.files = FileList["{bin,lib}/*"].to_a
|
15
|
+
s.files += %w{ README MIT-LICENSE Rakefile pkg_resources/gemcmdwin-super.rb.pam }
|
16
|
+
s.executables = [ 'kgem.rb' ]
|
17
|
+
s.extensions = [ 'ext/Rakefile' ]
|
18
|
+
s.require_path = "lib"
|
19
|
+
s.requirements = %w{ korundum4 }
|
20
|
+
s.description = <<-EOF
|
21
|
+
Kgem is KDE GUI for ruby gem tool.
|
22
|
+
You can install/uninstall/update/download gems just clicking around,
|
23
|
+
search to find gem, browsing source files in gems without installing these gems.
|
24
|
+
You don't need to remember gem's command and options any more.
|
25
|
+
EOF
|
26
|
+
s.has_rdoc = false
|
27
|
+
s.extra_rdoc_files = ["README"]
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'ftools'
|
31
|
+
APP_DIR = File.expand_path(File.dirname(__FILE__))
|
32
|
+
RES_DIR = File::join(APP_DIR, "pkg_resources")
|
33
|
+
def install_console_helper(console_helper_name, target_cmd_name)
|
34
|
+
etc_dir = ENV['etc_dir'] || '/etc'
|
35
|
+
|
36
|
+
console_helper_link = File.join(APP_DIR, 'bin', console_helper_name)
|
37
|
+
cmd_path = File.join(APP_DIR, 'bin', target_cmd_name)
|
38
|
+
pam_src_path = File.join( RES_DIR, console_helper_name + '.pam' )
|
39
|
+
pam_dst_path = File.join(etc_dir, 'pam.d', console_helper_name)
|
40
|
+
console_app_file = File.join(etc_dir, 'security', 'console.apps', console_helper_name)
|
41
|
+
console_helper_target = %x{ which consolehelper }.strip!
|
42
|
+
|
43
|
+
puts "cp #{pam_src_path} #{pam_dst_path}"
|
44
|
+
puts "ln -s #{console_helper_target} #{console_helper_link}"
|
45
|
+
puts "write #{console_app_file}"
|
46
|
+
|
47
|
+
File.cp(pam_src_path, pam_dst_path)
|
48
|
+
if File.exist?(console_helper_link) then
|
49
|
+
File.unlink(console_helper_link)
|
50
|
+
end
|
51
|
+
File.symlink(console_helper_target, console_helper_link)
|
52
|
+
|
53
|
+
open(console_app_file, 'w') do |f|
|
54
|
+
f.write(<<-EOF
|
55
|
+
USER=root
|
56
|
+
PROGRAM=#{cmd_path}
|
57
|
+
FALLBACK=false
|
58
|
+
SESSION=true
|
59
|
+
EOF
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
package = Rake::GemPackageTask.new(spec) do |pkg|
|
67
|
+
pkg.need_tar = true
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "install as gem package"
|
71
|
+
task :installgem => :gem do
|
72
|
+
system("gem install -l pkg/" + package.gem_file )
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
desc "install pam"
|
77
|
+
task :installpam do
|
78
|
+
install_console_helper('gemcmdwin-super.rb', 'gemcmdwin.rb')
|
79
|
+
end
|
Binary file
|
data/bin/gemcmdwin.rb
ADDED
@@ -0,0 +1,342 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubygems/gem_runner'
|
5
|
+
require 'rubygems/exceptions'
|
6
|
+
|
7
|
+
required_version = Gem::Requirement.new "> 1.8.3"
|
8
|
+
|
9
|
+
unless required_version.satisfied_by? Gem.ruby_version then
|
10
|
+
abort "Expected Ruby Version #{required_version}, was #{Gem.ruby_version}"
|
11
|
+
end
|
12
|
+
|
13
|
+
#--------------------------------------------------------------------------
|
14
|
+
#
|
15
|
+
require 'ftools'
|
16
|
+
|
17
|
+
APP_NAME = File.basename(__FILE__).sub(/\.rb/, '')
|
18
|
+
APP_DIR = File::dirname(File.expand_path(File.dirname(__FILE__)))
|
19
|
+
LIB_DIR = File::join(APP_DIR, "lib")
|
20
|
+
APP_VERSION = "0.1.0"
|
21
|
+
|
22
|
+
# standard libs
|
23
|
+
require 'fileutils'
|
24
|
+
|
25
|
+
# additional libs
|
26
|
+
require 'korundum4'
|
27
|
+
|
28
|
+
#
|
29
|
+
# my libraries and programs
|
30
|
+
#
|
31
|
+
require "#{LIB_DIR}/mylibs"
|
32
|
+
|
33
|
+
|
34
|
+
#--------------------------------------------------------------------------
|
35
|
+
#
|
36
|
+
#
|
37
|
+
class ChooseListDlg < Qt::Dialog
|
38
|
+
def initialize(parent)
|
39
|
+
super(parent)
|
40
|
+
self.windowTitle = 'RubyGem Asking Choose from List.'
|
41
|
+
|
42
|
+
# createWidget
|
43
|
+
@msgLine = Qt::Label.new
|
44
|
+
@msgLine.wordWrap = true
|
45
|
+
@table = Qt::TableWidget.new(0,1)
|
46
|
+
@table.horizontalHeader.stretchLastSection = true
|
47
|
+
@table.selectionMode = Qt::AbstractItemView::SingleSelection
|
48
|
+
@table.selectionBehavior = Qt::AbstractItemView::SelectRows
|
49
|
+
@okBtn = KDE::PushButton.new(KDE::Icon.new('dialog-ok'), 'OK')
|
50
|
+
@cancelBtn = KDE::PushButton.new(KDE::Icon.new('dialog-cancel'), 'Cancel')
|
51
|
+
connect(@okBtn, SIGNAL(:clicked), self, SLOT(:accept))
|
52
|
+
connect(@cancelBtn, SIGNAL(:clicked), self, SLOT(:reject))
|
53
|
+
|
54
|
+
# layout
|
55
|
+
layout.dispose if layout
|
56
|
+
lo = Qt::VBoxLayout.new do |l|
|
57
|
+
l.addWidget(@msgLine)
|
58
|
+
l.addWidget(@table)
|
59
|
+
l.addWidgetAtRight(@okBtn, @cancelBtn)
|
60
|
+
end
|
61
|
+
lo.setStretch(0, 0)
|
62
|
+
lo.setStretch(1, 1)
|
63
|
+
setLayout(lo)
|
64
|
+
end
|
65
|
+
|
66
|
+
def ask(question, list)
|
67
|
+
@msgLine.text = question
|
68
|
+
@table.clearContents
|
69
|
+
@table.rowCount = list.length
|
70
|
+
list.each_with_index do |l, r|
|
71
|
+
item = Qt::TableWidgetItem.new(l)
|
72
|
+
item.flags = 1 | 32 # Qt::GraphicsItem::ItemIsSelectable | Qt::GraphicsItem::ItemIsEnabled
|
73
|
+
@table.setItem(r, 0, item)
|
74
|
+
end
|
75
|
+
@table.selectRow(list.length-1)
|
76
|
+
ret = exec
|
77
|
+
return nil, nil unless @table.currentItem && ret == Qt::Dialog::Accepted
|
78
|
+
row = @table.currentItem.row
|
79
|
+
[list[row], row]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class AskDlg < Qt::Dialog
|
84
|
+
def initialize(parent)
|
85
|
+
super(parent)
|
86
|
+
self.windowTitle = 'RubyGem Asking.'
|
87
|
+
|
88
|
+
# createWidget
|
89
|
+
@msgLine = Qt::Label.new
|
90
|
+
@msgLine.wordWrap = true
|
91
|
+
@lineEdit = Qt::LineEdit.new
|
92
|
+
@okBtn = KDE::PushButton.new(KDE::Icon.new('dialog-ok'), 'OK')
|
93
|
+
connect(@okBtn, SIGNAL(:clicked), self, SLOT(:accept))
|
94
|
+
|
95
|
+
# layout
|
96
|
+
lo = Qt::VBoxLayout.new do |l|
|
97
|
+
l.addWidget(@msgLine)
|
98
|
+
l.addWidget(@lineEdit)
|
99
|
+
l.addWidgetAtRight(@okBtn)
|
100
|
+
end
|
101
|
+
setLayout(lo)
|
102
|
+
end
|
103
|
+
|
104
|
+
def ask(question)
|
105
|
+
@msgLine.text = question
|
106
|
+
@lineEdit.text = ''
|
107
|
+
exec
|
108
|
+
@lineEdit.text
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class YesNoDlg < Qt::Dialog
|
113
|
+
def initialize(parent)
|
114
|
+
super(parent)
|
115
|
+
self.windowTitle = 'RubyGem Asking Y/N.'
|
116
|
+
|
117
|
+
@msgLine = Qt::Label.new
|
118
|
+
@msgLine.wordWrap = true
|
119
|
+
@okBtn = KDE::PushButton.new(KDE::Icon.new('dialog-ok'), 'OK')
|
120
|
+
@cancelBtn = KDE::PushButton.new(KDE::Icon.new('dialog-cancel'), 'Cancel')
|
121
|
+
connect(@okBtn, SIGNAL(:clicked), self, SLOT(:accept))
|
122
|
+
connect(@cancelBtn, SIGNAL(:clicked), self, SLOT(:reject))
|
123
|
+
|
124
|
+
# layout
|
125
|
+
lo = Qt::VBoxLayout.new do |l|
|
126
|
+
l.addWidget(@msgLine)
|
127
|
+
l.addWidgetAtRight(@okBtn, @cancelBtn)
|
128
|
+
end
|
129
|
+
setLayout(lo)
|
130
|
+
end
|
131
|
+
|
132
|
+
def ask(question)
|
133
|
+
@msgLine.text = question
|
134
|
+
exec == Qt::Dialog::Accepted
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
#--------------------------------------------------------------------------
|
139
|
+
#
|
140
|
+
#
|
141
|
+
class MainWindow < KDE::MainWindow
|
142
|
+
slots :startCmd
|
143
|
+
|
144
|
+
def initialize(args)
|
145
|
+
super(nil)
|
146
|
+
# args.unshift('--backtrace')
|
147
|
+
@args = args
|
148
|
+
|
149
|
+
self.windowTitle = 'Ruby Gem'
|
150
|
+
createWidget
|
151
|
+
# initialize gem ui
|
152
|
+
@winUi = Gem::DefaultUserInteraction.ui = WinUI.new(self, @logWidget)
|
153
|
+
|
154
|
+
# config
|
155
|
+
setAutoSaveSettings()
|
156
|
+
|
157
|
+
Qt::Timer.singleShot(0, self, SLOT(:startCmd))
|
158
|
+
end
|
159
|
+
|
160
|
+
def createWidget
|
161
|
+
@logWidget = Qt::TextBrowser.new
|
162
|
+
@okBtn = KDE::PushButton.new(KDE::Icon.new('dialog-ok'), 'OK')
|
163
|
+
|
164
|
+
connect(@okBtn, SIGNAL(:clicked), self, SLOT(:close))
|
165
|
+
|
166
|
+
# layout
|
167
|
+
lw = VBoxLayoutWidget.new do |w|
|
168
|
+
w.addWidget(@logWidget)
|
169
|
+
w.addWidgetAtRight(@okBtn)
|
170
|
+
end
|
171
|
+
setCentralWidget( lw )
|
172
|
+
end
|
173
|
+
|
174
|
+
#------------------------------------
|
175
|
+
#
|
176
|
+
# virtual slot
|
177
|
+
def closeEvent(ev)
|
178
|
+
super(ev)
|
179
|
+
$config.sync # important! qtruby can't invoke destructor properly.
|
180
|
+
end
|
181
|
+
|
182
|
+
# slot
|
183
|
+
def startCmd
|
184
|
+
|
185
|
+
# testWinUi
|
186
|
+
|
187
|
+
begin
|
188
|
+
Gem::GemRunner.new.run @args
|
189
|
+
rescue Gem::SystemExitException => e
|
190
|
+
@winUi.write( e.message )
|
191
|
+
$exitCode = 1
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
def testWinUi
|
196
|
+
ret = @winUi.ask "test ask. what is your name?"
|
197
|
+
@winUi.write("your answer is " + ret)
|
198
|
+
|
199
|
+
ret = @winUi.ask "test ask long message.\nsome long explanation.\nwhat is your favourite food?"
|
200
|
+
@winUi.write("your answer is " + ret)
|
201
|
+
|
202
|
+
ret = @winUi.ask_yes_no "test ask Y/N."
|
203
|
+
@winUi.write("your answer is " + (ret ? "yes" : "no"))
|
204
|
+
|
205
|
+
ret = @winUi.choose_from_list "test choose.", %w{ zarusoba tensoba yamakakesoba nishinsoba }
|
206
|
+
@winUi.write("your answer is " + (ret[0] ? ret[0] : "none"))
|
207
|
+
|
208
|
+
@winUi.alert "test alert."
|
209
|
+
@winUi.alert_error "test alert_error."
|
210
|
+
@winUi.alert_warning "test alert_warning."
|
211
|
+
progress = @winUi.progress_reporter 10, "test progress."
|
212
|
+
10.times do |i|
|
213
|
+
sleep(0.1)
|
214
|
+
progress.updated "testing count : #{i}"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
#---------------------------
|
219
|
+
#
|
220
|
+
class WinUI
|
221
|
+
attr_reader :outs, :errs
|
222
|
+
def initialize(parent, outW)
|
223
|
+
@outs = @errs = OutStream.new(outW)
|
224
|
+
|
225
|
+
# dialogs
|
226
|
+
@askDlg = AskDlg.new(parent)
|
227
|
+
@yesnoDlg = YesNoDlg.new(parent)
|
228
|
+
@chooseListDlg = ChooseListDlg.new(parent)
|
229
|
+
end
|
230
|
+
|
231
|
+
def write(msg)
|
232
|
+
@outs.write(msg)
|
233
|
+
end
|
234
|
+
|
235
|
+
#
|
236
|
+
class OutStream
|
237
|
+
def initialize(outW)
|
238
|
+
@outWidget = outW
|
239
|
+
end
|
240
|
+
|
241
|
+
def write(msg)
|
242
|
+
STDOUT.puts msg
|
243
|
+
@outWidget.append(msg.to_s)
|
244
|
+
end
|
245
|
+
|
246
|
+
alias :puts :write
|
247
|
+
alias :print :write
|
248
|
+
|
249
|
+
def tty?
|
250
|
+
true
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
# ui methods
|
255
|
+
def choose_from_list(question, list)
|
256
|
+
@chooseListDlg.ask(question, list)
|
257
|
+
end
|
258
|
+
|
259
|
+
def ask_yes_no(question, default=nil)
|
260
|
+
@yesnoDlg.ask(question)
|
261
|
+
end
|
262
|
+
|
263
|
+
def ask(question)
|
264
|
+
@askDlg.ask(question)
|
265
|
+
end
|
266
|
+
|
267
|
+
def say(statement="")
|
268
|
+
write(statement)
|
269
|
+
end
|
270
|
+
|
271
|
+
def alert(statement, question=nil)
|
272
|
+
write("INFO: #{statement}")
|
273
|
+
ask(question) if question
|
274
|
+
end
|
275
|
+
|
276
|
+
def alert_warning(statement, question=nil)
|
277
|
+
write("WARNING: #{statement}")
|
278
|
+
ask(question) if question
|
279
|
+
end
|
280
|
+
|
281
|
+
def alert_error(statement, question=nil)
|
282
|
+
write("ERROR: #{statement}")
|
283
|
+
ask(question) if question
|
284
|
+
end
|
285
|
+
|
286
|
+
def debug(statement)
|
287
|
+
write(statement)
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
def terminate_interaction(status = 0)
|
292
|
+
raise Gem::SystemExitException, status
|
293
|
+
end
|
294
|
+
|
295
|
+
def progress_reporter(*args)
|
296
|
+
ProgressReporter.new(*args)
|
297
|
+
end
|
298
|
+
|
299
|
+
class ProgressReporter
|
300
|
+
def initialize(size, initial_message,
|
301
|
+
terminal_message = 'complete')
|
302
|
+
@progressDlg = Qt::ProgressDialog.new
|
303
|
+
@progressDlg.labelText = initial_message
|
304
|
+
@progressDlg.setRange(0, size)
|
305
|
+
@progressDlg.forceShow
|
306
|
+
@progressDlg.setWindowModality(Qt::WindowModal)
|
307
|
+
@count = 0
|
308
|
+
@terminal_message = terminal_message
|
309
|
+
end
|
310
|
+
|
311
|
+
def updated(message)
|
312
|
+
@progressDlg.labelText = message
|
313
|
+
@count += 1
|
314
|
+
@progressDlg.setValue(@count)
|
315
|
+
end
|
316
|
+
|
317
|
+
def done
|
318
|
+
@progressDlg.hide
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
#--------------------------------------------------------------------------
|
326
|
+
#
|
327
|
+
#
|
328
|
+
$exitCode = 0
|
329
|
+
|
330
|
+
about = KDE::AboutData.new(APP_NAME, nil, KDE::ki18n(APP_NAME), APP_VERSION)
|
331
|
+
KDE::CmdLineArgs.init([], about)
|
332
|
+
|
333
|
+
$app = KDE::Application.new
|
334
|
+
args = KDE::CmdLineArgs.parsedArgs()
|
335
|
+
$config = KDE::Global::config
|
336
|
+
win = MainWindow.new(ARGV)
|
337
|
+
$app.setTopWidget(win)
|
338
|
+
|
339
|
+
win.show
|
340
|
+
$app.exec
|
341
|
+
|
342
|
+
$exitCode
|