kgem 0.1.8 → 0.1.9

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 CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
6
6
 
7
7
  spec = Gem::Specification.new do |s|
8
8
  s.name = "kgem"
9
- s.version = "0.1.8"
9
+ s.version = "0.1.9"
10
10
  s.author = "ruby.twiddler"
11
11
  s.email = "ruby.twiddler at gmail.com"
12
12
  s.homepage = "http://github.com/rubytwiddler/kgem/wiki"
Binary file
@@ -11,7 +11,7 @@ APP_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
11
11
  APP_NAME = File.basename(APP_FILE).sub(/\.rb/, '')
12
12
  APP_DIR = File::dirname(File.expand_path(File.dirname(APP_FILE)))
13
13
  LIB_DIR = File::join(APP_DIR, "lib")
14
- APP_VERSION = "0.1.8"
14
+ APP_VERSION = "0.1.9"
15
15
 
16
16
 
17
17
  # standard libs
@@ -23,7 +23,11 @@ require 'net/http'
23
23
  require 'shellwords'
24
24
 
25
25
  # additional libs
26
- require 'korundum4'
26
+ begin
27
+ require 'korundum4'
28
+ rescue LoadError
29
+ require 'korundum'
30
+ end
27
31
  require 'ktexteditor'
28
32
 
29
33
  #
@@ -15,7 +15,7 @@ def install_console_helper(console_helper_name, target_cmd_name)
15
15
  console_app_file = File.join(etc_dir, 'security', 'console.apps', console_helper_name)
16
16
  console_helper_target = %x{ which consolehelper }.strip!
17
17
 
18
- if !File.exist?(console_helper_target) then
18
+ if !console_helper_target then
19
19
  puts <<-EOF
20
20
 
21
21
  consolehelper is not installed.
@@ -33,6 +33,7 @@ EOF
33
33
  File.unlink(console_helper_link)
34
34
  end
35
35
  File.symlink(console_helper_target, console_helper_link)
36
+ FileUtils.mkdir_p(File.dirname(console_app_file))
36
37
 
37
38
  open(console_app_file, 'w') do |f|
