gviz 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86acea43cf9f96125e9e319effb7e0b5cfd83dbe
4
- data.tar.gz: 0d9ce484c6e2a4d5078f586a5e8de88fb48786ae
3
+ metadata.gz: 111365e7127ce64d1645957d112c7ea204dd6aed
4
+ data.tar.gz: 5784cd73f99d927fa79378d020e176f742717546
5
5
  SHA512:
6
- metadata.gz: aa0642cb0fbb8fb0ff3ff1ad80c1b5ff52dc887630382d2e8eca790431ea0cdb82118f0539464f32bb332f7c18bb1262c86c769143e521fe714bc0f87e536b34
7
- data.tar.gz: f50bf997cd60c46469ef0465a7999b3eef0afac3aa0b2ede4514c24627fd93558d1c1d895426ef3a5af248970f38d6c571b0aa54fda0d6ec263bf668b3795897
6
+ metadata.gz: a239468f16cbbb6583724c8752da66b29227551b51727607ad69dfef87137e22f0ad0ce9c5f02dc53e66a66e2df7d03c606d2ea4841f1157cdafc1a03b1fe7d1
7
+ data.tar.gz: 1daf776b599733172e81f856eec100039d0a2083a2f8731547cae76a21e2695489cc39f794b0a598affc9e9b02caf3fe8ed7cc5110edce30dddfefd3956279a7
@@ -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")
@@ -1,3 +1,3 @@
1
1
  class Gviz
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -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])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kyoendo