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.

Revisions

  1. coreypurcell revised this gist Sep 23, 2011. No changes.
  2. coreypurcell revised this gist Sep 23, 2011. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions writer_spec.rb
    Original file line number Diff line number Diff line change
    @@ -13,13 +13,9 @@
    end
    b.run

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

  3. coreypurcell revised this gist Sep 23, 2011. 1 changed file with 8 additions and 4 deletions.
    12 changes: 8 additions & 4 deletions writer_spec.rb
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,14 @@
    end
    b.run


    DotWriter.write(b, 'circuit.ps')
    File.exists?('circuit.ps').should be_true

    file = Tempfile.new('testing_circuit.ps')
    begin
    DotWriter.write(b, file.path)
    file.size.should > 0
    ensure
    file.close
    file.unlink
    end
    end

    end
  4. coreypurcell revised this gist Sep 23, 2011. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions writer_spec.rb
    Original file line number Diff line number Diff line change
    @@ -19,4 +19,16 @@

    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
  5. coreypurcell created this gist Sep 23, 2011.
    22 changes: 22 additions & 0 deletions writer_spec.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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


    DotWriter.write(b, 'circuit.ps')
    File.exists?('circuit.ps').should be_true

    end

    end