visualruby 1.0.12

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.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/bin/editor/VR_Document.rb +219 -0
  3. data/bin/editor/VR_TabSearch.rb +50 -0
  4. data/bin/editor/VR_Tabs.rb +99 -0
  5. data/bin/editor/VR_TextShell.rb +83 -0
  6. data/bin/editor/VR_TextViewCommon.rb +65 -0
  7. data/bin/editor/glade/VR_Document.glade +160 -0
  8. data/bin/main/GemTree.rb +23 -0
  9. data/bin/main/NewProjectGUI.rb +28 -0
  10. data/bin/main/ProjectChooserGUI.rb +41 -0
  11. data/bin/main/ProjectChooserView.rb +39 -0
  12. data/bin/main/RubygemsAPI.rb +93 -0
  13. data/bin/main/Splash.rb +22 -0
  14. data/bin/main/VR_ENV.rb +61 -0
  15. data/bin/main/VR_ENV_GLOBAL.rb +64 -0
  16. data/bin/main/VR_File_Tree.rb +120 -0
  17. data/bin/main/VR_Local_Gem_Tree.rb +80 -0
  18. data/bin/main/VR_Main.rb +313 -0
  19. data/bin/main/VR_Remote_Gem_Tree.rb +70 -0
  20. data/bin/main/glade/NewProjectGUI.glade +141 -0
  21. data/bin/main/glade/ProjectChooserGUI.glade +140 -0
  22. data/bin/main/glade/RubygemsAPI.glade +130 -0
  23. data/bin/main/glade/Splash.glade +18 -0
  24. data/bin/main/glade/VR_ENV.glade +168 -0
  25. data/bin/main/glade/VR_ENV_GLOBAL.glade +268 -0
  26. data/bin/main/glade/VR_File_Tree.glade +65 -0
  27. data/bin/main/glade/VR_Local_Gem_Tree.glade +45 -0
  28. data/bin/main/glade/VR_Main.glade +707 -0
  29. data/bin/main/glade/VR_Remote_Gem_Tree.glade +76 -0
  30. data/bin/tools/VR_Tools.rb +120 -0
  31. data/img/close.png +0 -0
  32. data/img/folder.png +0 -0
  33. data/img/glade.png +0 -0
  34. data/img/gtk-edit.png +0 -0
  35. data/img/obj.png +0 -0
  36. data/img/png.png +0 -0
  37. data/img/rb.png +0 -0
  38. data/img/ruby.png +0 -0
  39. data/img/splash.png +0 -0
  40. data/img/unknown.png +0 -0
  41. data/skeleton/document/New.glade +13 -0
  42. data/skeleton/document/NewWindow.rb +15 -0
  43. data/skeleton/project/bin/MyClass.rb +15 -0
  44. data/skeleton/project/bin/glade/MyClass.glade +45 -0
  45. data/skeleton/project/main.rb +14 -0
  46. data/visualruby_examples/active_record/.vr_settings.yaml +47 -0
  47. data/visualruby_examples/active_record/active_record.rb +52 -0
  48. data/visualruby_examples/active_record/bin/ChoosePerson.rb +17 -0
  49. data/visualruby_examples/active_record/bin/Person.rb +13 -0
  50. data/visualruby_examples/active_record/bin/glade/ChoosePerson.glade +61 -0
  51. data/visualruby_examples/active_record/bin/glade/Person.glade +148 -0
  52. data/visualruby_examples/active_record/db/development.sqlite3 +0 -0
  53. data/visualruby_examples/active_record2/.vr_settings.yaml +48 -0
  54. data/visualruby_examples/active_record2/active_record2.rb +142 -0
  55. data/visualruby_examples/active_record2/bin/CompanyGUI.rb +54 -0
  56. data/visualruby_examples/active_record2/bin/Employee.rb +20 -0
  57. data/visualruby_examples/active_record2/bin/Employer.rb +11 -0
  58. data/visualruby_examples/active_record2/bin/Paycheck.rb +11 -0
  59. data/visualruby_examples/active_record2/bin/glade/CompanyGUI.glade +167 -0
  60. data/visualruby_examples/active_record2/bin/glade/Employee.glade +123 -0
  61. data/visualruby_examples/active_record2/bin/glade/Employer.glade +147 -0
  62. data/visualruby_examples/active_record2/bin/glade/Paycheck.glade +145 -0
  63. data/visualruby_examples/active_record2/db/development.sqlite3 +0 -0
  64. data/visualruby_examples/all_widgets/.vr_settings.yaml +20 -0
  65. data/visualruby_examples/all_widgets/all_widgets.rb +13 -0
  66. data/visualruby_examples/all_widgets/bin/AllWidgets.rb +43 -0
  67. data/visualruby_examples/all_widgets/bin/glade/AllWidgets.glade +166 -0
  68. data/visualruby_examples/all_widgets/bin/splash.png +0 -0
  69. data/visualruby_examples/calculator/.vr_settings.yaml +21 -0
  70. data/visualruby_examples/calculator/bin/Calculator.rb +63 -0
  71. data/visualruby_examples/calculator/bin/glade/Calculator.glade +243 -0
  72. data/visualruby_examples/calculator/main.rb +13 -0
  73. data/visualruby_examples/child_window/.vr_settings.yaml +46 -0
  74. data/visualruby_examples/child_window/bin/ChildWindowDemo.rb +41 -0
  75. data/visualruby_examples/child_window/bin/MyChildClass.rb +42 -0
  76. data/visualruby_examples/child_window/bin/glade/ChildWindowDemo.glade +101 -0
  77. data/visualruby_examples/child_window/bin/glade/MyChildClass.glade +58 -0
  78. data/visualruby_examples/child_window/main.rb +13 -0
  79. data/visualruby_examples/drag_drop/.vr_settings.yaml +19 -0
  80. data/visualruby_examples/drag_drop/bin/DragDropDemo.rb +45 -0
  81. data/visualruby_examples/drag_drop/bin/glade/DragDropDemo.glade +143 -0
  82. data/visualruby_examples/drag_drop/img/folder.png +0 -0
  83. data/visualruby_examples/drag_drop/img/glade.png +0 -0
  84. data/visualruby_examples/drag_drop/img/gtk-edit.png +0 -0
  85. data/visualruby_examples/drag_drop/img/obj.png +0 -0
  86. data/visualruby_examples/drag_drop/img/png.png +0 -0
  87. data/visualruby_examples/drag_drop/img/rb.png +0 -0
  88. data/visualruby_examples/drag_drop/img/ruby.png +0 -0
  89. data/visualruby_examples/drag_drop/img/unknown.png +0 -0
  90. data/visualruby_examples/drag_drop/main.rb +14 -0
  91. data/visualruby_examples/listview/.vr_settings.yaml +46 -0
  92. data/visualruby_examples/listview/bin/SongListView.rb +89 -0
  93. data/visualruby_examples/listview/bin/SongListViewGUI.rb +67 -0
  94. data/visualruby_examples/listview/bin/audio-x-generic.png +0 -0
  95. data/visualruby_examples/listview/bin/glade/SongListViewGUI.glade +220 -0
  96. data/visualruby_examples/listview/main.rb +19 -0
  97. data/visualruby_examples/listview_objects/.vr_settings.yaml +46 -0
  98. data/visualruby_examples/listview_objects/bin/DataObject.rb +32 -0
  99. data/visualruby_examples/listview_objects/bin/DataObjectGUI.rb +41 -0
  100. data/visualruby_examples/listview_objects/bin/ListViewObjects.rb +34 -0
  101. data/visualruby_examples/listview_objects/bin/ListViewObjectsGUI.rb +18 -0
  102. data/visualruby_examples/listview_objects/bin/glade/DataObject.glade +198 -0
  103. data/visualruby_examples/listview_objects/bin/glade/ListViewObjectsGUI.glade +102 -0
  104. data/visualruby_examples/listview_objects/main.rb +13 -0
  105. data/visualruby_examples/simple_ruby_gui/.vr_settings.yaml +45 -0
  106. data/visualruby_examples/simple_ruby_gui/bin/DataObjectGUI.rb +20 -0
  107. data/visualruby_examples/simple_ruby_gui/bin/glade/DataObjectGUI.glade +163 -0
  108. data/visualruby_examples/simple_ruby_gui/simple_ruby_gui +16 -0
  109. data/visualruby_examples/treeview/.vr_settings.yaml +18 -0
  110. data/visualruby_examples/treeview/bin/MyClass.rb +28 -0
  111. data/visualruby_examples/treeview/bin/glade/MyClass.glade +48 -0
  112. data/visualruby_examples/treeview/main.rb +14 -0
  113. data/vr +40 -0
  114. metadata +202 -0
