Use {timing, data} tuple as file arg in stdout_stream

This commit is contained in:
Marcin Kulik 2017-07-03 22:40:08 +02:00
parent c5fd094b91
commit 7de966bc3d
2 changed files with 8 additions and 8 deletions

View File

@ -106,7 +106,7 @@ defmodule Asciinema.Asciicasts do
PosterGenerator.generate(asciicast)
end
def stdout_stream(asciicast_file_path) do
def stdout_stream(asciicast_file_path) when is_binary(asciicast_file_path) do
asciicast =
asciicast_file_path
|> File.read!
@ -118,7 +118,7 @@ defmodule Asciinema.Asciicasts do
|> Map.get("stdout")
|> Enum.map(&List.to_tuple/1)
end
def stdout_stream(stdout_timing_path, stdout_data_path) do
def stdout_stream({stdout_timing_path, stdout_data_path}) do
Stream.resource(
fn -> open_stream_files(stdout_timing_path, stdout_data_path) end,
&generate_stream_elem/1,

View File

@ -119,22 +119,22 @@ defmodule Asciinema.AsciicastsTest do
describe "stdout_stream/2" do
test "with gzipped files" do
stream = Asciicasts.stdout_stream("spec/fixtures/0.9.9/stdout.time",
"spec/fixtures/0.9.9/stdout")
stream = Asciicasts.stdout_stream({"spec/fixtures/0.9.9/stdout.time",
"spec/fixtures/0.9.9/stdout"})
assert :ok == Stream.run(stream)
assert [{1.234567, "foobar"}, {0.123456, "baz"}] == Enum.take(stream, 2)
end
test "with bzipped files" do
stream = Asciicasts.stdout_stream("spec/fixtures/0.9.8/stdout.time",
"spec/fixtures/0.9.8/stdout")
stream = Asciicasts.stdout_stream({"spec/fixtures/0.9.8/stdout.time",
"spec/fixtures/0.9.8/stdout"})
assert :ok == Stream.run(stream)
assert [{1.234567, "foobar"}, {0.123456, "baz"}] == Enum.take(stream, 2)
end
test "with bzipped files (utf-8 sequence split between frames)" do
stream = Asciicasts.stdout_stream("spec/fixtures/0.9.8/stdout-split.time",
"spec/fixtures/0.9.8/stdout-split")
stream = Asciicasts.stdout_stream({"spec/fixtures/0.9.8/stdout-split.time",
"spec/fixtures/0.9.8/stdout-split"})
assert :ok == Stream.run(stream)
assert [{1.234567, "xxżó"}, {0.123456, "łć"}, {2.0, "xx"}] == Enum.take(stream, 3)
end