rundoc 4.1.1 → 4.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 406f197901506713b700c1ff8511fb05904400f806c7dc9d1a134e2b04ab13ab
4
- data.tar.gz: 5b09bdd1560879915be2b52f1f36a13626fe2edfd696a14e66f90d5849b999fc
3
+ metadata.gz: b65a04eca7d7099223b2a626c47eb78e14a8e102266cf880cddc747a0d9fc4a5
4
+ data.tar.gz: 840585e8f0c6b3cddbb1d15354f4fdf862d2440b20054cd1b5344c026adb23d9
5
5
  SHA512:
6
- metadata.gz: '089c0ed9bb56187b8d18ff8eb55662ddf88f592329c028ff24478723bf044e87e75fbc6c84e903bb34bb3e111134a48a6b54861d6af1eb0e2cb9dc533a812da4'
7
- data.tar.gz: f616697430af9d1948d64a9a97a7902ccc3dfa8a61cc4bc4a5b7d3e109944ec50e1475b6889c1168fceba5a733b4d34adc5dd0d068ddff85fcfbff40ee2e8438
6
+ metadata.gz: 99661d14543918c21a988bd1c4cffc1d5c9d73a852a95c16b0905b5ddde312dc986d970b4082921752cd2eac4d786a0ae37f42f3577fdea2df54c6de50376810
7
+ data.tar.gz: 6819d3babc4cb2a7ad1f76386e3d7e7f28886a989e6a31ef052ea87b3b226a6979cc1c2092653fa7aadadd34d3f8af9b268464c2a14c70f385b559ee8a13ca9a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## HEAD
2
2
 
3
+ ## 4.1.3
4
+
5
+ - Fix: Internal error in `background.wait` introduced in 4.1.2 (https://github.com/zombocom/rundoc/pull/97)
6
+ - Fix: Website commands such as `:::>> website.visit(...)` now use lazy lookup (like Background tasks since 4.1.2). This allows `pre.erb` to be used with these commands (https://github.com/zombocom/rundoc/pull/98)
7
+
8
+ ## 4.1.2
9
+
10
+ - 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)
11
+
3
12
  ## 4.1.1
4
13
 
5
14
  - 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
- @spawn = Rundoc::CodeCommand::Background::ProcessSpawn.find(name)
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
- @spawn.log.truncate(0)
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
- @spawn = Rundoc::CodeCommand::Background::ProcessSpawn.find(name)
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
- @spawn.log.read
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
- FileUtils.touch(log)
11
+ @log = log
12
+ @redirect = out
13
+ FileUtils.touch(@log)
11
14
 
12
- @spawn = ProcessSpawn.new(
15
+ @background = nil
16
+ end
17
+
18
+ def background
19
+ @background ||= ProcessSpawn.new(
13
20
  @command,
14
- timeout: timeout,
15
- log: log,
16
- out: out
17
- )
18
- puts "Spawning commmand: `#{@spawn.command}`"
19
- ProcessSpawn.add(@name, @spawn)
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
- @spawn.wait(@wait)
28
- @spawn.check_alive! unless @allow_fail
35
+ background.wait(@wait)
36
+ background.check_alive! unless @allow_fail
29
37
 
30
- @spawn.log.read
38
+ background.log.read
31
39
  end
32
40
 
33
41
  def alive?
34
- !!@spawn.alive?
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
- @spawn.log.read
28
+ background.log.read
24
29
  end
25
30
 
26
31
  def writecontents
27
- @contents_written ||= @spawn.stdin_write(
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
- @spawn = Rundoc::CodeCommand::Background::ProcessSpawn.find(name)
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
- @spawn.stop
13
- @spawn.log.read
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
- @spawn = Rundoc::CodeCommand::Background::ProcessSpawn.find(name)
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
- @spawn.wait(@wait, @timeout_value)
19
+ background.wait(@wait, @timeout_value)
15
20
  ""
16
21
  end
17
22
  end
@@ -2,7 +2,11 @@ class Rundoc::CodeCommand::Website
2
2
  class Navigate < Rundoc::CodeCommand
3
3
  def initialize(name:)
4
4
  @name = name
5
- @driver = Rundoc::CodeCommand::Website::Driver.find(name)
5
+ @driver = nil
6
+ end
7
+
8
+ def driver
9
+ @driver ||= Rundoc::CodeCommand::Website::Driver.find(@name)
6
10
  end
7
11
 
8
12
  def to_md(env = {})
@@ -11,7 +15,7 @@ class Rundoc::CodeCommand::Website
11
15
 
12
16
  def call(env = {})
13
17
  puts "website.navigate [#{@name}]: #{contents}"
14
- @driver.safe_eval(contents, env)
18
+ driver.safe_eval(contents, env)
15
19
  ""
16
20
  end
17
21
 
@@ -1,8 +1,13 @@
1
1
  class Rundoc::CodeCommand::Website
2
2
  class Screenshot < Rundoc::CodeCommand
3
3
  def initialize(name:, upload: false)
4
- @driver = Rundoc::CodeCommand::Website::Driver.find(name)
4
+ @name = name
5
5
  @upload = upload
6
+ @driver = nil
7
+ end
8
+
9
+ def driver
10
+ @driver ||= Rundoc::CodeCommand::Website::Driver.find(@name)
6
11
  end
7
12
 
8
13
  def to_md(env = {})
@@ -10,14 +15,14 @@ class Rundoc::CodeCommand::Website
10
15
  end
11
16
 
12
17
  def call(env = {})
13
- puts "Taking screenshot: #{@driver.current_url}"
14
- filename = @driver.screenshot(
18
+ puts "Taking screenshot: #{driver.current_url}"
19
+ filename = driver.screenshot(
15
20
  upload: @upload,
16
21
  screenshots_dir: env[:context].screenshots_dir
17
22
  )
18
23
 
19
24
  relative_filename = filename.relative_path_from(env[:context].output_dir)
20
- env[:before] << "![Screenshot of #{@driver.current_url}](#{relative_filename})"
25
+ env[:before] << "![Screenshot of #{driver.current_url}](#{relative_filename})"
21
26
  ""
22
27
  end
23
28
 
@@ -6,14 +6,21 @@ class Rundoc::CodeCommand::Website
6
6
  @name = name
7
7
  @url = url
8
8
  @scroll = scroll
9
- @driver = Driver.new(
10
- name: name,
11
- url: url,
12
- height: height,
13
- width: width,
14
- visible: visible
15
- )
16
- Driver.add(@name, @driver)
9
+ @height = height
10
+ @width = width
11
+ @visible = visible
12
+ end
13
+
14
+ def driver
15
+ @driver ||= Driver.new(
16
+ name: @name,
17
+ url: @url,
18
+ height: @height,
19
+ width: @width,
20
+ visible: @visible
21
+ ).tap do |driver|
22
+ Driver.add(@name, driver)
23
+ end
17
24
  end
18
25
 
19
26
  def to_md(env = {})
@@ -26,11 +33,11 @@ class Rundoc::CodeCommand::Website
26
33
 
27
34
  puts message
28
35
 
29
- @driver.visit(@url) if @url
30
- @driver.scroll(@scroll) if @scroll
36
+ driver.visit(@url) if @url
37
+ driver.scroll(@scroll) if @scroll
31
38
 
32
39
  return "" if contents.nil? || contents.empty?
33
- @driver.safe_eval(contents, env)
40
+ driver.safe_eval(contents, env)
34
41
 
35
42
  ""
36
43
  end
@@ -1,3 +1,3 @@
1
1
  module Rundoc
2
- VERSION = "4.1.1"
2
+ VERSION = "4.1.3"
3
3
  end
@@ -6,6 +6,8 @@ class IntegrationWebsiteTest < Minitest::Test
6
6
  ```
7
7
  :::>> website.visit(name: "example", url: "http://example.com")
8
8
  :::>> website.screenshot(name: "example")
9
+ :::>> website.navigate(name: "example")
10
+ session.execute_script "window.scrollBy(0,10)"
9
11
  ```
10
12
  RUBY
11
13
 
@@ -4,16 +4,25 @@ 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
+ # 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(
10
+ "hello there",
11
+ name: "cat",
12
+ wait: "hello"
13
+ )
14
+
7
15
  background_start = Rundoc::CodeCommand::Background::Start.new("cat",
8
16
  name: "cat")
17
+
9
18
  background_start.call
19
+ output = stdin_write.call
20
+ assert_equal("hello there" + $/, output)
10
21
 
11
- output = Rundoc::CodeCommand::Background::StdinWrite.new(
12
- "hello there",
22
+ Rundoc::CodeCommand::Background::Wait.new(
13
23
  name: "cat",
14
24
  wait: "hello"
15
25
  ).call
16
- assert_equal("hello there" + $/, output)
17
26
 
18
27
  Rundoc::CodeCommand::Background::Log::Clear.new(
19
28
  name: "cat"
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.1
4
+ version: 4.1.3
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-13 00:00:00.000000000 Z
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor