Skip to content

Instantly share code, notes, and snippets.

@coreypurcell
Created September 23, 2011 18:32
Show Gist options
  • Save coreypurcell/1238111 to your computer and use it in GitHub Desktop.
Save coreypurcell/1238111 to your computer and use it in GitHub Desktop.
require 'circuitizer'
describe DotWriter do
it "writes a board to a file" do
b = Board.new do
source 's1', true
source 's2', true
and_gate 'AND'
reading 'OUT'
trace 's1', 'AND'
trace 's2', 'AND'
trace 'AND', 'OUT'
end
b.run
Tempfile.new('testing_circuit.ps') do |file|
DotWriter.write(b, file.path)
file.size.should > 0
end
end
end
class DotWriter
def self.write(board, filename)
g = Graph.new(board)
IO.popen("dot -Tps -o #{filename}", 'r+') do |dot|
dot.write(g.to_dot)
end
end
end
@semmons99
Copy link

Tempfile.new('testing_circuit.ps') do |file|
  DotWriter.write(b, file.path)
  file.size.should > 0
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment