Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force mutable Strings to address upcoming Ruby default frozen strings #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/sample44.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"rvee",
"rveervee"
].each { |s|
p = "p_" << s
p = String.new("p_") << s
g.add_nodes( p, "shape" => "point" )
g.add_nodes( s )
g.add_edges( p, s, "arrowhead" => s )
Expand Down
2 changes: 1 addition & 1 deletion lib/graphviz.rb
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def output( hOpts = {} )
xOutputString = (@filename == String ||
@output.any? {|format, file| file == String })

xOutput = ""
xOutput = String.new
if @format.to_s == "none" or @output.any? {|fmt, fn| fmt.to_s == "none"}
if xOutputString
xOutput << xDOTScript
Expand Down
2 changes: 1 addition & 1 deletion lib/graphviz/core_ext.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class String
def self.random(size)
s = ""
s = String.new
d = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
size.times {
s << d[rand(d.size)]
Expand Down
2 changes: 1 addition & 1 deletion lib/graphviz/dot_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class DOTScript
def_delegators :@script, :end_with?

def initialize
@script = ''
@script = String.new
end

def append(line)
Expand Down
4 changes: 2 additions & 2 deletions lib/graphviz/edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ def output( oGraphType ) #:nodoc:
# reserved words, they aren't accepted in dot as node name
reserved_names = ["node", "edge","graph", "digraph", "subgraph", "strict"]

xOut = reserved_names.include?(self.node_one) ? "" << "_" + self.node_one : "" << self.node_one
xOut = reserved_names.include?(self.node_one) ? String.new << "_" + self.node_one : String.new << self.node_one
xOut = xOut << xLink
xOut = reserved_names.include?(self.node_two) ? xOut << "_" + self.node_two : xOut << self.node_two
xAttr = ""
xAttr = String.new
xSeparator = ""
@edge_attributes.data.each do |k, v|
xAttr << xSeparator + k + " = " + v.to_gv
Expand Down
4 changes: 2 additions & 2 deletions lib/graphviz/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def output #:nodoc:
# add a check to see if the node names are valid
# if they aren't is added an _ before
# and the print staies the same, because of the label
xOut = reserved_names.include?(node_id) ? "" << "_" + node_id : "" << node_id
xAttr = ""
xOut = reserved_names.include?(node_id) ? String.new << "_" + node_id : String.new << node_id
xAttr = String.new
xSeparator = ""

if @node_attributes.data.has_key?("label") and @node_attributes.data.has_key?("html")
Expand Down
4 changes: 2 additions & 2 deletions lib/graphviz/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def output( *options )
# * :attrs : show XML attributes (default true)
#
def initialize( xml_file, *options )
@node_name = "00000"
@node_name = String.new("00000")
@show_text = true
@show_attributes = true

Expand Down Expand Up @@ -88,7 +88,7 @@ def parse_xml_node( xml_node ) #:nodoc:
text_node_name = local_node_name.clone
text_node_name << "111"

xText = ""
xText = String.new
xSep = ""
xml_node.texts().each do |l|
x = l.value.chomp.strip
Expand Down