hasu 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hasu/guard.rb +55 -0
- data/lib/hasu/version.rb +1 -1
- data/lib/hasu/window.rb +18 -62
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89e96997e9e719db654653cd173a498b3305b4da
|
4
|
+
data.tar.gz: 4e0929abf8fca155cf9c5df2f67bda0b938e66bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d9b059732fc224e354955f7185add04fa1b0777a0dc5237faff70d510fd67f0498236e176454909d65da7485dfc488c68e3a6f48e24b1ff76609ff9ecefc2e7
|
7
|
+
data.tar.gz: 5f2b5f95aa172a674ff0fc33dcd52be08e012e6afb9ef9ff68e27c3b193565c5ce6897215b8b5423f90f860a81724f27742beb7bf2af451b039c1dcf3d29646e
|
data/lib/hasu/guard.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Hasu
|
2
|
+
module Guard
|
3
|
+
def update(*)
|
4
|
+
if Hasu.reload!
|
5
|
+
Hasu.error = nil
|
6
|
+
end
|
7
|
+
unless Hasu.error
|
8
|
+
super
|
9
|
+
end
|
10
|
+
rescue => e
|
11
|
+
Hasu.error = e
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset
|
15
|
+
super if defined?(super)
|
16
|
+
Hasu.error = nil
|
17
|
+
rescue => e
|
18
|
+
Hasu.error = e
|
19
|
+
end
|
20
|
+
|
21
|
+
def draw(*)
|
22
|
+
if Hasu.error
|
23
|
+
([Hasu.error.inspect] + Hasu.error.backtrace).each_with_index do |line, i|
|
24
|
+
_hasu_font.draw(line.gsub("\n",''), 10, 10 + i * 16, 0)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
begin
|
28
|
+
super
|
29
|
+
rescue => e
|
30
|
+
Hasu.error = e
|
31
|
+
draw
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def _hasu_font
|
37
|
+
@_hasu_font ||= Gosu::Font.new(self, Gosu::default_font_name, 16)
|
38
|
+
end
|
39
|
+
|
40
|
+
def button_down(id)
|
41
|
+
case id
|
42
|
+
when Gosu::KbEscape
|
43
|
+
close
|
44
|
+
when Gosu::Window.char_to_button_id('r')
|
45
|
+
reset
|
46
|
+
else
|
47
|
+
begin
|
48
|
+
super(id)
|
49
|
+
rescue => e
|
50
|
+
Hasu.error = e
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/hasu/version.rb
CHANGED
data/lib/hasu/window.rb
CHANGED
@@ -1,71 +1,27 @@
|
|
1
1
|
require "gosu"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
2
|
+
require "hasu/guard"
|
3
|
+
|
4
|
+
module Hasu
|
5
|
+
class Window < Gosu::Window
|
6
|
+
def self.inherited(other)
|
7
|
+
includer = caller.first.split(":").first
|
8
|
+
Hasu.reloads[includer] = File.mtime(includer)
|
9
|
+
if other.respond_to?(:prepend, true)
|
10
|
+
other.send(:prepend, Hasu::Guard)
|
11
|
+
else
|
12
|
+
warn "Most of Hasu's nifty features (e.g. error catching, file reloading) are only available on Ruby >= 2.0."
|
13
|
+
end
|
13
14
|
end
|
14
|
-
end
|
15
15
|
|
16
|
-
|
17
|
-
super
|
18
|
-
reset
|
19
|
-
end
|
20
|
-
|
21
|
-
def update(*)
|
22
|
-
if Hasu.reload!
|
23
|
-
Hasu.error = nil
|
24
|
-
end
|
25
|
-
unless Hasu.error
|
16
|
+
def initialize(*)
|
26
17
|
super
|
18
|
+
reset
|
27
19
|
end
|
28
|
-
rescue => e
|
29
|
-
Hasu.error = e
|
30
|
-
end
|
31
|
-
|
32
|
-
def reset
|
33
|
-
super if defined?(super)
|
34
|
-
Hasu.error = nil
|
35
|
-
rescue => e
|
36
|
-
Hasu.error = e
|
37
|
-
end
|
38
|
-
|
39
|
-
def draw(*)
|
40
|
-
if Hasu.error
|
41
|
-
([Hasu.error.inspect] + Hasu.error.backtrace).each_with_index do |line, i|
|
42
|
-
_hasu_font.draw(line.gsub("\n",''), 10, 10 + i * 16, 0)
|
43
|
-
end
|
44
|
-
else
|
45
|
-
begin
|
46
|
-
super
|
47
|
-
rescue => e
|
48
|
-
Hasu.error = e
|
49
|
-
draw
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
20
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
def button_down(id)
|
59
|
-
case id
|
60
|
-
when Gosu::KbEscape
|
61
|
-
close
|
62
|
-
when Gosu::Window.char_to_button_id('r')
|
63
|
-
reset
|
64
|
-
else
|
65
|
-
begin
|
66
|
-
super(id)
|
67
|
-
rescue => e
|
68
|
-
Hasu.error = e
|
21
|
+
def self.run
|
22
|
+
unless @running
|
23
|
+
@running = true
|
24
|
+
new.show
|
69
25
|
end
|
70
26
|
end
|
71
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hasu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Fairley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- example/rect.rb
|
69
69
|
- hasu.gemspec
|
70
70
|
- lib/hasu.rb
|
71
|
+
- lib/hasu/guard.rb
|
71
72
|
- lib/hasu/version.rb
|
72
73
|
- lib/hasu/window.rb
|
73
74
|
homepage: https://github.com/michaelfairley/hasu
|