Use {timing, data} tuple as file arg in stdout_stream
This commit is contained in:
parent
c5fd094b91
commit
7de966bc3d
@ -106,7 +106,7 @@ defmodule Asciinema.Asciicasts do
|
|||||||
PosterGenerator.generate(asciicast)
|
PosterGenerator.generate(asciicast)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stdout_stream(asciicast_file_path) do
|
def stdout_stream(asciicast_file_path) when is_binary(asciicast_file_path) do
|
||||||
asciicast =
|
asciicast =
|
||||||
asciicast_file_path
|
asciicast_file_path
|
||||||
|> File.read!
|
|> File.read!
|
||||||
@ -118,7 +118,7 @@ defmodule Asciinema.Asciicasts do
|
|||||||
|> Map.get("stdout")
|
|> Map.get("stdout")
|
||||||
|> Enum.map(&List.to_tuple/1)
|
|> Enum.map(&List.to_tuple/1)
|
||||||
end
|
end
|
||||||
def stdout_stream(stdout_timing_path, stdout_data_path) do
|
def stdout_stream({stdout_timing_path, stdout_data_path}) do
|
||||||
Stream.resource(
|
Stream.resource(
|
||||||
fn -> open_stream_files(stdout_timing_path, stdout_data_path) end,
|
fn -> open_stream_files(stdout_timing_path, stdout_data_path) end,
|
||||||
&generate_stream_elem/1,
|
&generate_stream_elem/1,
|
||||||
|
@ -119,22 +119,22 @@ defmodule Asciinema.AsciicastsTest do
|
|||||||
|
|
||||||
describe "stdout_stream/2" do
|
describe "stdout_stream/2" do
|
||||||
test "with gzipped files" do
|
test "with gzipped files" do
|
||||||
stream = Asciicasts.stdout_stream("spec/fixtures/0.9.9/stdout.time",
|
stream = Asciicasts.stdout_stream({"spec/fixtures/0.9.9/stdout.time",
|
||||||
"spec/fixtures/0.9.9/stdout")
|
"spec/fixtures/0.9.9/stdout"})
|
||||||
assert :ok == Stream.run(stream)
|
assert :ok == Stream.run(stream)
|
||||||
assert [{1.234567, "foobar"}, {0.123456, "baz"}] == Enum.take(stream, 2)
|
assert [{1.234567, "foobar"}, {0.123456, "baz"}] == Enum.take(stream, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with bzipped files" do
|
test "with bzipped files" do
|
||||||
stream = Asciicasts.stdout_stream("spec/fixtures/0.9.8/stdout.time",
|
stream = Asciicasts.stdout_stream({"spec/fixtures/0.9.8/stdout.time",
|
||||||
"spec/fixtures/0.9.8/stdout")
|
"spec/fixtures/0.9.8/stdout"})
|
||||||
assert :ok == Stream.run(stream)
|
assert :ok == Stream.run(stream)
|
||||||
assert [{1.234567, "foobar"}, {0.123456, "baz"}] == Enum.take(stream, 2)
|
assert [{1.234567, "foobar"}, {0.123456, "baz"}] == Enum.take(stream, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "with bzipped files (utf-8 sequence split between frames)" do
|
test "with bzipped files (utf-8 sequence split between frames)" do
|
||||||
stream = Asciicasts.stdout_stream("spec/fixtures/0.9.8/stdout-split.time",
|
stream = Asciicasts.stdout_stream({"spec/fixtures/0.9.8/stdout-split.time",
|
||||||
"spec/fixtures/0.9.8/stdout-split")
|
"spec/fixtures/0.9.8/stdout-split"})
|
||||||
assert :ok == Stream.run(stream)
|
assert :ok == Stream.run(stream)
|
||||||
assert [{1.234567, "xxżó"}, {0.123456, "łć"}, {2.0, "xx"}] == Enum.take(stream, 3)
|
assert [{1.234567, "xxżó"}, {0.123456, "łć"}, {2.0, "xx"}] == Enum.take(stream, 3)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user