command_timer 0.0.7 → 0.0.8
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/command_timer/command.rb +18 -1
- data/lib/command_timer/parser.rb +11 -6
- data/lib/command_timer/runner.rb +1 -0
- data/lib/command_timer/version.rb +1 -1
- metadata +1 -1
@@ -1,8 +1,9 @@
|
|
1
1
|
module CommandTimer
|
2
2
|
class Command
|
3
|
+
attr_writer :burn_time
|
3
4
|
attr_accessor :description
|
4
5
|
attr_accessor :content
|
5
|
-
|
6
|
+
attr_accessor :observer
|
6
7
|
|
7
8
|
def burn_time
|
8
9
|
if @burn_time =~ /[0-9]{2}:[0-9]{2}:[0-9]{2}/
|
@@ -15,6 +16,22 @@ module CommandTimer
|
|
15
16
|
def exec
|
16
17
|
echo_command
|
17
18
|
system @content
|
19
|
+
if @observer
|
20
|
+
puts "===================="
|
21
|
+
puts "= Start observer, input S to stop it."
|
22
|
+
puts "= #{@observer}"
|
23
|
+
puts "===================="
|
24
|
+
thread = Thread.new do
|
25
|
+
system @observer
|
26
|
+
end
|
27
|
+
thread.run
|
28
|
+
input = ""
|
29
|
+
until ["s", "S", "stop"].include?(input) do
|
30
|
+
input = STDIN.gets.chomp
|
31
|
+
end
|
32
|
+
thread.kill
|
33
|
+
puts "Observer stopped."
|
34
|
+
end
|
18
35
|
end
|
19
36
|
|
20
37
|
def echo_command
|
data/lib/command_timer/parser.rb
CHANGED
@@ -10,12 +10,8 @@ module CommandTimer
|
|
10
10
|
data = cell[1]
|
11
11
|
command = Command.new
|
12
12
|
data.each do |k, v|
|
13
|
-
if
|
14
|
-
command.
|
15
|
-
v.each_line do |line|
|
16
|
-
command.content += line.strip
|
17
|
-
command.content += ';' unless command.content.end_with?(';')
|
18
|
-
end
|
13
|
+
if ['content', 'observer'].include?(k)
|
14
|
+
command.send("#{k}=", parse_commands(v))
|
19
15
|
else
|
20
16
|
command.send("#{k}=", v)
|
21
17
|
end
|
@@ -24,5 +20,14 @@ module CommandTimer
|
|
24
20
|
end
|
25
21
|
commands
|
26
22
|
end
|
23
|
+
|
24
|
+
def self.parse_commands(text)
|
25
|
+
commands = ''
|
26
|
+
text.each_line do |line|
|
27
|
+
commands += line.strip
|
28
|
+
commands += ';' unless line.end_with?(';')
|
29
|
+
end
|
30
|
+
commands
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
data/lib/command_timer/runner.rb
CHANGED