ruby-graphviz 1.0.9 → 1.1.0

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: 09cf41331aaf2b0baafb4602ffc9fd380f8b3fe9
4
- data.tar.gz: bb8ecb3ec2d96996b88828571fab1b5524f722ca
3
+ metadata.gz: b41b2ddc156dd0ea02af2fdc5914e9494e61a4e0
4
+ data.tar.gz: a10df946f3a81fb23d44dafe6b3d89c46dc64cad
5
5
  SHA512:
6
- metadata.gz: bb891ab78f980673972eedbd897d507b5fef69e9bf168765f6fd576025d25f504e2844a9af294166ecf2a89b9c2478307cbdee86f3dd90206e70012306b0ee56
7
- data.tar.gz: 3b509fdc45e4332048a718a7bac659b376fa2eeecee2d716d12a252ed507e053e107a190b9184d01c021ef582c679acacfeb6ad3e8c5de755b387a9e5543aa43
6
+ metadata.gz: 343df04cb63e2694e04ae3c6cb1343207aa13f6e4b7abdbd6f394613045bb04aa508050903179c757eeec9699dd3034dddfe0305a0e2d2ee0244454586593b2e
7
+ data.tar.gz: 3f9eb3928166fc170e924a6c302d2baf1c685930431700f3bf792fd1d51712c5ba85f8f7f33fa13a533a77629279f4fea270ee9dda6318f81f4d83a18a243a8b
@@ -1,6 +1,7 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
4
6
  - jruby
5
- - rbx-18mode
6
- - rbx-19mode
7
+ - rbx-2
@@ -19,8 +19,12 @@
19
19
  * coding64 <https://github.com/coding46>
20
20
  * Neven Has <https://github.com/nevenh>
21
21
  * Postmodern <https://github.com/postmodern>
22
- * markus1189 <https://github.com/markus1189>
23
22
  * Mike Fiedler <https://github.com/miketheman>
23
+ * Kenichi Kamiya <https://github.com/kachick>
24
+ * Gabe Kopley <https://github.com/gkop>
25
+ * markus1189 <https://github.com/markus1189>
26
+ * Praveen Arimbrathodiyil <https://github.com/pravi>
27
+ * Andrew <https://github.com/AndrewKvalheim>
24
28
 
25
29
  Thanks to :
26
30
 
@@ -1,5 +1,10 @@
1
1
  = CHANGELOG
2
2
 
3
+ == 1.1.0 :
4
+ * Issue #61 : Combine graphviz instances
5
+ * Issue #73 : Avoid constructing shell commands as strings
6
+ * Bug correction with development dependencies on JRuby
7
+
3
8
  == 1.0.9 :
4
9
  * Add support for attributs
5
10
  * forcelabels
@@ -10,6 +15,11 @@
10
15
  * Issue #52 : Extracted xDOTScript to DOTScript class (by markus1189)
11
16
  * Issue #54 : Fixes a couple of typos and spacing (by Mike Fiedler)
12
17
  * Issue #55 : Avoid autoload
18
+ * Issue #57 : Add man pages for the commandline programs (by Praveen Arimbrathodiyil)
19
+ * Issue #59 : Support label as Fixnum (by Gabe Kopley)
20
+ * Issue #62 : Remove warnings (by Kenichi Kamiya)
21
+ * Issue #63 : Fix typo (by Kenichi Kamiya)
22
+ * Issue #65 : ruby-graphviz breaks autoloading of ActiveSupport::Concerns
13
23
  * Update graphviz attributs
14
24
 
15
25
  == 1.0.8 :
@@ -1,8 +1,9 @@
1
1
  = Ruby/GraphViz
2
2
 
