gviz 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/gviz/core.rb +1 -1
 - data/lib/gviz/version.rb +1 -1
 - data/spec/gviz_spec.rb +40 -54
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 111365e7127ce64d1645957d112c7ea204dd6aed
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5784cd73f99d927fa79378d020e176f742717546
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a239468f16cbbb6583724c8752da66b29227551b51727607ad69dfef87137e22f0ad0ce9c5f02dc53e66a66e2df7d03c606d2ea4841f1157cdafc1a03b1fe7d1
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1daf776b599733172e81f856eec100039d0a2083a2f8731547cae76a21e2695489cc39f794b0a598affc9e9b02caf3fe8ed7cc5110edce30dddfefd3956279a7
         
     | 
    
        data/lib/gviz/core.rb
    CHANGED
    
    | 
         @@ -242,7 +242,7 @@ class Gviz 
     | 
|
| 
       242 
242 
     | 
    
         
             
              def build_attrs(attrs, join=true)
         
     | 
| 
       243 
243 
     | 
    
         
             
                return nil if attrs.empty?
         
     | 
| 
       244 
244 
     | 
    
         
             
                arr = attrs.map { |k, v|
         
     | 
| 
       245 
     | 
    
         
            -
                  if v.match(/^\s*<.*>\s*$/)  # accept HTML labels
         
     | 
| 
      
 245 
     | 
    
         
            +
                  if v.to_s.match(/^\s*<.*>\s*$/)  # accept HTML labels
         
     | 
| 
       246 
246 
     | 
    
         
             
                    "#{k}=<#{v}>".gsub("\n", '').gsub(/\s+</, '<')
         
     | 
| 
       247 
247 
     | 
    
         
             
                  else
         
     | 
| 
       248 
248 
     | 
    
         
             
                    %(#{k}="#{v}").gsub("\n", "\\n")
         
     | 
    
        data/lib/gviz/version.rb
    CHANGED
    
    
    
        data/spec/gviz_spec.rb
    CHANGED
    
    | 
         @@ -271,6 +271,46 @@ describe Gviz do 
     | 
|
| 
       271 
271 
     | 
    
         
             
                end
         
     | 
| 
       272 
272 
     | 
    
         
             
              end
         
     | 
| 
       273 
273 
     | 
    
         | 
| 
      
 274 
     | 
    
         
            +
              describe "#build_attrs" do
         
     | 
| 
      
 275 
     | 
    
         
            +
                context "with non-string values" do
         
     | 
| 
      
 276 
     | 
    
         
            +
                  it "converts float to string" do
         
     | 
| 
      
 277 
     | 
    
         
            +
                    expect( gv.send("build_attrs", {width:1.0}) ).to eq "[width=\"1.0\"]"
         
     | 
| 
      
 278 
     | 
    
         
            +
                  end
         
     | 
| 
      
 279 
     | 
    
         
            +
                end
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                context "handling newline characters in values" do
         
     | 
| 
      
 282 
     | 
    
         
            +
                  it "accepts as newline" do
         
     | 
| 
      
 283 
     | 
    
         
            +
                    expect( gv.send("build_attrs", {label:"hello\nworld"}) ).to eq "[label=\"hello\\nworld\"]"
         
     | 
| 
      
 284 
     | 
    
         
            +
                  end
         
     | 
| 
      
 285 
     | 
    
         
            +
                end
         
     | 
| 
      
 286 
     | 
    
         
            +
             
     | 
| 
      
 287 
     | 
    
         
            +
                context "with unicode" do
         
     | 
| 
      
 288 
     | 
    
         
            +
                  it "accepts as unicode values" do
         
     | 
| 
      
 289 
     | 
    
         
            +
                    expect( gv.send("build_attrs", {label:"こんにちは、世界!"}) ).to eq "[label=\"こんにちは、世界!\"]"
         
     | 
| 
      
 290 
     | 
    
         
            +
                  end
         
     | 
| 
      
 291 
     | 
    
         
            +
                end
         
     | 
| 
      
 292 
     | 
    
         
            +
             
     | 
| 
      
 293 
     | 
    
         
            +
                context "with HTML tag values" do
         
     | 
| 
      
 294 
     | 
    
         
            +
                  tag = '<TABLE><TR><TD><IMG SRC="logo.gif" /></TD></TR></TABLE>'
         
     | 
| 
      
 295 
     | 
    
         
            +
                  it "accepts as HTML tags" do
         
     | 
| 
      
 296 
     | 
    
         
            +
                    expect( gv.send("build_attrs", {label:tag}) ).to eq "[label=<<TABLE><TR><TD><IMG SRC=\"logo.gif\" /></TD></TR></TABLE>>]"
         
     | 
| 
      
 297 
     | 
    
         
            +
                  end
         
     | 
| 
      
 298 
     | 
    
         
            +
                end
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
                context "with HTML tag values passed by heredoc" do
         
     | 
| 
      
 301 
     | 
    
         
            +
                  tag =<<-HTML
         
     | 
| 
      
 302 
     | 
    
         
            +
                  <TABLE>
         
     | 
| 
      
 303 
     | 
    
         
            +
                    <TR>
         
     | 
| 
      
 304 
     | 
    
         
            +
                      <TD><IMG SRC="logo2.gif" /></TD>
         
     | 
| 
      
 305 
     | 
    
         
            +
                    </TR>
         
     | 
| 
      
 306 
     | 
    
         
            +
                  </TABLE>
         
     | 
| 
      
 307 
     | 
    
         
            +
                  HTML
         
     | 
| 
      
 308 
     | 
    
         
            +
                  it "accepts as HTML tags" do
         
     | 
| 
      
 309 
     | 
    
         
            +
                    expect( gv.send("build_attrs", {label:tag}) ).to eq "[label=<<TABLE><TR><TD><IMG SRC=\"logo2.gif\" /></TD></TR></TABLE>>]"
         
     | 
| 
      
 310 
     | 
    
         
            +
                  end
         
     | 
| 
      
 311 
     | 
    
         
            +
                end
         
     | 
| 
      
 312 
     | 
    
         
            +
              end
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
       274 
314 
     | 
    
         
             
              describe "#to_s" do
         
     | 
| 
       275 
315 
     | 
    
         
             
                context "without attrs" do
         
     | 
| 
       276 
316 
     | 
    
         
             
                  before do
         
     | 
| 
         @@ -399,60 +439,6 @@ describe Gviz do 
     | 
|
| 
       399 
439 
     | 
    
         
             
                  end
         
     | 
| 
       400 
440 
     | 
    
         
             
                end
         
     | 
| 
       401 
441 
     | 
    
         | 
| 
       402 
     | 
    
         
            -
                context "when a label include `\\n`" do
         
     | 
| 
       403 
     | 
    
         
            -
                  before { gv.node(:a, label:"hello\nworld") }
         
     | 
| 
       404 
     | 
    
         
            -
                  subject { gv.to_s }
         
     | 
| 
       405 
     | 
    
         
            -
                  it do
         
     | 
| 
       406 
     | 
    
         
            -
                    should eql ~<<-EOS
         
     | 
| 
       407 
     | 
    
         
            -
                      digraph G {
         
     | 
| 
       408 
     | 
    
         
            -
                        a[label="hello\\nworld"];
         
     | 
| 
       409 
     | 
    
         
            -
                      }
         
     | 
| 
       410 
     | 
    
         
            -
                      EOS
         
     | 
| 
       411 
     | 
    
         
            -
                  end
         
     | 
| 
       412 
     | 
    
         
            -
                end
         
     | 
| 
       413 
     | 
    
         
            -
             
     | 
| 
       414 
     | 
    
         
            -
                context "when a label include unicode" do
         
     | 
| 
       415 
     | 
    
         
            -
                  before { gv.node(:a, label:"こんにちは、世界!") }
         
     | 
| 
       416 
     | 
    
         
            -
                  subject { gv.to_s }
         
     | 
| 
       417 
     | 
    
         
            -
                  it do
         
     | 
| 
       418 
     | 
    
         
            -
                    should eql ~<<-EOS
         
     | 
| 
       419 
     | 
    
         
            -
                      digraph G {
         
     | 
| 
       420 
     | 
    
         
            -
                        a[label="こんにちは、世界!"];
         
     | 
| 
       421 
     | 
    
         
            -
                      }
         
     | 
| 
       422 
     | 
    
         
            -
                      EOS
         
     | 
| 
       423 
     | 
    
         
            -
                  end
         
     | 
| 
       424 
     | 
    
         
            -
                end
         
     | 
| 
       425 
     | 
    
         
            -
             
     | 
| 
       426 
     | 
    
         
            -
                context "when a label include HTML-like tags" do
         
     | 
| 
       427 
     | 
    
         
            -
                  before { gv.node(:a, label:'<TABLE><TR><TD><IMG SRC="logo.gif" /></TD></TR></TABLE>') }
         
     | 
| 
       428 
     | 
    
         
            -
                  subject { gv.to_s }
         
     | 
| 
       429 
     | 
    
         
            -
                  it do
         
     | 
| 
       430 
     | 
    
         
            -
                    should eql ~<<-EOS
         
     | 
| 
       431 
     | 
    
         
            -
                      digraph G {
         
     | 
| 
       432 
     | 
    
         
            -
                        a[label=<<TABLE><TR><TD><IMG SRC="logo.gif" /></TD></TR></TABLE>>];
         
     | 
| 
       433 
     | 
    
         
            -
                      }
         
     | 
| 
       434 
     | 
    
         
            -
                      EOS
         
     | 
| 
       435 
     | 
    
         
            -
                  end
         
     | 
| 
       436 
     | 
    
         
            -
                end
         
     | 
| 
       437 
     | 
    
         
            -
             
     | 
| 
       438 
     | 
    
         
            -
                context "when a label include HTML-like tags with heredoc" do
         
     | 
| 
       439 
     | 
    
         
            -
                  before { gv.node(:a, label:<<-HTML) }
         
     | 
| 
       440 
     | 
    
         
            -
                  <TABLE>
         
     | 
| 
       441 
     | 
    
         
            -
                    <TR>
         
     | 
| 
       442 
     | 
    
         
            -
                      <TD><IMG SRC="logo2.gif" /></TD>
         
     | 
| 
       443 
     | 
    
         
            -
                    </TR>
         
     | 
| 
       444 
     | 
    
         
            -
                  </TABLE>
         
     | 
| 
       445 
     | 
    
         
            -
                  HTML
         
     | 
| 
       446 
     | 
    
         
            -
                  subject { gv.to_s }
         
     | 
| 
       447 
     | 
    
         
            -
                  it do
         
     | 
| 
       448 
     | 
    
         
            -
                    should eql ~<<-EOS
         
     | 
| 
       449 
     | 
    
         
            -
                      digraph G {
         
     | 
| 
       450 
     | 
    
         
            -
                        a[label=<<TABLE><TR><TD><IMG SRC="logo2.gif" /></TD></TR></TABLE>>];
         
     | 
| 
       451 
     | 
    
         
            -
                      }
         
     | 
| 
       452 
     | 
    
         
            -
                      EOS
         
     | 
| 
       453 
     | 
    
         
            -
                  end
         
     | 
| 
       454 
     | 
    
         
            -
                end
         
     | 
| 
       455 
     | 
    
         
            -
             
     | 
| 
       456 
442 
     | 
    
         
             
                context "take ports on edges" do
         
     | 
| 
       457 
443 
     | 
    
         
             
                  before do
         
     | 
| 
       458 
444 
     | 
    
         
             
                    gv.route(:a => [:b, :c])
         
     |