38
39
  f.write(<<-EOF
@@ -1,3 +1,5 @@
1
+ require 'time'
2
+
1
3
  class FetchedGem
2
4
  attr_accessor :fileName, :directory, :installed
3
5
 
@@ -196,15 +198,15 @@ class DownloadedWin < Qt::Widget
196
198
  return unless File.exist?(filePath)
197
199
 
198
200
  @installBtn.enabled = @deleteBtn.enabled = ! fetchedGem.installed
199
- files = %x{ tar xvf #{filePath} data.tar.gz -O | gunzip -c | tar t }.split(/\n/)
201
+ files = %x{ tar xf #{filePath} data.tar.gz -O | gunzip -c | tar t }.split(/\n/)
200
202
  files.unshift
201
203
  @gemViewer.setFiles(files)
202
- gem = GemItem::getGemfromPath(filePath)
204
+ gem = GemItem::getGemfromCache(filePath)
203
205
  @gemViewer.setDetail(gem)
204
206
 
205
207
  proc = lambda do |item|
206
208
  file = item.text
207
- @gemViewer.previewWin.setText( file, %x{ tar xvf #{filePath.shellescape} data.tar.gz -O | gunzip -c | tar x #{file.shellescape} -O } )
209
+ @gemViewer.previewWin.setText( file, %x{ tar xf #{filePath.shellescape} data.tar.gz -O | gunzip -c | tar x #{file.shellescape} -O } )
208
210
  end
209
211
  @gemViewer.setPreviewProc(proc)
210
212
  end
@@ -237,7 +239,7 @@ class DownloadedWin < Qt::Widget
237
239
  slots :unpack
238
240
  def unpack
239
241
  fetchedGem = @gemFileList.currentGem
240
- fileName = fetchedGem.filePath
242
+ filePath = fetchedGem.filePath
241
243
  if Settings.autoUnpackFlag then
242
244
  dir = Settings.autoUnpackDir
243
245
  else
@@ -245,8 +247,10 @@ class DownloadedWin < Qt::Widget
245
247
  return unless dir
246
248
  Settings.autoUnpackDir.setUrl(dir)
247
249
  end
248
- puts %Q{ execute: gem unpack #{fileName} --target=#{dir.shellescape} }
249
- %x{ gem unpack #{fileName} --target=#{dir.shellescape} }
250
+ outDir = File.join(dir, File.basename(filePath).sub(File.extname(filePath),''))
251
+ FileUtils.remove_dir(outDir, true)
252
+ FileUtils.mkdir_p(outDir)
253
+ %x{ tar xf #{filePath.shellescape} data.tar.gz -O | gunzip -c | tar x --directory=#{outDir.shellescape} }
250
254
  end
251
255
 
252
256
  end
@@ -41,7 +41,7 @@ class GemHelpDlg < KDE::MainWindow
41
41
  end
42
42
 
43
43
  def iniHelpList
44
- list = %x{gem help command}.inject([]) do |a, line|
44
+ list = %x{gem help command}.split(/[\r\n]+/).inject([]) do |a, line|
45
45
  line =~ /^\s{4}(\w+)/ ? a << $1 : a
46
46
  end
47
47
  list.unshift('examples')
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'rubygems'
3
3
  require 'rubygems/specification'
4
+ require 'yaml'
4
5
 
5
6
  # additional libs
6
7
  require 'korundum4'
@@ -88,6 +89,13 @@ class GemItem
88
89
  spec = Marshal.load(res)
89
90
  GemItem::parseGemSpec(spec)
90
91
  end
92
+
93
+ def self.getGemfromCache(filePath)
94
+ res = %x{ tar xf #{filePath.shellescape} metadata.gz -O | gunzip -c }
95
+ return nil if res.empty?
96
+ spec = YAML::load(res)
97
+ GemItem::parseGemSpec(spec)
98
+ end
91
99
  end
92
100
 
93
101
 
@@ -44,6 +44,15 @@ class Qt::VBoxLayout
44
44
  w.push(nil)
45
45
  addWidgetWithNilStretch(*w)
46
46
  end
47
+
48
+ def addGroup(name)
49
+ g = Qt::GroupBox.new(name)
50
+ vbx = Qt::VBoxLayout.new do |vb|
51
+ yield(vb)
52
+ end
53
+ g.setLayout(vbx)
54
+ addWidget(g)
55
+ end
47
56
  end
48
57
 
49
58
 
@@ -163,7 +172,29 @@ class FolderSelectorLineEdit < Qt::Widget
163
172
  end
164
173
  end
165
174
 
175
+ class FileSelectorLineEdit < FolderSelectorLineEdit
176
+ def initialize(filter="", file=nil, parent=nil)
177
+ super(file,parent)
178
+
179
+ @filter = filter
180
+ @dirSelectBtn.setIcon(KDE::Icon.new('document-open'))
181
+ end
182
+
183
+ def openSelectDlg
184
+ path = Qt::FileDialog::getOpenFileName(self,'select file', @lineEdit.text, @filter)
185
+ unless !path || path.empty?
186
+ @lineEdit.text = path
187
+ end
188
+ end
189
+
190
+ def fileName
191
+ @lineEdit.text
192
+ end
166
193
 
194
+ def fileName=(file)
195
+ @lineEdit.text = file
196
+ end
197
+ end
167
198
 
168
199
 
169
200
  #--------------------------------------------------------------------------
@@ -424,7 +455,7 @@ end
424
455
  #
425
456
  module Enumerable
426
457
  class Proxy
427
- instance_methods.each { |m| undef_method(m) unless m.match(/^__/) }
458
+ instance_methods.each { |m| undef_method(m) unless m.match(/^(__|object_id$)/) }
428
459
  def initialize(enum, method=:map)
429
460
  @enum, @method = enum, method
430
461
  end
@@ -438,6 +469,42 @@ module Enumerable
438
469
  end
439
470
  end
440
471
 
472
+
473
+ #
474
+ # meta programming support methods.
475
+ # ref. http://http://dannytatom.github.com/metaid/
476
+ #
477
+ class Object
478
+ # The hidden singleton lurks behind everyone
479
+ def metaclass; class << self; self; end; end
480
+ def meta_eval &blk; metaclass.instance_eval &blk; end
481
+
482
+ # Adds methods to a metaclass
483
+ def meta_def name, &blk
484
+ meta_eval { define_method name, &blk }
485
+ end
486
+
487
+ # Defines an instance method within a class
488
+ def class_def name, &blk
489
+ class_eval { define_method name, &blk }
490
+ end
491
+ end
492
+ #
493
+ #
494
+ #
495
+ class Dir
496
+ def self.allDirs(path)
497
+ dirs = []
498
+ Dir.foreach(path) do |f|
499
+ fullPath = File.join(path, f)
500
+ if File.directory?(fullPath) and f !~ /^\.\.?$/ then
501
+ dirs << f
502
+ end
503
+ end
504
+ dirs
505
+ end
506
+ end
507
+
441
508
  #
442
509
  #
443
510
  #
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: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 8
10
- version: 0.1.8
9
+ - 9
10
+ version: 0.1.9
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-30 00:00:00 +09:00
18
+ date: 2010-10-07 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency