File tree Expand file tree Collapse file tree 5 files changed +51
-4
lines changed Expand file tree Collapse file tree 5 files changed +51
-4
lines changed Original file line number Diff line number Diff line change
1
+ defmodule Mudbrick.Drawing do
2
+ defstruct lines: [ ]
3
+
4
+ def new ( ) do
5
+ struct! ( __MODULE__ , [ ] )
6
+ end
7
+
8
+ defmodule Path do
9
+ @ enforce_keys [ :from , :to ]
10
+ defstruct [ :from , :to ]
11
+
12
+ def new ( drawing , opts ) do
13
+ Map . update! ( drawing , :lines , fn lines ->
14
+ [ struct! ( __MODULE__ , opts ) | lines ]
15
+ end )
16
+ end
17
+ end
18
+ end
Original file line number Diff line number Diff line change
1
+ defmodule Mudbrick.Drawing.Output do
2
+ defstruct operations: [ ]
3
+
4
+ def from ( _ ) do
5
+ % __MODULE__ { }
6
+ end
7
+ end
Original file line number Diff line number Diff line change
1
+ defmodule Mudbrick.DrawingTest do
2
+ use ExUnit.Case , async: true
3
+
4
+ import Mudbrick.TestHelper , only: [ output: 2 ]
5
+
6
+ alias Mudbrick.Drawing
7
+
8
+ test "can make an empty line drawing" do
9
+ assert [ ] =
10
+ output ( fn ->
11
+ Drawing . new ( )
12
+ end )
13
+ |> operations ( )
14
+ end
15
+
16
+ defp output ( f ) , do: output ( fn _ -> f . ( ) end , Mudbrick.Drawing.Output )
17
+
18
+ defp operations ( ops ) do
19
+ Enum . map ( ops , & Mudbrick.TestHelper . show / 1 )
20
+ end
21
+ end
Original file line number Diff line number Diff line change 1
1
defmodule Mudbrick.TextBlockTest do
2
2
use ExUnit.Case , async: true
3
3
4
- import Mudbrick.TestHelper , only: [ output: 1 ]
4
+ import Mudbrick.TestHelper , only: [ output: 2 ]
5
5
6
6
alias Mudbrick.TextBlock
7
7
alias Mudbrick.TextBlock.Line
@@ -283,6 +283,8 @@ defmodule Mudbrick.TextBlockTest do
283
283
end
284
284
end
285
285
286
+ defp output ( f ) , do: output ( f , Mudbrick.TextBlock.Output )
287
+
286
288
defp operations ( ops ) do
287
289
Enum . map ( ops , & Mudbrick.TestHelper . show / 1 )
288
290
end
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ defmodule Mudbrick.TestHelper do
6
6
@ example_png Path . join ( __DIR__ , "fixtures/Example.png" ) |> File . read! ( )
7
7
8
8
alias Mudbrick.Page
9
- alias Mudbrick.TextBlock.Output
10
9
11
10
def show ( o ) do
12
11
Mudbrick.Object . from ( o ) |> to_string ( )
@@ -38,7 +37,7 @@ defmodule Mudbrick.TestHelper do
38
37
@ example_png
39
38
end
40
39
41
- def output ( f ) when is_function ( f ) do
40
+ def output ( f , output_mod ) when is_function ( f ) do
42
41
import Mudbrick
43
42
44
43
{ doc , _contents_obj } =
@@ -65,7 +64,7 @@ defmodule Mudbrick.TestHelper do
65
64
}
66
65
} )
67
66
68
- ops = Output . from ( block ) . operations
67
+ ops = output_mod . from ( block ) . operations
69
68
70
69
context
71
70
|> Mudbrick.ContentStream . put ( operations: ops )
You can’t perform that action at this time.
0 commit comments