glejeune / Ruby-Graphviz

[MIRROR] Ruby interface to the GraphViz graphing tool
https://gitlab.com/glejeune/ruby-graphviz
Other
608 stars 116 forks source link

symbolize clashes with ActiveSupport symbolize #122

Open weedySeaDragon opened 7 years ago

weedySeaDragon commented 7 years ago

The symbolize_keys method in lib/core_ext.rb is also defined with exactly the same name in the ActiveSupport gem in lib/active_support/core_ext/hash/keys.rb

Both add the method to Hash

If both gems are used, this can result in warnings like this:

....rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/core_ext/hash/keys.rb:54: 
warning: method redefined; discarding old symbolize_keys
....rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ruby-graphviz-1.2.2/lib/graphviz/core_ext.rb:28: 
warning: previous definition of symbolize_keys was here

To avoid collisions, this method should only be defined if it doesn't already exist in Hash, or consider naming it something else. (preferably with a namespace or at least starting with graphviz_ so it's unlikely to collide with any other gems.

technicalpickles commented 1 year ago

I came across this for a different angle. I've been running memory_profiler on a slow spec, and ruby-graphviz came up as one of the top gems allocating memory, and it came down to the symbolize_keys implementation.