3
3
  {<img src="https://secure.travis-ci.org/glejeune/Ruby-Graphviz.png" />}[http://travis-ci.org/glejeune/Ruby-Graphviz]
4
+ {<img src="https://badge.fury.io/rb/ruby-graphviz.png" alt="Gem Version" />}[http://badge.fury.io/rb/ruby-graphviz]
4
5
 
5
- Copyright (C) 2004-2012 Gregoire Lejeune
6
+ Copyright (C) 2004-2013 Gregoire Lejeune
6
7
 
7
8
  * Doc : http://rdoc.info/projects/glejeune/Ruby-Graphviz
8
9
  * Sources : http://github.com/glejeune/Ruby-Graphviz
data/Rakefile CHANGED
@@ -13,9 +13,9 @@ include FileUtils
13
13
 
14
14
  CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log']
15
15
  RDOC_OPTS = ['--quiet', '--title', "Ruby/GraphViz, the Documentation",
16
- "--opname", "index.html",
17
- "--line-numbers",
18
- "--main", "README.rdoc"]
16
+ "--opname", "index.html",
17
+ "--line-numbers",
18
+ "--main", "README.rdoc"]
19
19
 
20
20
  desc "Packages up Ruby/GraphViz."
21
21
  task :default => [:test, :package]
@@ -24,38 +24,46 @@ task :package => [:clean]
24
24
  task :doc => :rdoc
25
25
 
26
26
  RDoc::Task.new do |rdoc|
27
- rdoc.rdoc_dir = 'doc/rdoc'
28
- rdoc.options += RDOC_OPTS
29
- rdoc.main = "README.rdoc"
30
- rdoc.title = "Ruby/GraphViz, the Documentation"
31
- rdoc.rdoc_files.add ['README.rdoc', 'CHANGELOG.rdoc', 'AUTHORS.rdoc', 'COPYING.rdoc',
32
- 'lib/graphviz.rb',
33
- 'lib/graphviz/node.rb',
34
- 'lib/graphviz/edge.rb',
35
- 'lib/graphviz/constants.rb',
36
- 'lib/graphviz/xml.rb',
37
- 'lib/graphviz/graphml.rb',
38
- 'lib/graphviz/family_tree.rb',
39
- 'lib/graphviz/family_tree/couple.rb',
40
- 'lib/graphviz/family_tree/generation.rb',
41
- 'lib/graphviz/family_tree/person.rb',
42
- 'lib/graphviz/family_tree/sibling.rb']
27
+ rdoc.rdoc_dir = 'doc/rdoc'
28
+ rdoc.options += RDOC_OPTS
29
+ rdoc.main = "README.rdoc"
30
+ rdoc.title = "Ruby/GraphViz, the Documentation"
31
+ rdoc.rdoc_files.add ['README.rdoc', 'CHANGELOG.rdoc', 'AUTHORS.rdoc', 'COPYING.rdoc',
32
+ 'lib/graphviz.rb',
33
+ 'lib/graphviz/node.rb',
34
+ 'lib/graphviz/edge.rb',
35
+ 'lib/graphviz/constants.rb',
36
+ 'lib/graphviz/xml.rb',
37
+ 'lib/graphviz/graphml.rb',
38
+ 'lib/graphviz/family_tree.rb',
39
+ 'lib/graphviz/family_tree/couple.rb',
40
+ 'lib/graphviz/family_tree/generation.rb',
41
+ 'lib/graphviz/family_tree/person.rb',
42
+ 'lib/graphviz/family_tree/sibling.rb']
43
43
  end
44
44
 
45
45
  Rake::TestTask.new(:test) do |t|
46
+ t.libs << 'lib' << 'test'
47
+ t.verbose = true
48
+
46
49
  require 'graphviz/utils'
47
50
  include GraphViz::Utils
48
- test_files = FileList['test/test_*.rb'].exclude('test/test_dot_script.rb')
49
- test_files.unshift('test/test_dot_script.rb')
51
+ test_files = FileList['test/test_*.rb']
50
52
  test_files.exclude("test/test_examples.rb") unless find_executable("dot", nil)
53
+
54
+ p test_files
51
55
  t.test_files = test_files
52
56
  end
53
57
 
54
58
  desc "Generate man pages"
55
59
  task :man do
56
- require 'ronn'
57
- chdir 'man' do
58
- sh "ronn -r *.ronn"
60
+ unless RUBY_PLATFORM == 'java'
61
+ require 'ronn'
62
+ chdir 'man' do
63
+ sh "ronn -r *.ronn"
64
+ end
65
+ else
66
+ puts "Can't generate man pages with JRuby"
59
67
  end
60
68
  end
61
69
 
@@ -0,0 +1,9 @@
1
+ $:.unshift( "../lib" )
2
+ require 'graphviz'
3
+
4
+ puts GraphViz.graph( :G ) { |g|
5
+ g[:label] = "<<b>This</b> is <i>a</i> <b>test</b>>"
6
+ n1 = g.add_nodes( "N1", :label => '<<b>node 1</b>>')
7
+ n2 = g.add_nodes( "N2", :label => '<<b>node 2</b>>')
8
+ g.add_edges( n1, n2, :label => '<<u>edge</u>>')
9
+ }.output( :svg => "#{$0}.svg", :none => String )
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $:.unshift( "../lib" )
4
+ require "graphviz"
5
+
6
+ g = nil
7
+ if ARGV[0]
8
+ g = GraphViz::new( "G", :path => ARGV[0] )
9
+ else
10
+ g = GraphViz::new( "G" )
11
+ end
12
+
13
+ g.add_edges("noDe", "graph")
14
+ g.add_edges("node", "graph")
15
+ g.add_edges("node", "Graph")
16
+ g.add_edges("graph", "subgraph")
17
+ g.add_edges("edge", "node")
18
+ g.add_edges("subgraph", "digraph")
19
+ g.add_edges("subgraph", "strict")
20
+
21
+ g.output( :png => "#{$0}.png" )
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $:.unshift( "../lib" )
4
+ require "graphviz"
5
+
6
+ g = nil
7
+ if ARGV[0]
8
+ g = GraphViz::new( "G", :path => ARGV[0] )
9
+ else
10
+ g = GraphViz::new( "G" )
11
+ end
12
+
13
+ g.node[:color] = "#FF0000:#FFFFFF"
14
+ g.add_edges("noDe", "graph")
15
+ g.add_edges("node", "graph")
16
+ g.add_edges("node", "Graph")
17
+ g.add_edges("graph", "subgraph")
18
+ g.add_edges("edge", "node")
19
+ g.add_edges("subgraph", "digraph")
20
+ g.add_edges("subgraph", "strict")
21
+
22
+ g.output( :png => "#{$0}.png" )
@@ -25,6 +25,8 @@ BEGIN {
25
25
  string attr; string attrv;
26
26
  graph_t subgraph; graph_t pgraph;
27
27
  graph_t ofgraph;
28
+ graph_t sub_graph;
29
+ graph_t tmp_g;
28
30
 
29
31
  string xOut;
30
32
  if( ARGC == 0 ) {
@@ -49,6 +51,55 @@ BEGIN {
49
51
  sout = gsub(sout, "$", "\\$");
50
52
  return( sout );
51
53
  }
54
+
55
+ void load_sub_graph( graph_t p ) {
56
+ if(p == NULL) {
57
+ return;
58
+ }
59
+ sub_graph = fstsubg(p);
60
+ while( sub_graph != NULL ) {
61
+ pgraph = sub_graph.parent;
62
+ printf ( " graph_%s = graph_%s.add_graph( \"%s\" )\n", rubyfy(sub_graph.name), rubyfy(pgraph.name), rubyfy(sub_graph.name) );
63
+
64
+ // ATTRS
65
+ attr = fstAttr(sub_graph, "G");
66
+ while( attr != "" ) {
67
+ attrv = aget( sub_graph, attr );
68
+ if( attrv != "" ) {
69
+ printf( " graph_%s[:%s] = '%s'\n", rubyfy(sub_graph.name), attr, attrv );
70
+ }
71
+ attr = nxtAttr( sub_graph, "G", attr );
72
+ }
73
+ tmp_g = sub_graph;
74
+ load_sub_graph(sub_graph);
75
+ sub_graph = nxtsubg( tmp_g );
76
+
77
+ }
78
+ }
79
+
80
+ graph_t get_node_graph(node_t n, graph_t p) {
81
+ sub_graph = fstsubg(p);
82
+ while( sub_graph != NULL ) {
83
+ if( isSubnode( sub_graph, n) != 0 ) {
84
+ return get_node_graph(n, sub_graph);
85
+ }
86
+ sub_graph = nxtsubg( sub_graph );
87
+ }
88
+ return p;
89
+ }
90
+
91
+ graph_t get_edge_graph(edge_t e, graph_t p) {
92
+ sub_graph = fstsubg(p);
93
+ while( sub_graph != NULL ) {
94
+ if( isSubedge( sub_graph, e) != 0 ) {
95
+ return get_edge_graph(e, sub_graph);
96
+ }
97
+ sub_graph = nxtsubg( sub_graph );
98
+ }
99
+ return p;
100
+ }
101
+
102
+
52
103
  }
53
104
 
54
105
  BEG_G {
@@ -77,83 +128,50 @@ BEG_G {
77
128
  attr = nxtAttr( $, "G", attr );
78
129
  }
79
130
 
80
- // Subgraph
81
- subgraph = fstsubg( $ );
82
- while( subgraph != NULL ) {
83
- pgraph = subgraph.parent;
84
- printf ( " graph_%s = graph_%s.add_graph( \"%s\" )\n", rubyfy(subgraph.name), rubyfy(pgraph.name), rubyfy(subgraph.name) );
85
-
86
- // ATTRS
87
- attr = fstAttr(subgraph, "G");
88
- while( attr != "" ) {
89
- attrv = aget( subgraph, attr );
90
- if( attrv != "" ) {
91
- printf( " graph_%s[:%s] = '%s'\n", rubyfy(subgraph.name), attr, attrv );
92
- }
93
- attr = nxtAttr( subgraph, "G", attr );
94
- }
95
-
96
- subgraph = nxtsubg( subgraph );
97
- }
131
+ load_sub_graph($);
98
132
  }
99
133
 
100
134
  N {
101
135
  pgraph = $.root;
102
- ofgraph = pgraph;
103
-
104
- subgraph = fstsubg( pgraph );
105
- while( subgraph != NULL ) {
106
- if( isSubnode( subgraph, $ ) != 0 ) {
107
- ofgraph = subgraph;
108
- }
109
- subgraph = nxtsubg( subgraph );
110
- }
136
+ ofgraph = get_node_graph($, pgraph);
111
137
 
112
138
  printf( " node_%s = graph_%s.add_nodes( \"%s\"", rubyfy($.name), rubyfy(ofgraph.name), stringify($.name) );
113
139
 
114
140
  // Attributs of N
115
- attr = fstAttr($G, "N");
116
- while( attr != "" ) {
117
- attrv = aget( $, attr );
118
- if( attrv != "" ) {
119
- printf( ", :%s => '%s'", attr, gsub( attrv, "'", "\\'" ) );
120
- } else {
121
- printf( ", :%s => ''", attr );
141
+ attr = fstAttr($G, "N");
142
+ while( attr != "" ) {
143
+ attrv = aget( $, attr );
144
+ if( attrv != "" ) {
145
+ printf( ", :%s => '%s'", attr, gsub( attrv, "'", "\\'" ) );
146
+ } else {
147
+ printf( ", :%s => ''", attr );
148
+ }
149
+ attr = nxtAttr( $G, "N", attr );
122
150
  }
123
- attr = nxtAttr( $G, "N", attr );
151
+
152
+ printf( " )\n");
124
153
  }
125
-
126
- printf( " )\n");
127
- }
128
154
 
129
155
  E {
130
- pgraph = $.root;
131
- ofgraph = pgraph;
132
-
133
- subgraph = fstsubg( pgraph );
134
- while( subgraph != NULL ) {
135
- if( isSubedge( subgraph, $ ) != 0 ) {
136
- ofgraph = subgraph;
137
- }
138
- subgraph = nxtsubg( subgraph );
139
- }
156
+ pgraph = $.root;
157
+ ofgraph = get_edge_graph($, $.root);
140
158
 
141
159
  printf( " graph_%s.add_edges( \"%s\", \"%s\"", rubyfy(ofgraph.name), stringify($.tail.name), stringify($.head.name) );
142
-
143
- // Attributs of E
144
- attr = fstAttr($G, "E");
145
- while( attr != "" ) {
146
- attrv = aget( $, attr );
147
- if( attrv != "" ) {
148
- printf( ", :%s => '%s'", attr, gsub( attrv, "'", "\\'" ) );
149
- } else {
150
- printf( ", :%s => ''", attr );
160
+
161
+ // Attributs of E
162
+ attr = fstAttr($G, "E");
163
+ while( attr != "" ) {
164
+ attrv = aget( $, attr );
165
+ if( attrv != "" ) {
166
+ printf( ", :%s => '%s'", attr, gsub( attrv, "'", "\\'" ) );
167
+ } else {
168
+ printf( ", :%s => ''", attr );
169
+ }
170
+ attr = nxtAttr( $G, "E", attr );
151
171
  }
152
- attr = nxtAttr( $G, "E", attr );
172
+
173
+ printf( " )\n" );
153
174
  }
154
-
155
- printf( " )\n" );
156
- }
157
175
 
158
176
  END_G {
159
177
  printf( "}\n" );
@@ -161,7 +179,7 @@ END_G {
161
179
  if( xOut == "-" ) {
162
180
  printf( "@_graph_eval = graph_%s\n", rubyfy($.name) );
163
181
  } else {
164
- printf( "graph_%s.output( :%s => \"%s.%s\" )\n", rubyfy($.name), xOut, gsub($F, ".*/", ""), xOut );
182
+ printf( "graph_%s.output( :%s => \"%s.%s\" )\n", rubyfy($.name), xOut, gsub($F, ".*/", ""), xOut );
165
183
  }
166
184
  }
167
185
  }
@@ -82,6 +82,7 @@ class GraphViz
82
82
  attr_accessor :edge
83
83
  alias_method :edge_attrs, :edge
84
84
 
85
+
85
86
  @elements_order = nil
86
87
 
87
88
  def add_node( xNodeName, hOpts = {} )
@@ -390,7 +391,12 @@ class GraphViz
390
391
  self[key] = value
391
392
  end
392
393
  else
393
- return( @graph[xAttrName].clone )
394
+ attr = @graph[xAttrName]
395
+ if attr.nil?
396
+ return nil
397
+ else
398
+ return( @graph[xAttrName].clone )
399
+ end
394
400
  end
395
401
  end
396
402
 
@@ -408,6 +414,13 @@ class GraphViz
408
414
  each_attribute(&b)
409
415
  end
410
416
 
417
+ # Create a new graph from the current subgraph
418
+ def to_graph
419
+ graph = self.clone
420
+ graph.pg = nil
421
+ return graph
422
+ end
423
+
411
424
  #
412
425
  # Generate the graph
413
426
  #
@@ -531,61 +544,59 @@ class GraphViz
531
544
  raise StandardError, "GraphViz not installed or #{@prog} not in PATH. Install GraphViz or use the 'path' option"
532
545
  end
533
546
 
534
- cmd = escape_path_containing_blanks(cmd) if IS_JRUBY
535
-
536
- xOutputWithFile = ""
537
- xOutputWithoutFile = ""
547
+ xOutputWithFile = []
548
+ xOutputWithoutFile = []
538
549
  unless @format.nil? or @format == "none"
539
550
  lNotHugly << @filename if @format.to_s == "svg" and @nothugly
540
551
  if @filename.nil? or @filename == String
541
- xOutputWithoutFile = "-T#{@format} "
552
+ xOutputWithoutFile = ["-T#{@format}"]
542
553
  else
543
- xOutputWithFile = "-T#{@format} -o#{@filename} "
554
+ xOutputWithFile = ["-T#{@format}", "-o#{@filename}"]
544
555
  end
545
556
  end
546
557
  @output.each_except( :key => ["none"] ) do |format, file|
547
558
  lNotHugly << file if format.to_s == "svg" and @nothugly
548
559
  if file.nil? or file == String
549
- xOutputWithoutFile << "-T#{format} "
560
+ xOutputWithoutFile += ["-T#{format}"]
550
561
  else
551
- xOutputWithFile << "-T#{format} -o#{file} "
562
+ xOutputWithFile += ["-T#{format}", "-o#{file}"]
552
563
  end
553
564
  end
554
565
 
555
- xExternalLibraries = ""
556
- @extlibs.each do |lib|
557
- xExternalLibraries << "-l#{lib} "
558
- end
559
-
560
- xOtherOptions = ""
561
- xOtherOptions += " -s#{@scale}" unless @scale.nil?
562
- xOtherOptions += " -y" if @inverty
563
- unless @no_layout.nil?
564
- xOtherOptions += " -n"
565
- xOtherOptions += "2" if @no_layout.to_i == 2
566
- end
567
- xOtherOptions += " -x" if @reduce_graph
568
- xOtherOptions += " -Lg" if @Lg
569
- xOtherOptions += " -LO" if @LO
570
- xOtherOptions += " -Ln#{@Ln}" unless @Ln.nil?
571
- xOtherOptions += " -LU#{@LU}" unless @LU.nil?
572
- xOtherOptions += " -LC#{@LC}" unless @LC.nil?
573
- xOtherOptions += " -LT#{@LT}" unless @LT.nil?
574
-
575
- if IS_JRUBY
576
- xCmd = "#{cmd} -q#{@errors} #{xExternalLibraries} #{xOtherOptions} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
566
+ xExternalLibraries = @extlibs.map { |lib| "-l#{lib}" }
567
+
568
+ xOtherOptions = []
569
+ xOtherOptions << "-s#{@scale}" if @scale
570
+ xOtherOptions << "-y" if @inverty
571
+ xOtherOptions << "-n#{@no_layout}" if @no_layout
572
+ xOtherOptions << "-x" if @reduce_graph
573
+ xOtherOptions << "-Lg" if @Lg
574
+ xOtherOptions << "-LO" if @LO
575
+ xOtherOptions << "-Ln#{@Ln}" if @Ln
576
+ xOtherOptions << "-LU#{@LU}" if @LU
577
+ xOtherOptions << "-LC#{@LC}" if @LC
578
+ xOtherOptions << "-LT#{@LT}" if @LT
579
+
580
+ tmpPath = if IS_JRUBY
581
+ t.path
577
582
  elsif IS_CYGWIN
578
- tmpPath = t.path
579
583
  begin
580
- tmpPath = "'" + `cygpath -w #{t.path}`.chomp + "'"
584
+ IO.popen("cygpath", "-w", t.path).chomp
581
585
  rescue
582
586
  warn "cygpath is not installed!"
587
+ t.path
583
588
  end
584
- xCmd = "\"#{cmd}\" -q#{@errors} #{xExternalLibraries} #{xOtherOptions} #{xOutputWithFile} #{xOutputWithoutFile} #{tmpPath}"
585
589
  else
586
- xCmd = "\"#{cmd}\" -q#{@errors} #{xExternalLibraries} #{xOtherOptions} #{xOutputWithFile} #{xOutputWithoutFile} #{t.path}"
590
+ t.path
587
591
  end
588
592
 
593
+ xCmd = [cmd, "-q#{@errors}"] +
594
+ xExternalLibraries +
595
+ xOtherOptions +
596
+ xOutputWithFile +
597
+ xOutputWithoutFile +
598
+ [tmpPath]
599
+
589
600
  xOutput << output_from_command( xCmd )
590
601
  end
591
602
 
@@ -613,9 +624,7 @@ class GraphViz
613
624
  @elements_order.each { |kElement|
614
625
  is_new_type = script_data.type != kElement["type"]
615
626
  if is_new_type
616
- unless script_data.type.nil? or script_data.empty?
617
- script << script_data
618
- end
627
+ script << script_data unless script_data.type.nil? or script_data.empty?
619
628
  script_data = DOTScriptData.new(kElement["type"])
620
629
  end
621
630
 
@@ -634,6 +643,7 @@ class GraphViz
634
643
  "Don't know what to do with element type '#{kElement['type']}'"
635
644
  end
636
645
  }
646
+ script << script_data unless script_data.type.nil? or script_data.empty?
637
647
  end
638
648
 
639
649
  def to_s
@@ -773,7 +783,7 @@ class GraphViz
773
783
  end
774
784
 
775
785
  def has_parent_graph?
776
- @oParentGraph
786
+ not @oParentGraph.nil?
777
787
  end
778
788
  ## ----------------------------------------------------------------------------
779
789
 
@@ -947,7 +957,8 @@ class GraphViz
947
957
  :unquote_empty => false,
948
958
  }.merge(opts)
949
959
 
950
- if (options[:force] or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z/ ).nil?)
960
+ reserved_words = %w{node edge graph digraph subgraph strict}
961
+ if (options[:force] or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z/ ).nil? or reserved_words.include?(str.downcase))
951
962
  unless options[:unquote_empty] and str.size == 0
952
963
  '"' + str.gsub('"', '\\"').gsub("\n", '\\\\n') + '"'
953
964
  end