gui_ruby_editor 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.
- checksums.yaml +15 -0
- data/README.md +13 -0
- data/gui_ruby_editor.gemspec +28 -0
- data/lib/gui_ruby_editor.rb +201 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTRkNThkN2Y4ZmRjYThkYWQwOGFkNGY2ZDIyZDQzZmUxNjBmN2Y4Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ODA5NjczYjU4ZWFiNWYzYzJmMmUwNGVkYzZhMDkzOTkyYzVkODE0MA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODJiM2U0N2VlOWI0NTk4ZWY0NWExZGJiNjhmYTlmNmI2ODYzN2M2YTE4NDI2
|
10
|
+
NzczN2NjZDU5M2NjZjc5YjkzNjQ5MWZiMjQzNDA3ODk1OTZmYTJkYTA2NGQ0
|
11
|
+
YTk5ZGMxMzVmOGVmNWFiMTM0NDBlMmVmYTM5YTlmZWU4ODQzOGQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmUxNWVjODg3NTYzOGY3MWJkZmVmMjFiYzZkNTZiNDc3NjQyOWExOGY3NWUx
|
14
|
+
YzM2NTkyZmRkYjM4ODhkMDhlODFhNzA3YzEwOWZlYmQyNTlkNzEyNjEwZDVk
|
15
|
+
Mzk5NzU1ZTlkNDUzMWExMmUyNGY0NGZmNzRmZDUwZTBhODk2Mjg=
|
data/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gui Ruby Editor is a Graphical User Interface Code Editor. It allows the user to enter a code into a text window and run the code. The output is displayed in a lower window with any Standard Error arising from code mistake. This helps Ruby beginners to discover their errors and correct it on the fly. The Editor allows the user to open a saved script make any changes and test it in the Gui Editor. The modified script may be saved under a different name. The output from execution of the code can be captured from the second window and saved into a file.
|
2
|
+
|
3
|
+
Installation:
|
4
|
+
=======
|
5
|
+
Enter "gem install gui_ruby_editor" at the cmd prompt.
|
6
|
+
|
7
|
+
Usage:
|
8
|
+
======
|
9
|
+
save the following ruby script on your desktop or folder containing your Ruby scripts:
|
10
|
+
|
11
|
+
require 'gui_ruby_editor'
|
12
|
+
`ruby gui_ruby_editor`
|
13
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "gui_ruby_editor"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
s.licenses = ['MIT']
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Sabry Abdel Fattah"]
|
9
|
+
s.date = "2015-03-08"
|
10
|
+
s.description = "Gui Ruby Editor is a Graphical User Interface Code Editor. It allows the user to enter a code into a text window and run the code or Ruby file. The output is displayed in a lower window with any Standard Error "
|
11
|
+
s.email = "sabryabdelfattah@gmail.com"
|
12
|
+
s.extra_rdoc_files = ["README.md"]
|
13
|
+
s.files = ["gui_ruby_editor.gemspec", "lib/gui_ruby_editor.rb" , "README.md"]
|
14
|
+
s.homepage = "http://sabryfattah.com"
|
15
|
+
s.rdoc_options = ["--main", "README.md"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubygems_version = "1.8.29"
|
18
|
+
s.summary = "Gui Ruby Editor is a Graphical User Interface Code Editor. It allows the user to enter a code into a text window and run the code. The output is displayed in a lower window with any Standard Error. The Editor allows the user to open a saved script make any changes and test it in the Gui Editor. The modified script may be saved under a different name. The output from execution of the code can be captured from the second window and saved into a file. "
|
19
|
+
|
20
|
+
if s.respond_to? :specification_version then
|
21
|
+
s.specification_version = 3
|
22
|
+
|
23
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
24
|
+
else
|
25
|
+
end
|
26
|
+
else
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'tk'
|
2
|
+
#Root Window#############################
|
3
|
+
root = TkRoot.new{title "Ruby Editor"}
|
4
|
+
root['geometry'] = '1540x700+1+1'
|
5
|
+
## 2 Buttons : to run file and run code #################
|
6
|
+
$button1 = TkButton.new(root){
|
7
|
+
text "Run File"
|
8
|
+
borderwidth 4
|
9
|
+
font TkFont.new('times 14 bold')
|
10
|
+
background "green"
|
11
|
+
relief "groove"
|
12
|
+
command(proc{runfile})
|
13
|
+
|
14
|
+
def runfile
|
15
|
+
if $filename != nil
|
16
|
+
$out = %x[ruby "#$filename" 2>&1]
|
17
|
+
$win2.delete(1.0, 'end')
|
18
|
+
$win2.insert('end', "#$out")
|
19
|
+
else
|
20
|
+
$win2.insert('end', "No File Selected")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
|
25
|
+
$button2 = TkButton.new(root){
|
26
|
+
text "Run Code"
|
27
|
+
borderwidth 4
|
28
|
+
font TkFont.new('times 14 bold')
|
29
|
+
background "green"
|
30
|
+
relief "groove"
|
31
|
+
command(proc{runcode})
|
32
|
+
|
33
|
+
def runcode
|
34
|
+
theCode = $win1.get("1.0", 'end')
|
35
|
+
File.write("tmp.rb", theCode)
|
36
|
+
$out = %x[ruby "tmp.rb" 2>&1]
|
37
|
+
$win2.delete(1.0, 'end')
|
38
|
+
$win2.insert('end', "#$out")
|
39
|
+
end
|
40
|
+
}
|
41
|
+
|
42
|
+
#________MENU________________________________________________
|
43
|
+
TkOption.add '*tearOff', 0
|
44
|
+
$filename =TkVariable.new
|
45
|
+
$newfilename =TkVariable.new
|
46
|
+
#______________Methods of the Menu ______________
|
47
|
+
newfile = Proc.new{$win1.delete(1.0, 'end')}
|
48
|
+
clearWin2 = Proc.new{$win2.delete(1.0, 'end')}
|
49
|
+
#________________________
|
50
|
+
openfile = Proc.new{
|
51
|
+
$filename = Tk::getOpenFile()
|
52
|
+
$content = File.read($filename)
|
53
|
+
$win1.delete(1.0, 'end')
|
54
|
+
$win1.insert('end', $content)
|
55
|
+
}
|
56
|
+
#___________________________________
|
57
|
+
closefile = Proc.new{$win1.delete(1.0, 'end')}
|
58
|
+
#____________________________________
|
59
|
+
savefile = Proc.new{
|
60
|
+
thetext = $win1.get("1.0", 'end')
|
61
|
+
File.write($filename, thetext)
|
62
|
+
}
|
63
|
+
#____________________________________
|
64
|
+
savefileas = Proc.new{
|
65
|
+
thetext = $win1.get("1.0", 'end')
|
66
|
+
$newfilename = Tk::getSaveFile('filetypes' => [["All Files", "."], ["Text Files", ".txt"]])
|
67
|
+
File.write($newfilename, thetext)
|
68
|
+
}
|
69
|
+
#____________________________________
|
70
|
+
exitapp = Proc.new{exit}
|
71
|
+
help = Proc.new{help_win}
|
72
|
+
#_______ HELP MENU _____________________
|
73
|
+
def help_win
|
74
|
+
begin
|
75
|
+
$win.destroy
|
76
|
+
rescue
|
77
|
+
end
|
78
|
+
$win = TkToplevel.new{title "Help Window"}
|
79
|
+
TkLabel.new($win){
|
80
|
+
text "This Ruby Editor allows you to:
|
81
|
+
1. Open a saved script from folder through a dialogbox(Win1 Menu)
|
82
|
+
2. Type your own new script and Save it (Save & Saveas in Win1 Menu)
|
83
|
+
3. Clear Win1 screen for a new script (New or Close from Win1 Menu)
|
84
|
+
4. Output from execution of code appears in Win2
|
85
|
+
5. You can clear Win2 from Win2 Menu (clear)
|
86
|
+
6. You may save the output of the script in a separate file (SaveAs in Win2 Menu)
|
87
|
+
The green button run the script and send output to Win2.
|
88
|
+
If you click the green button before selection of a script, a fatal error may occur.
|
89
|
+
"
|
90
|
+
borderwidth 5
|
91
|
+
font TkFont.new('times 16 bold')
|
92
|
+
background "yellow"
|
93
|
+
relief "groove"
|
94
|
+
justify "left"
|
95
|
+
}.grid('row' => 0, 'column' => 0)
|
96
|
+
TkButton.new($win) {
|
97
|
+
text "OK"
|
98
|
+
command "$win.destroy"
|
99
|
+
}.grid('row' => 1, 'column' => 0)
|
100
|
+
end
|
101
|
+
###################### Menu Structure ###################
|
102
|
+
win1_menu = TkMenu.new(root)
|
103
|
+
win2_menu = TkMenu.new(root)
|
104
|
+
helpMenu = TkMenu.new(root)
|
105
|
+
#______________________________
|
106
|
+
win1_menu.add('command',
|
107
|
+
'label' => "New...",
|
108
|
+
'command' => newfile,
|
109
|
+
'underline' => 0)
|
110
|
+
win1_menu.add('command',
|
111
|
+
'label' => "Open...",
|
112
|
+
'command' => openfile,
|
113
|
+
'underline' => 0)
|
114
|
+
win1_menu.add('command',
|
115
|
+
'label' => 'Close',
|
116
|
+
'command' => closefile,
|
117
|
+
'underline' => 0)
|
118
|
+
win1_menu.add('separator')
|
119
|
+
win1_menu.add('command',
|
120
|
+
'label' => "Save",
|
121
|
+
'command' => savefile,
|
122
|
+
'underline' => 0)
|
123
|
+
win1_menu.add('command',
|
124
|
+
'label' => "Save As...",
|
125
|
+
'command' => savefileas,
|
126
|
+
'underline' => 5)
|
127
|
+
win1_menu.add('separator')
|
128
|
+
win1_menu.add('command',
|
129
|
+
'label' => "Exit",
|
130
|
+
'command' => exitapp,
|
131
|
+
'underline' => 3)
|
132
|
+
helpMenu.add('command',
|
133
|
+
'label' => "Help",
|
134
|
+
'command' => help,
|
135
|
+
'underline' => 3)
|
136
|
+
#_________________________________________
|
137
|
+
win2_menu.add('command',
|
138
|
+
'label' => "Clear...",
|
139
|
+
'command' => clearWin2,
|
140
|
+
'underline' => 0)
|
141
|
+
win2_menu.add('command',
|
142
|
+
'label' => "Save As...",
|
143
|
+
'command' => savefileas,
|
144
|
+
'underline' => 5)
|
145
|
+
|
146
|
+
menu_bar = TkMenu.new
|
147
|
+
menu_bar.add('cascade',
|
148
|
+
'menu' => win1_menu,
|
149
|
+
'label' => "Win1")
|
150
|
+
menu_bar.add('cascade',
|
151
|
+
'menu' => win2_menu,
|
152
|
+
'label' => "Win2")
|
153
|
+
menu_bar.add('cascade',
|
154
|
+
'menu' => helpMenu,
|
155
|
+
'label' => "Help")
|
156
|
+
|
157
|
+
root.menu(menu_bar)
|
158
|
+
#__________________2 TEXT WINDOWS _______________________________
|
159
|
+
## Win1 for Code and Win2 for output ###########################
|
160
|
+
$win1 = TkText.new(root) do
|
161
|
+
width 82
|
162
|
+
height 9
|
163
|
+
background "black"
|
164
|
+
foreground "white"
|
165
|
+
font TkFont.new('tahoma 16 normal')
|
166
|
+
wrap 'word'
|
167
|
+
insertbackground "yellow"
|
168
|
+
insertwidth 3
|
169
|
+
cursor "hand2"
|
170
|
+
end
|
171
|
+
|
172
|
+
$win2 = TkText.new(root) do
|
173
|
+
width 82
|
174
|
+
height 9
|
175
|
+
background "black"
|
176
|
+
foreground "white"
|
177
|
+
font TkFont.new('tahoma 16 normal')
|
178
|
+
wrap 'word'
|
179
|
+
insertbackground "yellow"
|
180
|
+
insertwidth 3
|
181
|
+
cursor "hand2"
|
182
|
+
end
|
183
|
+
|
184
|
+
#___________ SCROLLBARS of WIN2 and WIN2 _____________________
|
185
|
+
$scrollbar1 = TkScrollbar.new(root){command proc{|*args| $win1.yview(*args)}
|
186
|
+
}
|
187
|
+
$win1.yscrollcommand(proc{|first, last| $scrollbar1.set(first, last)})
|
188
|
+
|
189
|
+
$scrollbar2 = TkScrollbar.new(root){command proc{|*args| $win2.yview(*args)}
|
190
|
+
}
|
191
|
+
$win2.yscrollcommand(proc{|first, last| $scrollbar2.set(first, last)})
|
192
|
+
#________________ GEOMETRY _____________________________
|
193
|
+
$win1.grid('row' => 0, 'column' => 0)
|
194
|
+
$win2.grid('row' => 1, 'column' => 0)
|
195
|
+
$button1.grid('row' =>3, 'column' => 0, 'sticky' => 'NW')
|
196
|
+
$button2.grid('row' =>3, 'column' => 0, 'sticky' => 'NE')
|
197
|
+
$scrollbar1.grid('row' => 0, 'column' => 1, 'sticky' => 'NS')
|
198
|
+
$scrollbar2.grid('row' => 1, 'column' => 1, 'sticky' => 'NS')
|
199
|
+
######### Show GUI ###############################
|
200
|
+
Tk.mainloop
|
201
|
+
######END OF SCRIPT #######
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gui_ruby_editor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sabry Abdel Fattah
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: ! 'Gui Ruby Editor is a Graphical User Interface Code Editor. It allows
|
14
|
+
the user to enter a code into a text window and run the code or Ruby file. The output
|
15
|
+
is displayed in a lower window with any Standard Error '
|
16
|
+
email: sabryabdelfattah@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README.md
|
21
|
+
files:
|
22
|
+
- README.md
|
23
|
+
- gui_ruby_editor.gemspec
|
24
|
+
- lib/gui_ruby_editor.rb
|
25
|
+
homepage: http://sabryfattah.com
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options:
|
31
|
+
- --main
|
32
|
+
- README.md
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.4.5
|
48
|
+
signing_key:
|
49
|
+
specification_version: 3
|
50
|
+
summary: Gui Ruby Editor is a Graphical User Interface Code Editor. It allows the
|
51
|
+
user to enter a code into a text window and run the code. The output is displayed
|
52
|
+
in a lower window with any Standard Error. The Editor allows the user to open a
|
53
|
+
saved script make any changes and test it in the Gui Editor. The modified script
|
54
|
+
may be saved under a different name. The output from execution of the code can be
|
55
|
+
captured from the second window and saved into a file.
|
56
|
+
test_files: []
|