lwu (owner)

Revisions

gist: 7199 Download_button fork
public
Description:
DebugShoes, a quick sketch of a class that adds informative debug interactions to a Shoes app
Public Clone URL: git://gist.github.com/7199.git
Embed All Files: show embed
debug_shoes.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Shoes got you down? DebugShoes won't fail silently on ya...
#
class DebugShoes < Shoes
  def self.app(*args, &blk)
    super(*args) do
      begin
        self.instance_eval(&blk)
      rescue => e
        error(e) # log the error and inform the user!
        @err_bar = flow :width => 1.0, :height => 32, :top => self.height-32, :left => 0 do
          background lightgrey
          stack :width => self.width-100
          stack :width => 20, :margin => 4 do image "#{DIR}/static/icon-error.png" end;
          stack :width => 80 do para(link("#{Shoes.log.length} Errors!", :stroke => red) { Shoes.show_log }) end;
        end
      end
    end
  end
end
 
# Note use of DebugShoes rather than ol' Shoes!
#
DebugShoes.app :width=>640, :width=>480 do
  flow do
    stack :width=>100, :margin=>15 do
      background lightblue
    end
    stack :width => 300, :margin=>15 do
      @e = edit_box "Would that I..."
    end
  end
 
  lightgray # d'oh, spellbot fail
 
end