Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketch out the structure for backends
- Loading branch information
Showing
5 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Minitrace::Backend | ||
def process(event) | ||
raise NotImplementedError | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require "minitrace/backend" | ||
|
||
module Minitrace::Backends | ||
autoload :Spy, "minitrace/backends/spy" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Minitrace::Backends::Spy < Minitrace::Backend | ||
def processed | ||
@processed ||= [] | ||
end | ||
|
||
def process(event) | ||
processed << event | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class Minitrace::Backends::SpyTest < Minitest::Test | ||
def test_process | ||
spy = Minitrace::Backends::Spy.new | ||
|
||
a = Minitrace::Event.new | ||
spy.process(a) | ||
|
||
b = Minitrace::Event.new | ||
spy.process(b) | ||
|
||
c = Minitrace::Event.new | ||
spy.process(c) | ||
|
||
assert { spy.processed == [a, b, c] } | ||
end | ||
end |