rundoc 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rundoc/code_command/background/log/clear.rb +7 -2
- data/lib/rundoc/code_command/background/log/read.rb +7 -2
- data/lib/rundoc/code_command/background/start.rb +20 -12
- data/lib/rundoc/code_command/background/stdin_write.rb +8 -3
- data/lib/rundoc/code_command/background/stop.rb +8 -3
- data/lib/rundoc/code_command/background/wait.rb +7 -2
- data/lib/rundoc/version.rb +1 -1
- data/test/rundoc/code_commands/background_test.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 175e8af5e0beeb7acca8d32740f3379d68771ba207d723a1f51495848645249c
|
4
|
+
data.tar.gz: ac404b2c8337948628d7f18b90b20c57668f8a059d6e10c9c64354d21e04ac58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758367c980b07a1d57f63fd0272e16f4ac4a93c42e747b9da200891438e661cede3edde72bb23f25ceb3e8c35074c53a59cb0a7e141edcb78684569163134deb
|
7
|
+
data.tar.gz: 6250e519af65a9800d4bb41926adb1713ef8e12d22e4503bb8eb8369514ce82db1036e289b80d0bd0fa8fb5cdb5d2f92fc2dc6e9ce029f5fb4a873f872e8f310
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
+
## 4.1.2
|
4
|
+
|
5
|
+
- Fix: Background task name lookup is now lazy, this fixes a bug when using `:::>- pre.erb background.start(...)` (https://github.com/zombocom/rundoc/pull/95)
|
6
|
+
|
3
7
|
## 4.1.1
|
4
8
|
|
5
9
|
- Fix: Visibility forwarding for `pre.erb` was accidentally reversed, this is now fixed. (https://github.com/zombocom/rundoc/pull/93)
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Rundoc::CodeCommand::Background::Log
|
2
2
|
class Clear < Rundoc::CodeCommand
|
3
3
|
def initialize(name:)
|
4
|
-
@
|
4
|
+
@name = name
|
5
|
+
@background = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
def background
|
9
|
+
@background ||= Rundoc::CodeCommand::Background::ProcessSpawn.find(@name)
|
5
10
|
end
|
6
11
|
|
7
12
|
def to_md(env = {})
|
@@ -9,7 +14,7 @@ class Rundoc::CodeCommand::Background::Log
|
|
9
14
|
end
|
10
15
|
|
11
16
|
def call(env = {})
|
12
|
-
|
17
|
+
background.log.truncate(0)
|
13
18
|
""
|
14
19
|
end
|
15
20
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Rundoc::CodeCommand::Background::Log
|
2
2
|
class Read < Rundoc::CodeCommand
|
3
3
|
def initialize(name:)
|
4
|
-
@
|
4
|
+
@name = name
|
5
|
+
@background = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
def background
|
9
|
+
@background ||= Rundoc::CodeCommand::Background::ProcessSpawn.find(@name)
|
5
10
|
end
|
6
11
|
|
7
12
|
def to_md(env = {})
|
@@ -9,7 +14,7 @@ class Rundoc::CodeCommand::Background::Log
|
|
9
14
|
end
|
10
15
|
|
11
16
|
def call(env = {})
|
12
|
-
|
17
|
+
background.log.read
|
13
18
|
end
|
14
19
|
end
|
15
20
|
end
|
@@ -3,20 +3,28 @@ require "tempfile"
|
|
3
3
|
class Rundoc::CodeCommand::Background
|
4
4
|
class Start < Rundoc::CodeCommand
|
5
5
|
def initialize(command, name:, wait: nil, timeout: 5, log: Tempfile.new("log"), out: "2>&1", allow_fail: false)
|
6
|
+
@timeout = timeout
|
6
7
|
@command = command
|
7
8
|
@name = name
|
8
9
|
@wait = wait
|
9
10
|
@allow_fail = allow_fail
|
10
|
-
|
11
|
+
@log = log
|
12
|
+
@redirect = out
|
13
|
+
FileUtils.touch(@log)
|
11
14
|
|
12
|
-
@
|
15
|
+
@background = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def background
|
19
|
+
@background ||= ProcessSpawn.new(
|
13
20
|
@command,
|
14
|
-
timeout: timeout,
|
15
|
-
log: log,
|
16
|
-
out:
|
17
|
-
)
|
18
|
-
|
19
|
-
|
21
|
+
timeout: @timeout,
|
22
|
+
log: @log,
|
23
|
+
out: @redirect
|
24
|
+
).tap do |spawn|
|
25
|
+
puts "Spawning commmand: `#{spawn.command}`"
|
26
|
+
ProcessSpawn.add(@name, spawn)
|
27
|
+
end
|
20
28
|
end
|
21
29
|
|
22
30
|
def to_md(env = {})
|
@@ -24,14 +32,14 @@ class Rundoc::CodeCommand::Background
|
|
24
32
|
end
|
25
33
|
|
26
34
|
def call(env = {})
|
27
|
-
|
28
|
-
|
35
|
+
background.wait(@wait)
|
36
|
+
background.check_alive! unless @allow_fail
|
29
37
|
|
30
|
-
|
38
|
+
background.log.read
|
31
39
|
end
|
32
40
|
|
33
41
|
def alive?
|
34
|
-
|
42
|
+
!!background.alive?
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
@@ -6,10 +6,15 @@ class Rundoc::CodeCommand::Background
|
|
6
6
|
def initialize(contents, name:, wait:, timeout: 5, ending: $/)
|
7
7
|
@contents = contents
|
8
8
|
@ending = ending
|
9
|
-
@spawn = Rundoc::CodeCommand::Background::ProcessSpawn.find(name)
|
10
9
|
@wait = wait
|
10
|
+
@name = name
|
11
11
|
@timeout_value = Integer(timeout)
|
12
12
|
@contents_written = nil
|
13
|
+
@background = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def background
|
17
|
+
@background ||= Rundoc::CodeCommand::Background::ProcessSpawn.find(@name)
|
13
18
|
end
|
14
19
|
|
15
20
|
# The command is rendered (`:::>-`) by the output of the `def call` method.
|
@@ -20,11 +25,11 @@ class Rundoc::CodeCommand::Background
|
|
20
25
|
# The contents produced by the command (`:::->`) are rendered by the `def to_md` method.
|
21
26
|
def call(env = {})
|
22
27
|
writecontents
|
23
|
-
|
28
|
+
background.log.read
|
24
29
|
end
|
25
30
|
|
26
31
|
def writecontents
|
27
|
-
@contents_written ||=
|
32
|
+
@contents_written ||= background.stdin_write(
|
28
33
|
contents,
|
29
34
|
wait: @wait,
|
30
35
|
ending: @ending,
|
@@ -1,7 +1,12 @@
|
|
1
1
|
class Rundoc::CodeCommand::Background
|
2
2
|
class Stop < Rundoc::CodeCommand
|
3
3
|
def initialize(name:)
|
4
|
-
@
|
4
|
+
@name = name
|
5
|
+
@background = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
def background
|
9
|
+
@background ||= Rundoc::CodeCommand::Background::ProcessSpawn.find(@name)
|
5
10
|
end
|
6
11
|
|
7
12
|
def to_md(env = {})
|
@@ -9,8 +14,8 @@ class Rundoc::CodeCommand::Background
|
|
9
14
|
end
|
10
15
|
|
11
16
|
def call(env = {})
|
12
|
-
|
13
|
-
|
17
|
+
background.stop
|
18
|
+
background.log.read
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
class Rundoc::CodeCommand::Background
|
2
2
|
class Wait < Rundoc::CodeCommand
|
3
3
|
def initialize(name:, wait:, timeout: 5)
|
4
|
-
@
|
4
|
+
@name = name
|
5
5
|
@wait = wait
|
6
6
|
@timeout_value = Integer(timeout)
|
7
|
+
@background = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def background
|
11
|
+
@background ||= Rundoc::CodeCommand::Background::ProcessSpawn.find(name)
|
7
12
|
end
|
8
13
|
|
9
14
|
def to_md(env = {})
|
@@ -11,7 +16,7 @@ class Rundoc::CodeCommand::Background
|
|
11
16
|
end
|
12
17
|
|
13
18
|
def call(env = {})
|
14
|
-
|
19
|
+
background.wait(@wait, @timeout_value)
|
15
20
|
""
|
16
21
|
end
|
17
22
|
end
|
data/lib/rundoc/version.rb
CHANGED
@@ -4,15 +4,19 @@ class BackgroundTest < Minitest::Test
|
|
4
4
|
def test_stdin_with_cat_echo
|
5
5
|
Dir.mktmpdir do |dir|
|
6
6
|
Dir.chdir(dir) do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
output = Rundoc::CodeCommand::Background::StdinWrite.new(
|
7
|
+
# Intentionally out of order, should not raise an error as long as "cat"
|
8
|
+
# command exists at execution time
|
9
|
+
stdin_write = Rundoc::CodeCommand::Background::StdinWrite.new(
|
12
10
|
"hello there",
|
13
11
|
name: "cat",
|
14
12
|
wait: "hello"
|
15
|
-
)
|
13
|
+
)
|
14
|
+
|
15
|
+
background_start = Rundoc::CodeCommand::Background::Start.new("cat",
|
16
|
+
name: "cat")
|
17
|
+
|
18
|
+
background_start.call
|
19
|
+
output = stdin_write.call
|
16
20
|
assert_equal("hello there" + $/, output)
|
17
21
|
|
18
22
|
Rundoc::CodeCommand::Background::Log::Clear.new(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rundoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|