@@ -0,0 +1,23 @@
1
+
2
+ class GemTree < VR::ListView
3
+
4
+ RUBY_ICON = Gdk::Pixbuf.new(File.dirname(__FILE__) + '/../../img/rb.png')
5
+
6
+ def initialize()
7
+ hash = {:gems => {:pix => Gdk::Pixbuf, :gem => String}}
8
+ super(hash)
9
+ self.headers_visible = false
10
+ @api = RubygemsAPI.new
11
+ end
12
+
13
+ def self__button_release_event(w, event)
14
+ return unless selection.selected and event.button == 3 #right mouse
15
+ @builder['popGem'].popup(nil, nil, event.button, event.time)
16
+ end
17
+
18
+ def get_name_ver(line)
19
+ match = /^(.*)\s+\((.*)\)/.match(line)
20
+ return match[1], match[2]
21
+ end
22
+
23
+ end
@@ -0,0 +1,28 @@
1
+
2
+ class NewProjectGUI
3
+
4
+ include GladeGUI
5
+
6
+ def initialize(parent)
7
+ @parent = parent
8
+ @parent.proj_path = nil
9
+ end
10
+
11
+ def buttonCreate__clicked(*a)
12
+ fn = @builder["entryFolderName"].text
13
+ fn = fn.gsub(/[^\w\.]/, '_')
14
+ path = File.expand_path(File.join("~", "visualruby", fn))
15
+ if File.directory?(path)
16
+ VR::msg "That folder already exists. You can delete it and try again."
17
+ else
18
+ Dir.mkdir path
19
+ @parent.proj_path = path
20
+ destroy_window()
21
+ end
22
+ end
23
+
24
+ def buttonCancel__clicked(*a)
25
+ destroy_window()
26
+ end
27
+
28
+ end
@@ -0,0 +1,41 @@
1
+
2
+ class ProjectChooserGUI < ProjectChooserView
3
+
4
+ include GladeGUI
5
+
6
+ def initialize(parent)
7
+ @parent = parent
8
+ @parent.proj_path = nil
9
+ super()
10
+ load_glade(__FILE__) #don't set parent here! Want modal window.
11
+ end
12
+
13
+ def show()
14
+ @builder["scrolledwindowProjTree"].add(self)
15
+ refresh(false)
16
+ show_window()
17
+ end
18
+
19
+ def buttonOpen__clicked(*args)
20
+ return unless row = selected_rows.first
21
+ @parent.proj_path = row[:file_name]
22
+ destroy_window()
23
+ end
24
+
25
+ def buttonSelect_clicked
26
+ if folder = VR::Dialog.folder_box(@builder)
27
+ @parent.proj_path = folder
28
+ destroy_window()
29
+ end
30
+ end
31
+
32
+ def checkBackup_toggled
33
+ refresh(@builder["checkBackup"].active?)
34
+ end
35
+
36
+ def self__row_activated(*args)
37
+ buttonOpen__clicked
38
+ end
39
+
40
+
41
+ end
@@ -0,0 +1,39 @@
1
+
2
+ class ProjectChooserView < VR::ListView
3
+
4
+ PIX = Gdk::Pixbuf.new(File.dirname(__FILE__) + "/../../img/folder.png")
5
+
6
+ def initialize()
7
+ super(:folder => {:pix => Gdk::Pixbuf, :file_name => String}, :modified => DateTime)
8
+ ren_xalign(:modified => 1)
9
+ col_xalign(:modified => 1)
10
+ col_sort_column_id(:modified => id(:modified), :pix => id(:file_name))
11
+ end
12
+
13
+ def refresh(show_backup = false)
14
+ model.set_sort_column_id(1)
15
+ self.model.clear
16
+ pattern = ""
17
+ backup_path = Dir.pwd.gsub(ENV["HOME"], File.join(ENV["HOME"], "visualruby_backup"))
18
+ backup_ar = File.split(backup_path)
19
+ backup_ar << ["**", VR_ENV::SETTINGS_FILE]
20
+ if show_backup
21
+ pattern = File.join(*backup_ar)
22
+ else
23
+ pattern = File.join(ENV["HOME"], "visualruby", "**", VR_ENV::SETTINGS_FILE)
24
+ end
25
+ Dir.glob(pattern, File::FNM_DOTMATCH).each do |fn|
26
+ next if not show_backup and fn =~ / Backup /
27
+ next if show_backup and not fn =~ / Backup /
28
+ t = File.stat(fn).mtime
29
+ row = add_row()
30
+ row[:pix] = PIX
31
+ row[:file_name] = File.dirname(fn)
32
+ row[:modified] = DateTime.parse(t.to_s)
33
+ end
34
+ model.set_sort_column_id(id(:modified), Gtk::SORT_DESCENDING)
35
+ end
36
+
37
+ end
38
+
39
+
@@ -0,0 +1,93 @@
1
+
2
+ class RubygemsAPI
3
+
4
+ include GladeGUI
5
+
6
+ CREDENTIALS_FILE = ENV['HOME'] + "/.gem/credentials"
7
+
8
+ def initialize
9
+ load_glade(__FILE__)
10
+ uri = URI.parse("https://rubygems.org")
11
+ @http = Net::HTTP.new(uri.host, uri.port)
12
+ @http.use_ssl = true
13
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
14
+ end
15
+
16
+ def get_key()
17
+ if File.file?(CREDENTIALS_FILE)
18
+ return Gem.configuration.rubygems_api_key
19
+ end
20
+ return set_up_key()
21
+ end
22
+
23
+ def set_up_key()
24
+ @username = ""
25
+ @password = ""
26
+ key = nil
27
+ set_glade_all()
28
+ @builder["dialog1"].run do |response_id|
29
+ if response_id == 1 #Ok Button
30
+ get_glade_all() #gets @username, @password
31
+ path = "/api/v1/api_key.yaml"
32
+ @http.start() do |h|
33
+ req = Net::HTTP::Get.new(path)
34
+ req.basic_auth @username, @password
35
+ response = h.request(req)
36
+ obj = YAML.load(response.body)
37
+ key = obj[:rubygems_api_key]
38
+ if key
39
+ File.open(CREDENTIALS_FILE,"w") { |f| f.write(YAML.dump(obj)) }
40
+ else
41
+ VR::Dialog.message_box(obj.values[0])
42
+ end
43
+ end
44
+ end
45
+ end
46
+ @builder["dialog1"].hide
47
+ return key
48
+ end
49
+
50
+
51
+ def get_obj_url(path)
52
+ return nil unless key = get_key()
53
+ @http.start() {|h|
54
+ req = Net::HTTP::Get.new(path)
55
+ response = h.request_get(path, 'Authorization' => key)
56
+ return obj = YAML.load(response.body)
57
+ }
58
+ end
59
+
60
+
61
+ # in Windows, the File.open { read } doesn't work for the gemfile.
62
+ # also, you must set a variable (bod) to close the io stream
63
+
64
+ def push_gem(fn)
65
+ return unless key = get_key()
66
+ path = "https://rubygems.org/api/v1/gems"
67
+ req = Net::HTTP::Post.new(path)
68
+ req.add_field('Authorization', key)
69
+ req.content_type = 'application/octet-stream'
70
+ bod = File.open(fn, "rb") {|io| io.read } # no good in win: File.open(fn).read
71
+ req.body = bod #must do it like this to close io ??!?!
72
+ req.content_length = req.body.size
73
+ @http.start() do |h|
74
+ response = h.request(req)
75
+ return response.message
76
+ end
77
+ end
78
+
79
+ def yank_gem(name, ver)
80
+ return unless key = get_key()
81
+ path = "/api/v1/gems/yank?gem_name=#{URI.encode(name)}&version=#{URI.encode(ver)}"
82
+ req = Net::HTTP::Delete.new(path)
83
+ req.add_field('Authorization', key)
84
+ req.add_field 'Connection', 'keep-alive'
85
+ req.add_field 'Keep-Alive', '30'
86
+ req.content_type = 'application/x-www-form-urlencoded'
87
+ @http.start() do |h|
88
+ response = h.request(req)
89
+ return response.message
90
+ end
91
+ end
92
+
93
+ end
@@ -0,0 +1,22 @@
1
+
2
+ class Splash #(change name)
3
+
4
+ include GladeGUI
5
+
6
+ def show(parent)
7
+ load_glade(__FILE__) #loads file, glade/MyClass.glade into @builder
8
+ @builder["image1"].file = File.dirname(__FILE__) + "/../../img/splash.png"
9
+ show_window()
10
+ # wait_destroy()
11
+ end
12
+
13
+ def wait_destroy
14
+ t = Thread.new {
15
+ sleep(1.5)
16
+ destroy_window()
17
+ t.join
18
+ }
19
+ end
20
+
21
+
22
+ end
@@ -0,0 +1,61 @@
1
+
2
+ class VR_ENV
3
+
4
+ include GladeGUI
5
+
6
+ SETTINGS_FILE = ".vr_settings.yaml"
7
+ SETTINGS_FILE_VERSION = 1
8
+
9
+ attr_accessor :width, :height, :panel_pos, :rdoc_command_line, :settings_file_version
10
+ attr_accessor :run_command_line, :open_files, :open_folders, :current_file
11
+
12
+
13
+ def initialize()
14
+ @settings_file_version = SETTINGS_FILE_VERSION
15
+ @width = 800
16
+ @height = 600
17
+ @panel_pos = 360
18
+ @run_command_line = "ruby main.rb"
19
+ @open_files = []
20
+ @open_folders = []
21
+ @current_file = ""
22
+ @rdoc_command_line = "rdoc -x README"
23
+ save_yaml()
24
+ end
25
+
26
+ #todo validate
27
+ def buttonSave_clicked
28
+ get_glade_variables
29
+ save_yaml()
30
+ destroy_window()
31
+ end
32
+
33
+ # def buttonChooseFolder_clicked
34
+ # if folder = VR::Dialog.folder_box(@builder)
35
+ # if folder =~ /^#{Dir.pwd}\b/
36
+ # VR::Dialog.message_box("You must select a backup path outside the project's root folder.")
37
+ # else
38
+ # @builder['backup_path'].text = folder
39
+ # end
40
+ # end
41
+ # end
42
+
43
+ def self.load_yaml()
44
+ if File.file?(SETTINGS_FILE)
45
+ me = YAML::load(File.open(SETTINGS_FILE).read)
46
+ return VR_ENV.new() if me.settings_file_version.nil?
47
+ return VR_ENV.new() if me.settings_file_version < SETTINGS_FILE_VERSION
48
+ return me
49
+ else
50
+ VR_ENV.new()
51
+ end
52
+ end
53
+
54
+ def save_yaml()
55
+ data = YAML.dump(self)
56
+ File.open(Dir.pwd + "/" + SETTINGS_FILE, "w") {|f| f.puts(data)}
57
+ return self
58
+ end
59
+
60
+
61
+ end
@@ -0,0 +1,64 @@
1
+
2
+ class VR_ENV_GLOBAL
3
+
4
+ GLOBAL_SETTINGS_FILE = File.join(ENV["HOME"], "visualruby", ".vr_global_settings")
5
+ SETTINGS_FILE_VERSION = 1
6
+
7
+ include GladeGUI
8
+
9
+ attr_accessor :browser, :tab_spaces, :glade_path
10
+ attr_accessor :font_name, :settings_file_version
11
+
12
+ def initialize
13
+ @settings_file_version = SETTINGS_FILE_VERSION
14
+ @browser = "firefox"
15
+ @tab_spaces = 2
16
+ @font_name = "Monospace 10"
17
+ @glade_path = "glade-gtk2"
18
+ save_yaml
19
+ end
20
+
21
+ def before_show
22
+ @glade_box = VR::SimpleComboBoxEntry.new(@glade_path, "glade-gtk2", "glade", "glade-3", "C:\\Program Files (x86)\\Gtk+\\bin\\glade-3")
23
+ @builder["hboxGlade"].add(@glade_box)
24
+ @browser_box = VR::SimpleComboBoxEntry.new(@browser, "xdg-open", "chromium-browser", "firefox", "google-chrome", "chrome", "chromium", "iexplore", "start iexplore", "start firefox", "start google-chrome", "start chrome", "start chromium", "C:\\Program Files\\iexplorer\\iexplore.exe")
25
+ @builder["hboxBrowser"].add(@browser_box)
26
+ @builder["font_name"].show_size = true
27
+ end
28
+
29
+ #todo validate
30
+ def buttonSave_clicked
31
+ get_glade_variables
32
+ spaces = @builder['tab_spaces'].text.to_i
33
+ @tab_spaces = spaces if spaces > 0 and spaces < 9
34
+ @glade_path = @glade_box.active_text
35
+ @browser = @browser_box.active_text
36
+ save_yaml()
37
+ destroy_window()
38
+ end
39
+
40
+ def save_yaml
41
+ data = YAML.dump(self)
42
+ File.open(GLOBAL_SETTINGS_FILE, "w") {|f| f.puts(data)}
43
+ end
44
+
45
+ def self.load_yaml()
46
+ if File.file?(GLOBAL_SETTINGS_FILE)
47
+ me = YAML::load(File.open(GLOBAL_SETTINGS_FILE).read)
48
+ return VR_ENV_GLOBAL.new() if me.settings_file_version.nil?
49
+ return VR_ENV_GLOBAL.new() if me.settings_file_version < SETTINGS_FILE_VERSION
50
+ return me
51
+ else
52
+ VR_ENV_GLOBAL.new()
53
+ end
54
+ end
55
+
56
+ def buttonTryGlade__clicked(*argv)
57
+ VR_Tools.popen(@glade_box.active_text)
58
+ end
59
+
60
+ def buttonTryBrowser__clicked(*argv)
61
+ VR_Tools.popen(@browser_box.active_text)
62
+ end
63
+
64
+ end
@@ -0,0 +1,120 @@
1
+
2
+ class VR_File_Tree < VR::FileTreeView
3
+
4
+ include GladeGUI
5
+
6
+ def initialize(main, icon_path)
7
+ super(icon_path)
8
+ @main = main
9
+ @api = RubygemsAPI.new
10
+ load_glade(__FILE__)
11
+ end
12
+
13
+ def self__row_activated(*args)
14
+ return unless rows = selected_rows
15
+ file_name = rows.first[:path]
16
+ if File.extname(file_name) == ".glade"
17
+ VR_Tools.popen("#{$VR_ENV_GLOBAL.glade_path} #{file_name} ")
18
+ else
19
+ @main.tabs.load_tab(file_name) if not File.directory?(file_name)
20
+ end
21
+ end
22
+
23
+ def menuPushGem_clicked
24
+ file_name = get_selected_path()
25
+ @main.shell.buffer.text = @api.push_gem(file_name)
26
+ end
27
+
28
+ def popInstallGem_clicked()
29
+ file_name = get_selected_path()
30
+ # begin
31
+ inst = Gem::Installer.new(file_name, :wrappers => true, :ignore_dependencies => true)
32
+ inst.install().to_s
33
+ txt = "Installed Gem: " + file_name
34
+ txt += "\nNo check was made for dependencies"
35
+ # rescue
36
+ # command = "gem install #{file_name} --local 2>&1"
37
+ # txt = VR_Tools.sudo_command(command)
38
+ # end
39
+ @main.shell.buffer.text = txt
40
+ end
41
+
42
+ def menuRDoc_clicked
43
+ return unless @main.tabs.try_to_save_all(false)
44
+ fn = get_selected_path()
45
+ old_dir = Dir.pwd
46
+ FileUtils.cd(fn)
47
+ @main.shell.buffer.text = $VR_ENV.rdoc_command_line + fn + "\n"
48
+ @main.shell.buffer.text += `#{$VR_ENV.rdoc_command_line} 2>&1`
49
+ VR_Tools.replace_html_in_docs()
50
+ FileUtils.cd(old_dir)
51
+ VR_Tools.popen("#{$VR_ENV_GLOBAL.browser} #{fn}/doc/index.html")
52
+ @main.file_tree.refresh()
53
+ end
54
+
55
+ def popBuildGem_clicked
56
+ file_name = get_selected_path()
57
+ @main.tabs.try_to_save_all(false)
58
+ gem_builder = "Invalid .gemspec file: " + file_name
59
+ begin #try ruby 2.0.0 way first:
60
+ spec = Gem::Specification.load(file_name)
61
+ gem_builder = "Built Gem:\n" + Gem::Package.build(spec)
62
+ rescue #try old way
63
+ spec = Gem::Specification.load(file_name)
64
+ b = Gem::Builder.new(spec)
65
+ b.build()
66
+ gem_builder = b.success()
67
+ end
68
+ @main.shell.buffer.text = gem_builder
69
+ refresh()
70
+ end
71
+
72
+ def popGlade_clicked
73
+ path = get_selected_path()
74
+ source_code = File.open(path, "r").read
75
+ class_name = VR_Document.get_class_title(source_code).gsub(".rb", "")
76
+ # glade_file = File.dirname(path) + "/glade/" + File.basename(path, ".rb") + ".glade"
77
+ glade_file = File.dirname(path) + "/glade/" + class_name + ".glade"
78
+ if not File.file?(glade_file)
79
+ path = File.dirname(glade_file)
80
+ FileUtils.makedirs(path) if not File.directory?(path)
81
+ FileUtils.cp File.expand_path(File.dirname(__FILE__)+"/../../skeleton/document/New.glade"), glade_file
82
+ VR_Tools.popen("#{$VR_ENV_GLOBAL.glade_path} #{glade_file}")
83
+ sleep(2) #must do it this way because different thread
84
+ File.delete(glade_file)
85
+ else
86
+ VR_Tools.popen("#{$VR_ENV_GLOBAL.glade_path} #{glade_file}")
87
+ end
88
+ end
89
+
90
+ def self__button_release_event(w, event) # right mouse button
91
+ return unless path = get_selected_path() and event.button == 3
92
+ if File.file?(path) and (File.extname(path) == ".rb" or File.extname(path) == "")
93
+ @builder['popFile'].popup(nil, nil, event.button, event.time)
94
+ elsif File.extname(path) == ".gemspec"
95
+ @builder['popGemspec'].popup(nil, nil, event.button, event.time)
96
+ elsif File.extname(path) == ".gem"
97
+ @builder['popGemFile'].popup(nil, nil, event.button, event.time)
98
+ elsif File.directory?(path)
99
+ @builder['popFolder'].popup(nil, nil, event.button, event.time)
100
+ end
101
+ end
102
+
103
+ def self__key_press_event(view, evt)
104
+ return unless evt.keyval == 65535 #delete
105
+ return unless file_name = get_selected_path()
106
+ return unless VR::Dialog.ok_box("Delete: " + File.basename(file_name) + "?")
107
+ if File.file?(file_name)
108
+ @main.tabs.destroy_file_tab(file_name)
109
+ File.delete(file_name)
110
+ elsif File.directory?(file_name) and file_name != Dir.pwd #root!
111
+ FileUtils.remove_dir(file_name, true)
112
+ end
113
+ delete_selected()
114
+ end
115
+
116
+
117
+ end
118
+
119
+
120
+
@@ -0,0 +1,80 @@
1
+
2
+ class VR_Local_Gem_Tree < GemTree
3
+
4
+ include GladeGUI
5
+
6
+ def initialize(main)
7
+ super()
8
+ @main = main
9
+ # set_title(PIX => "Gems on this Computer")
10
+ load_glade(__FILE__)
11
+ end
12
+
13
+ def refresh()
14
+ self.model.clear
15
+ result = `gem list`
16
+ result.each_line do |line|
17
+ gem, versions = get_name_ver(line)
18
+ versions.split(",").each do |v|
19
+ add_row( :pix => RUBY_ICON, :gem => "#{gem} (#{v})" )
20
+ end
21
+ end
22
+ end
23
+
24
+
25
+ #todo
26
+ def popViewSpec_clicked;
27
+ gem, ver = selected_gem()
28
+ spec = `gem specification #{gem} -v #{ver}`
29
+ @main.tabs.load_tab()
30
+ @main.tabs.set_contents(spec)
31
+ end
32
+
33
+ def popOpenRubygemsPage_clicked
34
+ gem, ver = selected_gem()
35
+ VR_Tools.popen("#{$VR_ENV_GLOBAL.browser} http://rubygems.org/gems/#{gem}")
36
+ end
37
+
38
+ def popOpenHomepage_clicked
39
+ gem, ver = selected_gem()
40
+ spec = `gem specification #{gem} -v #{ver}`
41
+ match = /^homepage:\s+(.*)$/.match(spec)
42
+ VR_Tools.popen("#{$VR_ENV_GLOBAL.browser} #{match[1]}")
43
+ end
44
+
45
+ def popUninstall_clicked
46
+ gem, ver = selected_gem()
47
+ # begin
48
+ Gem::Uninstaller.new(gem, {:version => ver, :executables => true }).uninstall()
49
+ txt = "Uninstalled Gem: #{gem} #{ver}"
50
+ # rescue
51
+ # command = "gem uninstall #{gem} -x -v '#{ver}' 2>&1"
52
+ # txt = VR_Tools.sudo_command(command)
53
+ # end
54
+ @main.shell.buffer.text = txt
55
+ refresh()
56
+ end
57
+
58
+
59
+ # def popUninstall_clicked
60
+ # gem, ver = selected_gem()
61
+ # #command = "gem uninstall " + gem_name.gsub("("," -x -v ").gsub(")","")
62
+ # command = "gem uninstall #{gem} -x -v '#{ver}' 2>&1"
63
+ # @main.shell.buffer.text = VR_Tools.sudo_command(command)
64
+ # refresh()
65
+ # end
66
+
67
+ # def get_name_ver(line)
68
+ # match = /^(.*)\s+\((.*)\)/.match(line)
69
+ # return match[1], match[2]
70
+ # end
71
+
72
+ def selected_gem
73
+ row = self.selection.selected[1].split(" (")
74
+ ver = row[1].gsub(")","")
75
+ return row[0], ver
76
+ end
77
+
78
+ end
79
+
80
+