rubytext 0.0.75 → 0.0.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubytext.rb +1 -1
- data/lib/settings.rb +7 -0
- data/lib/version.rb +1 -1
- data/test/auto.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57dc0a7d99cad64dde62865a3bd48f8e5cd49644390f9089371fe121a742e6b4
|
4
|
+
data.tar.gz: 4e89cb5f8394f4ac36a2e7599720b9a03111f1de4b428545e245c457b0bf7ca3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125ff3fe92c91935c218f80da9980242725fd6c47949e394d4b35dfc34b252c378193861041e02275cc8f9b934d6f85ca392209cd50b0a5bff18b90b149a8c41
|
7
|
+
data.tar.gz: bf92b9b47a490046e7ebc35d77d9d7bbe7e664034dae83e06b9eb97990c4db5027aa430b9d4c48b6185360904fff66167c6be329d5003761a21b7b63bf24a095
|
data/lib/rubytext.rb
CHANGED
@@ -45,7 +45,7 @@ def make_exception(sym, str)
|
|
45
45
|
define_method(sym) do |*args|
|
46
46
|
msg = str
|
47
47
|
list = (args + [nil]*2)[0..2]
|
48
|
-
list.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg) }
|
48
|
+
list.each.with_index {|arg, i| msg.sub!("$#{i+1}", arg.to_s) }
|
49
49
|
Object.class_eval(sym.to_s).new(msg)
|
50
50
|
end
|
51
51
|
end
|
data/lib/settings.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
module RubyText
|
2
2
|
# Hmm, all these are module-level.
|
3
3
|
|
4
|
+
ValidArgs = [:raw, :_raw, :echo, :_echo, :cbreak, :_cbreak]
|
5
|
+
|
4
6
|
def self.start(*args, log: "/tmp/rubytext.log",
|
5
7
|
fg: White, bg: Blue, scroll: false)
|
6
8
|
$debug ||= File.new(log, "w") if log # FIXME remove global
|
9
|
+
|
10
|
+
args.each {|arg| raise "#{arg} is not valid" unless ValidArgs.include?(arg) }
|
11
|
+
raise "#{fg} is not a color" unless ::Colors.include? fg
|
12
|
+
raise "#{bg} is not a color" unless ::Colors.include? bg
|
13
|
+
|
7
14
|
main = RubyText::Window.main(fg: fg, bg: bg, scroll: scroll)
|
8
15
|
Object.const_set(:STDSCR, main) unless defined? STDSCR
|
9
16
|
$stdscr = STDSCR # FIXME global needed?
|
data/lib/version.rb
CHANGED
data/test/auto.rb
CHANGED
@@ -19,26 +19,26 @@ class MyTest < Minitest::Test
|
|
19
19
|
RubyText.start
|
20
20
|
curr = RubyText.flags
|
21
21
|
RubyText.stop
|
22
|
-
assert curr == [:cbreak, :
|
22
|
+
assert curr == [:cbreak, :_echo, :keypad], "Got #{curr.inspect}"
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def test_002_start_bad_param
|
26
26
|
assert_raises(RTError) { RubyText.start(:foobar); RubyText.stop }
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def test_003_start_bad_color
|
30
30
|
assert_raises(RTError) { RubyText.start(fg: :chartreuse); RubyText.stop }
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_004_set_reset
|
34
34
|
RubyText.start
|
35
|
-
orig = [:cbreak, :
|
35
|
+
orig = [:cbreak, :_echo, :keypad]
|
36
36
|
assert RubyText.flags == orig
|
37
37
|
|
38
38
|
used = [:raw, :_cursor, :_echo]
|
39
39
|
RubyText.set(*used)
|
40
40
|
curr = RubyText.flags
|
41
|
-
assert used.all? {|x| curr.include? x }
|
41
|
+
assert used.all? {|x| curr.include? x }, "Got #{curr.inspect}"
|
42
42
|
|
43
43
|
RubyText.reset
|
44
44
|
assert RubyText.flags == orig
|