File tree Expand file tree Collapse file tree 5 files changed +12
-94
lines changed
Expand file tree Collapse file tree 5 files changed +12
-94
lines changed Original file line number Diff line number Diff line change 66/pkg /
77/spec /reports /
88/tmp /
9+ Gemfile.lock
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 22
33module Jekyll
44 module Graphviz
5- VERSION = "0.1.3 "
5+ VERSION = "0.1.4 "
66 end
77end
Original file line number Diff line number Diff line change @@ -6,9 +6,12 @@ class Graphviz < Converter
66 safe true
77 priority :low
88
9+ attr_accessor :cache
10+
911 def setup
1012 require 'ruby-graphviz'
1113 @format = ( @config . dig ( "graphviz" , "format" ) || :svg ) . to_sym
14+ @cache = { }
1215 @setup = true
1316 end
1417
@@ -23,7 +26,7 @@ def output_ext(ext)
2326
2427 def convert ( content )
2528 setup unless @setup
26- GraphViz . parse_string ( content ) . output ( @format => String )
29+ @cache [ content ] ||= GraphViz . parse_string ( content ) . output ( @format => String )
2730 end
2831 end
2932 end
Original file line number Diff line number Diff line change @@ -31,6 +31,12 @@ def test_output_to_another_output_type
3131 assert_equal ( Encoding ::ASCII_8BIT , output . encoding )
3232 end
3333
34+ def test_files_are_cached
35+ content = "digraph x { a -> b }"
36+ converter . convert ( content )
37+ assert ( converter . cache . key? ( content ) )
38+ end
39+
3440 def converter ( opts = { } )
3541 config = Jekyll ::Configuration ::DEFAULTS . merge ( opts )
3642 @converter ||= Jekyll ::Converters ::Graphviz . new ( config )
You can’t perform that action at this time.
0 commit comments