cigarette 1.0 → 1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cigarette.rb +57 -6
- metadata +4 -4
data/lib/cigarette.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
|
+
require 'curses'
|
1
2
|
require 'yaml'
|
2
3
|
require 'cigarette/numeric.rb'
|
3
4
|
|
4
5
|
class Cigarette
|
5
6
|
|
6
|
-
|
7
|
+
DEFAULT = Curses::A_NORMAL
|
8
|
+
BLACK = 0
|
9
|
+
RED = 1
|
10
|
+
GREEN = 2
|
11
|
+
YELLOW = 3
|
12
|
+
BLUE = 4
|
13
|
+
MAGENTA = 5
|
14
|
+
CYAN = 6
|
15
|
+
WHITE = 7
|
16
|
+
|
17
|
+
VERSION = "1.1"
|
7
18
|
# Hope.
|
8
19
|
CANCER_DO_NOT_APPEAR = 42
|
9
20
|
|
@@ -20,7 +31,9 @@ class Cigarette
|
|
20
31
|
rescue Exception => e
|
21
32
|
abort "Problem during .cigarette loading: #{e.message}"
|
22
33
|
end
|
23
|
-
|
34
|
+
init_curses
|
35
|
+
deploy_trap
|
36
|
+
display_version
|
24
37
|
lighter_please!
|
25
38
|
end
|
26
39
|
|
@@ -34,11 +47,12 @@ class Cigarette
|
|
34
47
|
status = $?.success? unless defined? status
|
35
48
|
current_status = $?.success?
|
36
49
|
banner = ($?.success? ? "SUCCESS" : "ERROR(S)")
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
50
|
+
Curses.clear
|
51
|
+
display(2, 10, "#{banner} - #{@current_time.strftime("at: %T")}")
|
52
|
+
display(2, 2, "STATUS")
|
53
|
+
display(4, 0, output)
|
41
54
|
status = current_status
|
55
|
+
Curses.refresh
|
42
56
|
end
|
43
57
|
end
|
44
58
|
end
|
@@ -53,5 +67,42 @@ class Cigarette
|
|
53
67
|
end
|
54
68
|
end
|
55
69
|
|
70
|
+
def init_curses
|
71
|
+
Curses.noecho # do not show typed keys
|
72
|
+
Curses.init_screen
|
73
|
+
Curses.stdscr.keypad(true) # enable arrow keys
|
74
|
+
Curses.start_color
|
75
|
+
Curses.init_pair(RED, RED, BLACK)
|
76
|
+
Curses.init_pair(GREEN, GREEN, BLACK)
|
77
|
+
Curses.init_pair(MAGENTA, MAGENTA, WHITE)
|
78
|
+
Curses.init_pair(CYAN, CYAN, BLACK)
|
79
|
+
display(2, 2, "STATUS:")
|
80
|
+
display(2, 10, "WAITING")
|
81
|
+
Curses.refresh
|
82
|
+
end
|
83
|
+
|
84
|
+
def deploy_trap
|
85
|
+
for i in 1 .. 15 # SIGHUP .. SIGTERM
|
86
|
+
if trap(i, "SIG_IGN") != 0 then # 0 for SIG_IGN
|
87
|
+
trap(i) {|sig| onsig(sig) }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def display(line, column, text, color = DEFAULT)
|
93
|
+
Curses.setpos(line, column)
|
94
|
+
Curses.attron(Curses.color_pair(color | DEFAULT)) { Curses.addstr(text) }
|
95
|
+
end
|
96
|
+
|
97
|
+
def display_version
|
98
|
+
display(0,0, "cigarette - Version #{VERSION}")
|
99
|
+
Curses.refresh
|
100
|
+
end
|
101
|
+
|
102
|
+
def onsig(sig)
|
103
|
+
Curses.close_screen
|
104
|
+
exit sig
|
105
|
+
end
|
106
|
+
|
56
107
|
end
|
57
108
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cigarette
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: "1.
|
8
|
+
- 1
|
9
|
+
version: "1.1"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Thibaut Deloffre
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-12-
|
17
|
+
date: 2012-12-24 00:00:00 Z
|
18
18
|
dependencies: []
|
19
19
|
|
20
20
|
description: Tiny test tool
|