ruined 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 2010 arton (Akio Tajima). All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/ChangeLog CHANGED
@@ -1,3 +1,12 @@
1
+ Tue Oct 13 21:01:00 2010 arton
2
+ * Rakefile
3
+ add BSDL into gem
4
+ * ruined/html/main.html
5
+ escape modified value
6
+ * ruined/ruinmain.rb
7
+ version 0.0.4 => 0.0.5
8
+ escape stdout
9
+ unescape modified value
1
10
  Tue Oct 12 00:17:00 2010 arton
2
11
  * BSDL
3
12
  * readme.txt
@@ -1,230 +1,231 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html> <head>
3
- <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
4
- <meta http-equiv="content-style-type" content="text/css"/>
5
- <title></title>
6
- <link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.5.custom.css"></link>
7
- <link rel="stylesheet" href="../css/ruin.css"></link>
8
- <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
9
- <script type="text/javascript" src="../js/jquery-ui-1.8.5.custom.min.js"></script>
10
- <script type="text/javascript">
11
- var files = new Object();
12
- var priorLine = { line: null, index: null };
13
- var interval = 1000;
14
- var contTimer = null;
15
- function addFile(name, line, command) {
16
- var a = name.split('/');
17
- $('#lists').tabs('add' , '/debug/file/' + name , a[a.length - 1]);
18
- var index = $('#lists').tabs('length') - 1;
19
- $('#lists').tabs('select', index);
20
- $('td').bind('click', function(ev) {
21
- var sub = 'false';
22
- if (ev.currentTarget.style.backgroundColor == '') {
23
- sub = 'true';
24
- }
25
- var index = $('#lists').tabs('option', 'selected');
26
- var key, file;
27
- for (key in files) {
28
- if (files[key] == index) {
29
- file = key;
30
- break;
31
- }
32
- }
33
- if (file != null) {
34
- var line = 0;
35
- var list = $('#ui-tabs-' + (index * 2 + 2) + ' > table > tbody > tr > td');
36
- for (var i = 0; i < list.length; i++) {
37
- if (list[i] == ev.currentTarget) {
38
- line = i + 1;
39
- break;
40
- }
41
- }
42
- $.get('/debug/break/' + sub + '/' + file + '/' + line, function() {
43
- var bgclr = '';
44
- var clr = '';
45
- if (sub == 'true') {
46
- bgclr = 'saddlebrown';
47
- clr = 'white';
48
- }
49
- ev.currentTarget.style.backgroundColor = bgclr;
50
- ev.currentTarget.style.color = clr;
51
- });
52
- }
53
- });
54
- return index;
55
- }
56
- function changeTab(index) {
57
- $('#lists').tabs('select', index);
58
- }
59
- function lineColor(command, brk) {
60
- if (command == 'cont' && !brk) {
61
- return 'aquamarine';
62
- }
63
- return 'yellow';
64
- }
65
- function stopRun() {
66
- clearTimeout(contTimer);
67
- contTimer = null;
68
- $('#run').button('option', 'label', 'run');
69
- }
70
- function setLine(index, line, command, brk) {
71
- if (line > 0) {
72
- --line;
73
- }
74
- if (priorLine.index != null) {
75
- var style = $('#ui-tabs-' + (priorLine.index * 2 + 2) + ' > table > tbody > tr > td')[priorLine.line].style;
76
- style.backgroundColor = priorLine.backgroundColor;
77
- style.color = priorLine.color;
78
- }
79
- var style = $('#ui-tabs-' + (index * 2 + 2) + ' > table > tbody > tr > td')[line].style;
80
- priorLine.index = index;
81
- priorLine.line = line;
82
- priorLine.color = style.color;
83
- priorLine.backgroundColor = style.backgroundColor;
84
- style.backgroundColor = lineColor(command, brk);
85
- style.color = '';
86
- $('#ui-tabs-' + (index * 2 + 2) + ' > table > tbody > tr > td')[line].scrollIntoView(true);
87
- }
88
- function stepProc(command) {
89
- $.getJSON('/debug/' + command, function(data) {
90
- if (data == null || data.file == null) {
91
- if (contTimer != null) stopRun();
92
- $('button').button('disable');
93
- return;
94
- }
95
- if (data['break'] || data['event'] == 'exit') {
96
- stopRun();
97
- if (data['event'] == 'exit') {
98
- $('button').button('disable');
99
- $('#vars').tabs({
100
- show: function(envet, ui) {
101
- alert('program terminated');
102
- }
103
- });
104
- alert('program exit');
105
- }
106
- }
107
- if (files[data.file] == null) {
108
- files[data.file] = addFile(data.file, data.line, command);
109
- } else {
110
- changeTab(files[data.file]);
111
- }
112
- setLine(files[data.file], data.line, command, data['break']);
113
- $('#vars').tabs('load', $('#vars').tabs('option', 'selected'));
114
- var span = document.createElement('span');
115
- span.innerHTML = data.stdout;
116
- $('#stdout')[0].appendChild(span);
117
- span = document.createElement('span');
118
- $('#stdout')[0].appendChild(span);
119
- span.scrollIntoView(true);
120
- });
121
- }
122
- function contProc(command) {
123
- stepProc(command);
124
- contTimer = setTimeout('contProc("' + command + '");', interval);
125
- }
126
- function initTabs(elm) {
127
- elm.tabs();
128
- elm.tabs({ajaxOptions: {async: false}});
129
- elm.tabs('option', 'cache', true);
130
- }
131
- $(document).ready(function() {
132
- initTabs($('#lists'));
133
- initTabs($('#vars'));
134
- $('#vars').tabs({
135
- show: function(envet, ui) {
136
- $('#vars').tabs('load', $('#vars').tabs('option', 'selected'));
137
- },
138
- load: function(event, ui) {
139
- $('.var-value').dblclick(function(e) {
140
- var v = e.currentTarget.innerHTML;
141
- e.currentTarget.innerHTML = '<input type="text" value="' + v + '"/>';
142
- setTimeout(function() {
143
- e.currentTarget.childNodes.item(0).focus();
144
- $(e.currentTarget.childNodes.item(0)).focusout(function(ev) {
145
- var loc = 'locals/';
146
- if ($('#vars').tabs('option', 'selected') == 1) {
147
- loc = 'self/';
148
- } else if ($('#vars').tabs('option', 'selected') == 2) {
149
- loc = 'globals/';
150
- }
151
- var url = '/debug/' + loc + e.currentTarget.previousSibling.innerHTML
152
- + '/' + ev.currentTarget.value;
153
- e.currentTarget.innerHTML = ev.currentTarget.value;
154
- $.get(url, function() {
155
- $('#vars').tabs('load', $('#vars').tabs('option', 'selected'));
156
- });
157
- });
158
- }, 0);
159
- });
160
- }
161
- });
162
- $('#intval').slider();
163
- $('#intval').slider('option', 'value', 10);
164
- $('#intval').slider({
165
- change: function(e, ui) {
166
- interval = $('#intval').slider('option', 'value') * 100;
167
- }
168
- });
169
- $.ajaxSetup({cache: false});
170
-
171
- $('button').button();
172
- $('#run').click(function() {
173
- if (contTimer == null) {
174
- contProc('cont');
175
- $('#run').button('option', 'label', 'stop');
176
- } else {
177
- stopRun();
178
- }
179
- });
180
- $('#step').click(function() {
181
- stepProc('step');
182
- });
183
- $('#waiting').ajaxError(function() {
184
- if (contTimer != null) {
185
- stopRun();
186
- }
187
- });
188
- stepProc('stepping');
189
- });
190
- </script>
191
- </head>
192
- <body>
193
- <div class="list-pane">
194
- <div id="button-panel">
195
- <div class="console">
196
- <button id="step">Step</button>
197
- <button id="run">Run</button>
198
- </div>
199
- </div>
200
- <div id="speed-panel">
201
- <div id="intval"></div>
202
- <div style="float: left; width: 50%">fast &lt;----</div>
203
- <div style="float: right">----&gt; slow</div>
204
- </div>
205
- <div id="lists" style="clear: both">
206
- <ul></ul>
207
- </div>
208
- </div>
209
- <div class="vars-pane">
210
- <div id="vars">
211
- <ul>
212
- <li><a href="/debug/locals" title="Local Vars"><span>Local Vars</span></a></li>
213
- <li><a href="/debug/self" title="Self Vars"><span>Self Vars</span></a></li>
214
- <li><a href="/debug/globals" title="Global Vars"><span>Global Vars</span></a></li>
215
- </ul>
216
- <div id="Local_Vars"></div>
217
- <div id="Self_Vars"></div>
218
- <div id="Global_Vars"></div>
219
- </div>
220
- </div>
221
- <div style="clear: both;">
222
- <div id="output">
223
- <span id="stdout"></span>
224
- </div>
225
- <hr>
226
- <div id="waiting"></div>
227
- <address id="ruby-platform"></address>
228
- <!-- hhmts start --> Last modified: Wed Oct 13 00:12:03 +0900 2010 <!-- hhmts end -->
229
- </div>
230
- </body> </html>
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html> <head>
3
+ <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
4
+ <meta http-equiv="content-style-type" content="text/css"/>
5
+ <title></title>
6
+ <link rel="stylesheet" href="../css/smoothness/jquery-ui-1.8.5.custom.css"></link>
7
+ <link rel="stylesheet" href="../css/ruin.css"></link>
8
+ <script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>
9
+ <script type="text/javascript" src="../js/jquery-ui-1.8.5.custom.min.js"></script>
10
+ <script type="text/javascript">
11
+ var files = new Object();
12
+ var priorLine = { line: null, index: null };
13
+ var interval = 1000;
14
+ var contTimer = null;
15
+ function addFile(name, line, command) {
16
+ var a = name.split('/');
17
+ $('#lists').tabs('add' , '/debug/file/' + name , a[a.length - 1]);
18
+ var index = $('#lists').tabs('length') - 1;
19
+ $('#lists').tabs('select', index);
20
+ $('td').bind('click', function(ev) {
21
+ var sub = 'false';
22
+ if (ev.currentTarget.style.backgroundColor == '') {
23
+ sub = 'true';
24
+ }
25
+ var index = $('#lists').tabs('option', 'selected');
26
+ var key, file;
27
+ for (key in files) {
28
+ if (files[key] == index) {
29
+ file = key;
30
+ break;
31
+ }
32
+ }
33
+ if (file != null) {
34
+ var line = 0;
35
+ var list = $('#ui-tabs-' + (index * 2 + 2) + ' > table > tbody > tr > td');
36
+ for (var i = 0; i < list.length; i++) {
37
+ if (list[i] == ev.currentTarget) {
38
+ line = i + 1;
39
+ break;
40
+ }
41
+ }
42
+ $.get('/debug/break/' + sub + '/' + file + '/' + line, function() {
43
+ var bgclr = '';
44
+ var clr = '';
45
+ if (sub == 'true') {
46
+ bgclr = 'saddlebrown';
47
+ clr = 'white';
48
+ }
49
+ ev.currentTarget.style.backgroundColor = bgclr;
50
+ ev.currentTarget.style.color = clr;
51
+ });
52
+ }
53
+ });
54
+ return index;
55
+ }
56
+ function changeTab(index) {
57
+ $('#lists').tabs('select', index);
58
+ }
59
+ function lineColor(command, brk) {
60
+ if (command == 'cont' && !brk) {
61
+ return 'aquamarine';
62
+ }
63
+ return 'yellow';
64
+ }
65
+ function stopRun() {
66
+ clearTimeout(contTimer);
67
+ contTimer = null;
68
+ $('#run').button('option', 'label', 'run');
69
+ }
70
+ function setLine(index, line, command, brk) {
71
+ if (line > 0) {
72
+ --line;
73
+ }
74
+ if (priorLine.index != null) {
75
+ var style = $('#ui-tabs-' + (priorLine.index * 2 + 2) + ' > table > tbody > tr > td')[priorLine.line].style;
76
+ style.backgroundColor = priorLine.backgroundColor;
77
+ style.color = priorLine.color;
78
+ }
79
+ var style = $('#ui-tabs-' + (index * 2 + 2) + ' > table > tbody > tr > td')[line].style;
80
+ priorLine.index = index;
81
+ priorLine.line = line;
82
+ priorLine.color = style.color;
83
+ priorLine.backgroundColor = style.backgroundColor;
84
+ style.backgroundColor = lineColor(command, brk);
85
+ style.color = '';
86
+ $('#ui-tabs-' + (index * 2 + 2) + ' > table > tbody > tr > td')[line].scrollIntoView(true);
87
+ }
88
+ function stepProc(command) {
89
+ $.getJSON('/debug/' + command, function(data) {
90
+ if (data == null || data.file == null) {
91
+ if (contTimer != null) stopRun();
92
+ $('button').button('disable');
93
+ return;
94
+ }
95
+ if (data['break'] || data['event'] == 'exit') {
96
+ stopRun();
97
+ if (data['event'] == 'exit') {
98
+ $('button').button('disable');
99
+ $('#vars').tabs({
100
+ show: function(envet, ui) {
101
+ alert('program terminated');
102
+ }
103
+ });
104
+ alert('program exit');
105
+ }
106
+ }
107
+ if (files[data.file] == null) {
108
+ files[data.file] = addFile(data.file, data.line, command);
109
+ } else {
110
+ changeTab(files[data.file]);
111
+ }
112
+ setLine(files[data.file], data.line, command, data['break']);
113
+ $('#vars').tabs('load', $('#vars').tabs('option', 'selected'));
114
+ var span = document.createElement('span');
115
+ span.innerHTML = data.stdout;
116
+ $('#stdout')[0].appendChild(span);
117
+ span = document.createElement('span');
118
+ $('#stdout')[0].appendChild(span);
119
+ span.scrollIntoView(true);
120
+ });
121
+ }
122
+ function contProc(command) {
123
+ stepProc(command);
124
+ contTimer = setTimeout('contProc("' + command + '");', interval);
125
+ }
126
+ function initTabs(elm) {
127
+ elm.tabs();
128
+ elm.tabs({ajaxOptions: {async: false}});
129
+ elm.tabs('option', 'cache', true);
130
+ }
131
+ $(document).ready(function() {
132
+ initTabs($('#lists'));
133
+ initTabs($('#vars'));
134
+ $('#vars').tabs({
135
+ show: function(envet, ui) {
136
+ $('#vars').tabs('load', $('#vars').tabs('option', 'selected'));
137
+ },
138
+ load: function(event, ui) {
139
+ $('.var-value').dblclick(function(e) {
140
+ var v = e.currentTarget.innerHTML;
141
+ e.currentTarget.innerHTML = '<input type="text" value="' + v + '"/>';
142
+ setTimeout(function() {
143
+ e.currentTarget.childNodes.item(0).focus();
144
+ $(e.currentTarget.childNodes.item(0)).focusout(function(ev) {
145
+ var loc = 'locals/';
146
+ if ($('#vars').tabs('option', 'selected') == 1) {
147
+ loc = 'self/';
148
+ } else if ($('#vars').tabs('option', 'selected') == 2) {
149
+ loc = 'globals/';
150
+ }
151
+ var url = '/debug/' + loc
152
+ + encodeURIComponent(e.currentTarget.previousSibling.innerHTML)
153
+ + '/' + encodeURIComponent(ev.currentTarget.value);
154
+ e.currentTarget.innerHTML = ev.currentTarget.value;
155
+ $.get(url, function() {
156
+ $('#vars').tabs('load', $('#vars').tabs('option', 'selected'));
157
+ });
158
+ });
159
+ }, 0);
160
+ });
161
+ }
162
+ });
163
+ $('#intval').slider();
164
+ $('#intval').slider('option', 'value', 10);
165
+ $('#intval').slider({
166
+ change: function(e, ui) {
167
+ interval = $('#intval').slider('option', 'value') * 100;
168
+ }
169
+ });
170
+ $.ajaxSetup({cache: false});
171
+
172
+ $('button').button();
173
+ $('#run').click(function() {
174
+ if (contTimer == null) {
175
+ contProc('cont');
176
+ $('#run').button('option', 'label', 'stop');
177
+ } else {
178
+ stopRun();
179
+ }
180
+ });
181
+ $('#step').click(function() {
182
+ stepProc('step');
183
+ });
184
+ $('#waiting').ajaxError(function() {
185
+ if (contTimer != null) {
186
+ stopRun();
187
+ }
188
+ });
189
+ stepProc('stepping');
190
+ });
191
+ </script>
192
+ </head>
193
+ <body>
194
+ <div class="list-pane">
195
+ <div id="button-panel">
196
+ <div class="console">
197
+ <button id="step">Step</button>
198
+ <button id="run">Run</button>
199
+ </div>
200
+ </div>
201
+ <div id="speed-panel">
202
+ <div id="intval"></div>
203
+ <div style="float: left; width: 50%">fast &lt;----</div>
204
+ <div style="float: right">----&gt; slow</div>
205
+ </div>
206
+ <div id="lists" style="clear: both">
207
+ <ul></ul>
208
+ </div>
209
+ </div>
210
+ <div class="vars-pane">
211
+ <div id="vars">
212
+ <ul>
213
+ <li><a href="/debug/locals" title="Local Vars"><span>Local Vars</span></a></li>
214
+ <li><a href="/debug/self" title="Self Vars"><span>Self Vars</span></a></li>
215
+ <li><a href="/debug/globals" title="Global Vars"><span>Global Vars</span></a></li>
216
+ </ul>
217
+ <div id="Local_Vars"></div>
218
+ <div id="Self_Vars"></div>
219
+ <div id="Global_Vars"></div>
220
+ </div>
221
+ </div>
222
+ <div style="clear: both;">
223
+ <div id="output">
224
+ <span id="stdout"></span>
225
+ </div>
226
+ <hr>
227
+ <div id="waiting"></div>
228
+ <address id="ruby-platform"></address>
229
+ <!-- hhmts start --> Last modified: Wed Oct 13 11:09:42 +0900 2010 <!-- hhmts end -->
230
+ </div>
231
+ </body> </html>
@@ -2,13 +2,14 @@
2
2
  # coding: utf-8
