Class: Ruined::DebugServlet

Inherits:
HTTPServlet::AbstractServlet
  • Object
show all
Includes:
WEBrick::HTMLUtils
Defined in:
lib/ruined/ruinmain.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



87
88
89
# File 'lib/ruined/ruinmain.rb', line 87

def response
  @response
end

Instance Method Details

#break(*a) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/ruined/ruinmain.rb', line 89

def break(*a)
  if a.size < 3
    bye(response)
  else
    point = [a[1..(a.size - 2)].join('/'), a[a.size - 1].to_i]
    if a[0] == 'true'
      Ruined.breakpoints << point
    else
      Ruined.breakpoints.delete point
    end
    JSON(point)
  end
end

#cont(*a) ⇒ Object



114
115
116
117
118
# File 'lib/ruined/ruinmain.rb', line 114

def cont(*a)
  Ruined.release 0
  Ruined.wait 1
  JSON(Ruined.current_context)
end

#do_GET(req, res) ⇒ Object



76
77
78
79
80
81
82
83
84
85
# File 'lib/ruined/ruinmain.rb', line 76

def do_GET(req, res)
  m = %r|/debug/([^/?]+)/?([^?]*).*\Z|.match(req.unparsed_uri)
  if m
    @response = res
    res.body = __send__(m[1].to_sym, *(m[2].split('/').map{|x|URI.decode(x)}))
  else
    bye(res)        
  end
  @response = nil
end

#file(*a) ⇒ Object



124
125
126
127
128
129
130
# File 'lib/ruined/ruinmain.rb', line 124

def file(*a)
  r = '<table>'
  File.open(a.join('/')).each_line do |line|
    r << "<tr><td><pre>#{escape(line)}</pre></td></tr>"
  end.close
  r + '</table>'
end

#globals(*a) ⇒ Object



140
141
142
143
144
145
146
# File 'lib/ruined/ruinmain.rb', line 140

def globals(*a)
  if a.size == 0
    create_varlist Ruined.global_vars
  else
    eval_var(a)
  end
end

#locals(*a) ⇒ Object



132
133
134
135
136
137
138
# File 'lib/ruined/ruinmain.rb', line 132

def locals(*a)
  if a.size == 0
    create_varlist Ruined.local_vars
  else
    eval_var(a)
  end
end

#run(*a) ⇒ Object



103
104
# File 'lib/ruined/ruinmain.rb', line 103

def run(*a)
end

#self(*a) ⇒ Object



148
149
150
151
152
153
154
155
156
# File 'lib/ruined/ruinmain.rb', line 148

def self(*a)
  if a.size == 0
    create_varlist Ruined.self_vars
  elsif a.size < 2
    bye(response)
  else
    eval_var(a)
  end
end

#service(req, res) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/ruined/ruinmain.rb', line 69

def service(req, res)
  if Ruined.local_call?(req.addr)
    super
  else
    bye(res)
  end
end

#start(*a) ⇒ Object



158
159
160
# File 'lib/ruined/ruinmain.rb', line 158

def start(*a)
  '<html>start</html>'
end

#step(*a) ⇒ Object



120
121
122
# File 'lib/ruined/ruinmain.rb', line 120

def step(*a)
  cont(a)
end

#stepping(*a) ⇒ Object



109
110
111
112
# File 'lib/ruined/ruinmain.rb', line 109

def stepping(*a)
  Ruined.wait 1      
  JSON(Ruined.current_context)
end

#stop(*a) ⇒ Object



106
107
# File 'lib/ruined/ruinmain.rb', line 106

def stop(*a)
end