ku1ik / rainbow

Ruby gem for colorizing printed text on ANSI terminals
MIT License
813 stars 68 forks source link

Calling .color is changing variables #9

Closed fcoury closed 12 years ago

fcoury commented 12 years ago

Rainbow 1.1.2 behavior (wrong! - the variable is changed):

$ gem install rainbow
Fetching: rainbow-1.1.2.gem (100%)
Successfully installed rainbow-1.1.2
1 gem installed

$ irb
ree-1.8.7-2011.03 :001 > require 'rainbow' 
 => true 
ree-1.8.7-2011.03 :002 > @string = "color-me-blind"
 => "color-me-blind" 
ree-1.8.7-2011.03 :003 > @string.color(:yellow)
 => "\e[33mcolor-me-blind\e[0m" 
ree-1.8.7-2011.03 :004 > @string
 => "\e[33mcolor-me-blind\e[0m"

Rainbow 1.1.1 behavior (correct - @string is not touched):

$ gem list rainbow

*** LOCAL GEMS ***

rainbow (1.1.1)

$ irb
ree-1.8.7-2011.03 :003 > require 'rainbow'
 => true 
ree-1.8.7-2011.03 :004 > @string = "color-me-blind"
 => "color-me-blind" 
ree-1.8.7-2011.03 :005 > @string.color(:yellow)
 => "\e[33mcolor-me-blind\e[0m" 
ree-1.8.7-2011.03 :006 > @string
 => "color-me-blind"
ku1ik commented 12 years ago

Right, it seems like we have a regression. I'll add a test and fix that.

fcoury commented 12 years ago

Thanks for looking into this :)