3
3
 
4
4
  require 'webrick'
5
+ require 'uri'
5
6
  require 'json'
6
7
  require 'thread'
7
8
  require 'monitor'
8
9
  require 'stringio'
9
10
 
10
11
  module Ruined
11
- RUINED_VERSION = '0.0.4'
12
+ RUINED_VERSION = '0.0.5'
12
13
 
13
14
  @queue = [Queue.new, Queue.new]
14
15
  @breakpoints = []
@@ -35,14 +36,18 @@ module Ruined
35
36
  end
36
37
  end
37
38
  def do_GET(req, res)
38
- m = %r|/debug/([^/]+)/?(.*)\Z|.match(req.path)
39
+ m = %r|/debug/([^/?]+)/?([^?]*).*\Z|.match(req.unparsed_uri)
39
40
  if m
40
- res.body = __send__(m[1].to_sym, *(m[2].split('/')))
41
+ @response = res
42
+ res.body = __send__(m[1].to_sym, *(m[2].split('/').map{|x|URI.decode(x)}))
41
43
  else
42
44
  bye(res)
43
45
  end
46
+ @response = nil
44
47
  end
45
48
 
49
+ attr_reader :response
50
+
46
51
  def break(*a)
47
52
  if a.size < 3
48
53
  bye(response)
