kgem 0.1.4 → 0.1.5
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/Rakefile +1 -1
- data/bin/gemcmdwin-super.rb +0 -0
- data/bin/kgem.rb +18 -11
- data/lib/downloadedwin.rb +1 -1
- data/lib/gemitem.rb +2 -1
- data/lib/gemsource.rb +156 -0
- data/lib/gemviews.rb +7 -12
- data/lib/mylibs.rb +9 -3
- metadata +12 -11
data/Rakefile
CHANGED
data/bin/gemcmdwin-super.rb
CHANGED
Binary file
|
data/bin/kgem.rb
CHANGED
@@ -12,7 +12,7 @@ APP_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
|
|
12
12
|
APP_NAME = File.basename(APP_FILE).sub(/\.rb/, '')
|
13
13
|
APP_DIR = File::dirname(File.expand_path(File.dirname(APP_FILE)))
|
14
14
|
LIB_DIR = File::join(APP_DIR, "lib")
|
15
|
-
APP_VERSION = "0.1.
|
15
|
+
APP_VERSION = "0.1.5"
|
16
16
|
|
17
17
|
|
18
18
|
# standard libs
|
@@ -42,6 +42,7 @@ require "previewwin"
|
|
42
42
|
require "gemcmddlgs"
|
43
43
|
require "gemviews"
|
44
44
|
require "gemhelpdlg"
|
45
|
+
require "gemsource"
|
45
46
|
|
46
47
|
#--------------------------------------------------------------------
|
47
48
|
#--------------------------------------------------------------------
|
@@ -117,9 +118,14 @@ class MainWindow < KDE::MainWindow
|
|
117
118
|
settingsMenu.addAction(configureShortCutAction)
|
118
119
|
settingsMenu.addAction(configureAppAction)
|
119
120
|
|
121
|
+
# source menu
|
122
|
+
sourceAction = @actions.addNew(i18n('Configure Gem Sources'), self, \
|
123
|
+
{ :icon => 'repository', :shortCut => 'F12', :triggered => :configureSources })
|
124
|
+
sourceMenu = KDE::Menu.new(i18n('Sources'))
|
125
|
+
sourceMenu.addAction(sourceAction)
|
120
126
|
|
121
127
|
# Help menu
|
122
|
-
aboutDlg = KDE::AboutApplicationDialog.new(
|
128
|
+
aboutDlg = KDE::AboutApplicationDialog.new(KDE::CmdLineArgs.aboutData)
|
123
129
|
gemHelpAction = @actions.addNew(i18n('Gem Command Line Help'), self, \
|
124
130
|
{ :icon => 'help-about', :shortCut => 'F1', :triggered => :gemCommandHelp })
|
125
131
|
openAboutAction = @actions.addNew(i18n('About kgem'), self, \
|
@@ -150,6 +156,7 @@ class MainWindow < KDE::MainWindow
|
|
150
156
|
menu = KDE::MenuBar.new
|
151
157
|
menu.addMenu( fileMenu )
|
152
158
|
menu.addMenu( toolsMenu )
|
159
|
+
menu.addMenu( sourceMenu )
|
153
160
|
menu.addMenu( settingsMenu )
|
154
161
|
menu.addMenu( helpMenu )
|
155
162
|
setMenuBar(menu)
|
@@ -246,12 +253,6 @@ class MainWindow < KDE::MainWindow
|
|
246
253
|
@gemEnvDlg.displayEnv
|
247
254
|
end
|
248
255
|
|
249
|
-
def openUrlDocument(url)
|
250
|
-
cmd= Mime::services('.html').first.exec
|
251
|
-
cmd.gsub!(/%\w+/, url)
|
252
|
-
fork do exec(cmd) end
|
253
|
-
end
|
254
|
-
|
255
256
|
slots :configureShortCut
|
256
257
|
def configureShortCut
|
257
258
|
KDE::ShortcutsDialog.configure(@actions)
|
@@ -263,6 +264,12 @@ class MainWindow < KDE::MainWindow
|
|
263
264
|
@settingsDlg.exec == Qt::Dialog::Accepted
|
264
265
|
end
|
265
266
|
|
267
|
+
slots :configureSources
|
268
|
+
def configureSources
|
269
|
+
@gemSourceDlg ||= GemSourceDlg.new(self)
|
270
|
+
@gemSourceDlg.exec
|
271
|
+
end
|
272
|
+
|
266
273
|
slots :gemCommandHelp
|
267
274
|
def gemCommandHelp
|
268
275
|
@gemHelpdlg.show
|
@@ -311,11 +318,11 @@ end
|
|
311
318
|
# main start
|
312
319
|
#
|
313
320
|
|
314
|
-
|
321
|
+
about = KDE::AboutData.new(APP_NAME, nil, KDE::ki18n(APP_NAME), APP_VERSION,
|
315
322
|
KDE::ki18n('Gem Utitlity with KDE GUI.')
|
316
323
|
)
|
317
|
-
|
318
|
-
KDE::CmdLineArgs.init(ARGV,
|
324
|
+
about.addLicenseTextFile(APP_DIR + '/MIT-LICENSE')
|
325
|
+
KDE::CmdLineArgs.init(ARGV, about)
|
319
326
|
|
320
327
|
$app = KDE::Application.new
|
321
328
|
args = KDE::CmdLineArgs.parsedArgs()
|
data/lib/downloadedwin.rb
CHANGED
@@ -163,7 +163,7 @@ class DownloadedWin < Qt::Widget
|
|
163
163
|
fGem = FetchedGem.new
|
164
164
|
fGem.fileName = f
|
165
165
|
fGem.directory = exDir
|
166
|
-
fGem.installed = InstalledGemList.
|
166
|
+
fGem.installed = InstalledGemList.checkVersionedGemInstalled(f)
|
167
167
|
fGem
|
168
168
|
end
|
169
169
|
end
|
data/lib/gemitem.rb
CHANGED
@@ -41,6 +41,7 @@ class GemItem
|
|
41
41
|
@filePath = filePath
|
42
42
|
end
|
43
43
|
|
44
|
+
# return versoin knowing newest, not latest.
|
44
45
|
def nowVersion
|
45
46
|
version.split(/,/, 2).first
|
46
47
|
end
|
@@ -152,7 +153,7 @@ module InstalledGemList
|
|
152
153
|
@gemList ||= get
|
153
154
|
end
|
154
155
|
|
155
|
-
def
|
156
|
+
def checkVersionedGemInstalled(versionedName)
|
156
157
|
vname = versionedName.gsub(/\.gem$/, '')
|
157
158
|
gem = getCached.find do |gem|
|
158
159
|
gem.name + '-' + gem.version == vname
|
data/lib/gemsource.rb
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
class GemSourceDlg < Qt::Dialog
|
4
|
+
def initialize(parent=nil)
|
5
|
+
super(parent)
|
6
|
+
self.windowTitle = i18n('Gem sources')
|
7
|
+
createWidget
|
8
|
+
end
|
9
|
+
|
10
|
+
def createWidget
|
11
|
+
@sourceList = Qt::ListWidget.new
|
12
|
+
@rubygemsCheckBox = Qt::CheckBox.new(i18n('add rubygems source'))
|
13
|
+
connect(@rubygemsCheckBox, SIGNAL('stateChanged(int)'), self, \
|
14
|
+
SLOT('rubygemsStateChanged(int)'))
|
15
|
+
@githubCheckBox = Qt::CheckBox.new(i18n('add github source'))
|
16
|
+
connect(@githubCheckBox, SIGNAL('stateChanged(int)'), self, \
|
17
|
+
SLOT('githubStateChanged(int)'))
|
18
|
+
@addUrlLineEdit = KDE::LineEdit.new
|
19
|
+
@addBtn = KDE::PushButton.new(i18n('add'))
|
20
|
+
@deleteBtn = KDE::PushButton.new(i18n('delete'))
|
21
|
+
@okBtn = KDE::PushButton.new(KDE::Icon.new('dialog-ok'), i18n('Ok'))
|
22
|
+
@cancelBtn = KDE::PushButton.new(KDE::Icon.new('dialog-cancel'), i18n('Cancel'))
|
23
|
+
connect(@addBtn, SIGNAL(:clicked), self, SLOT(:addItem))
|
24
|
+
connect(@deleteBtn, SIGNAL(:clicked), self, SLOT(:deleteItem))
|
25
|
+
connect(@okBtn, SIGNAL(:clicked), self, SLOT(:accept))
|
26
|
+
connect(@cancelBtn, SIGNAL(:clicked), self, SLOT(:reject))
|
27
|
+
|
28
|
+
# layout
|
29
|
+
lo = Qt::VBoxLayout.new do |l|
|
30
|
+
l.addWidget(@sourceList)
|
31
|
+
l.addWidget(@rubygemsCheckBox)
|
32
|
+
l.addWidget(@githubCheckBox)
|
33
|
+
l.addWidgets(@deleteBtn, nil)
|
34
|
+
l.addWidgets(@addBtn, @addUrlLineEdit)
|
35
|
+
l.addWidgets(nil, @okBtn, @cancelBtn)
|
36
|
+
l.addStretch
|
37
|
+
end
|
38
|
+
setLayout(lo)
|
39
|
+
end
|
40
|
+
|
41
|
+
UrlRegexp = URI.regexp(['http', 'https'])
|
42
|
+
GithubUrl = 'http://gems.github.com'
|
43
|
+
RubygemsUrl = 'http://rubygems.org/'
|
44
|
+
SystemUrls = [ GithubUrl, RubygemsUrl ]
|
45
|
+
def updateSources
|
46
|
+
@sourceList.clear
|
47
|
+
@sourceUrls = {}
|
48
|
+
@rubygemsCheckBox.checked = false
|
49
|
+
@githubCheckBox.checked = false
|
50
|
+
%x{ gem sources -l }.split(/\n/).each do |line|
|
51
|
+
url = line[UrlRegexp]
|
52
|
+
if url then
|
53
|
+
case url
|
54
|
+
when RubygemsUrl
|
55
|
+
@rubygemsCheckBox.checked = true
|
56
|
+
when GithubUrl
|
57
|
+
@githubCheckBox.checked = true
|
58
|
+
else
|
59
|
+
@sourceUrls[url] = item = Qt::ListWidgetItem.new(url)
|
60
|
+
@sourceList.addItem(item)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
@orgUrls = Set.new(@sourceUrls.keys)
|
65
|
+
end
|
66
|
+
|
67
|
+
def addUrl(url)
|
68
|
+
unless @sourceUrls[url] then
|
69
|
+
@sourceUrls[url] = item = Qt::ListWidgetItem.new(url)
|
70
|
+
@sourceList.addItem(item)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def deleteUrl(url)
|
75
|
+
if @sourceUrls[url] then
|
76
|
+
row = @sourceList.row(@sourceUrls[url])
|
77
|
+
@sourceList.takeItem(row)
|
78
|
+
# @sourceList.removeItemWidget(@sourceUrls[url]) # cannot use ?
|
79
|
+
@sourceUrls.delete(url)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
slots :addItem
|
84
|
+
def addItem
|
85
|
+
url = @addUrlLineEdit.text.strip
|
86
|
+
case url
|
87
|
+
when RubygemsUrl
|
88
|
+
@rubygemsCheckBox.checked = true
|
89
|
+
when GithubUrl
|
90
|
+
@githubCheckBox.checked = true
|
91
|
+
else
|
92
|
+
unless url.empty? or @sourceUrls.has_key?(url) then
|
93
|
+
addUrl(url)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
slots :deleteItem
|
99
|
+
def deleteItem
|
100
|
+
row = @sourceList.currentRow
|
101
|
+
return unless row >= 0
|
102
|
+
case @sourceList.item(row).text
|
103
|
+
when RubygemsUrl
|
104
|
+
@rubygemsCheckBox.checked = false
|
105
|
+
when GithubUrl
|
106
|
+
@githubCheckBox.checked = false
|
107
|
+
else
|
108
|
+
@sourceList.takeItem(row)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
#-----------------
|
113
|
+
def exec
|
114
|
+
updateSources
|
115
|
+
super
|
116
|
+
end
|
117
|
+
|
118
|
+
slots 'githubStateChanged(int)'
|
119
|
+
def githubStateChanged(state)
|
120
|
+
if state == Qt::Checked then
|
121
|
+
addUrl(GithubUrl)
|
122
|
+
else
|
123
|
+
deleteUrl(GithubUrl)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
slots 'rubygemsStateChanged(int)'
|
128
|
+
def rubygemsStateChanged(state)
|
129
|
+
if state == Qt::Checked then
|
130
|
+
addUrl(RubygemsUrl)
|
131
|
+
else
|
132
|
+
deleteUrl(RubygemsUrl)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# overwrite virtual method
|
137
|
+
def accept
|
138
|
+
msg = ""
|
139
|
+
newUrls = Set.new(@sourceUrls.keys)
|
140
|
+
deletes = @orgUrls - newUrls
|
141
|
+
deletes.each do |url|
|
142
|
+
msg += "delete #{url}\n"
|
143
|
+
%x{ gem sources --remove #{url} }
|
144
|
+
end
|
145
|
+
|
146
|
+
adds = newUrls - @orgUrls
|
147
|
+
adds.each do |url|
|
148
|
+
msg += "add #{url}\n"
|
149
|
+
%x{ gem sources --add #{url} }
|
150
|
+
end
|
151
|
+
unless msg.empty? then
|
152
|
+
KDE::MessageBox.information(self, msg)
|
153
|
+
end
|
154
|
+
super
|
155
|
+
end
|
156
|
+
end
|
data/lib/gemviews.rb
CHANGED
@@ -273,14 +273,13 @@ Pristine All ?
|
|
273
273
|
@gemPath ||= %x{gem environment gempath}.chomp.split(/:/)
|
274
274
|
end
|
275
275
|
|
276
|
-
def findGemPath(
|
276
|
+
def findGemPath(relPath)
|
277
277
|
paths = getGemPaths
|
278
|
-
|
279
|
-
|
280
|
-
file = p + path
|
281
|
-
File.exist? file
|
278
|
+
path = paths.find do |pa|
|
279
|
+
File.exist? pa + relPath
|
282
280
|
end
|
283
|
-
|
281
|
+
return nil unless path
|
282
|
+
path + relPath
|
284
283
|
end
|
285
284
|
|
286
285
|
def viewGemRdoc(gem)
|
@@ -290,9 +289,7 @@ Pristine All ?
|
|
290
289
|
pkg = gem.package
|
291
290
|
ver = gem.nowVersion
|
292
291
|
url = findGemPath('/doc/' + pkg + '-' + ver + '/rdoc/index.html')
|
293
|
-
|
294
|
-
cmd.gsub!(/%\w+/, url)
|
295
|
-
fork do exec(cmd) end
|
292
|
+
openUrlDocument(url)
|
296
293
|
end
|
297
294
|
|
298
295
|
def viewGemDir(gem)
|
@@ -301,9 +298,7 @@ Pristine All ?
|
|
301
298
|
pkg = gem.package
|
302
299
|
ver = gem.nowVersion
|
303
300
|
url = findGemPath('/gems/' + pkg + '-' + ver)
|
304
|
-
|
305
|
-
cmd += " " + url
|
306
|
-
fork do exec(cmd) end
|
301
|
+
openDirectory(url)
|
307
302
|
end
|
308
303
|
end
|
309
304
|
|
data/lib/mylibs.rb
CHANGED
@@ -119,12 +119,10 @@ end
|
|
119
119
|
# Mandriva doesn't include kio smoke library.
|
120
120
|
# FolderSelectorLineEdit substitute KDE::UrlRequester
|
121
121
|
#
|
122
|
-
class FolderSelectorLineEdit< Qt::Widget
|
122
|
+
class FolderSelectorLineEdit < Qt::Widget
|
123
123
|
def initialize(dir=nil, parent=nil)
|
124
124
|
super(parent)
|
125
125
|
|
126
|
-
# setContentsMargins(0,0,0,0)
|
127
|
-
|
128
126
|
# widgets
|
129
127
|
@lineEdit = KDE::LineEdit.new
|
130
128
|
@lineEdit.text = dir if dir
|
@@ -407,11 +405,19 @@ end
|
|
407
405
|
#
|
408
406
|
#
|
409
407
|
def openDirectory(dir)
|
408
|
+
return if !dir or dir.empty?
|
410
409
|
cmd = KDE::MimeTypeTrader.self.query('inode/directory').first.exec[/\w+/]
|
411
410
|
cmd += " " + dir
|
412
411
|
fork do exec(cmd) end
|
413
412
|
end
|
414
413
|
|
414
|
+
def openUrlDocument(url)
|
415
|
+
return if !url or url.empty?
|
416
|
+
cmd = Mime::services('.html').first.exec
|
417
|
+
cmd.gsub!(/%\w+/, url)
|
418
|
+
fork do exec(cmd) end
|
419
|
+
end
|
420
|
+
|
415
421
|
#--------------------------------------------------------------------------
|
416
422
|
#
|
417
423
|
# stdlib
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kgem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- ruby.twiddler
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-21 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,19 +47,20 @@ extensions:
|
|
47
47
|
extra_rdoc_files:
|
48
48
|
- README
|
49
49
|
files:
|
50
|
-
- bin/gemcmdwin.rb
|
51
50
|
- bin/kgem.rb
|
51
|
+
- bin/gemcmdwin.rb
|
52
52
|
- bin/gemcmdwin-super.rb
|
53
|
+
- lib/downloadedwin.rb
|
54
|
+
- lib/gemhelpdlg.rb
|
55
|
+
- lib/gemviews.rb
|
53
56
|
- lib/searchwin.rb
|
57
|
+
- lib/installedwin.rb
|
54
58
|
- lib/mylibs.rb
|
59
|
+
- lib/previewwin.rb
|
60
|
+
- lib/gemsource.rb
|
61
|
+
- lib/settings.rb
|
55
62
|
- lib/gemitem.rb
|
56
|
-
- lib/gemviews.rb
|
57
|
-
- lib/installedwin.rb
|
58
|
-
- lib/downloadedwin.rb
|
59
63
|
- lib/gemcmddlgs.rb
|
60
|
-
- lib/settings.rb
|
61
|
-
- lib/gemhelpdlg.rb
|
62
|
-
- lib/previewwin.rb
|
63
64
|
- README
|
64
65
|
- MIT-LICENSE
|
65
66
|
- Rakefile
|