@@ -89,30 +94,26 @@ module Ruined
89
94
  def locals(*a)
90
95
  if a.size == 0
91
96
  create_varlist Ruined.local_vars
92
- elsif a.size != 2
93
- bye(response)
94
97
  else
95
- Ruined.set(a[0], a[1]).to_s
98
+ eval_var(a)
96
99
  end
97
100
  end
98
101
 
99
102
  def globals(*a)
100
103
  if a.size == 0
101
104
  create_varlist Ruined.global_vars
102
- elsif a.size != 2
103
- bye(response)
104
105
  else
105
- Ruined.set(a[0], a[1]).to_s
106
+ eval_var(a)
106
107
  end
107
108
  end
108
109
 
109
110
  def self(*a)
110
111
  if a.size == 0
111
112
  create_varlist Ruined.self_vars
112
- elsif a.size != 2
113
+ elsif a.size < 2
113
114
  bye(response)
114
115
  else
115
- Ruined.set(a[0], a[1]).to_s
116
+ eval_var(a)
116
117
  end
117
118
  end
118
119
 
@@ -129,6 +130,14 @@ module Ruined
129
130
  end
130
131
  s + '</table>'
131
132
  end
133
+
134
+ def eval_var(a)
135
+ if a.size < 2
136
+ bye(response)
137
+ else
138
+ Ruined.set(a[0], a[1..-1].join('/')).to_s
139
+ end
140
+ end
132
141
 
133
142
  def bye(res)
134
143
  res.status = 404
@@ -221,7 +230,7 @@ EOD
221
230
  out.pos = 0
222
231
  ret = ''
223
232
  out.each_line do |x|
224
- ret << "#{x.chomp}<br/>"
233
+ ret << "#{HTMLUtils.escape(x.chomp)}<br/>"
225
234
  end
226
235
  ret
227
236
  end
@@ -286,4 +295,3 @@ EOD
286
295
  end
287
296
  }
288
297
  end
289
-
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruined
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - arton
@@ -57,6 +57,7 @@ files:
57
57
  - lib/ruined/js/jquery-ui-1.8.5.custom.min.js
58
58
  - readme.txt
59
59
  - gpl-3.0.txt
60
+ - BSDL
60
61
  - ChangeLog
61
62
  has_rdoc: true
62
63
  homepage: http://github.com/arton/ruined