Sha256: a60129bc163325390b5aa903d8d5e7efe12ee950b8057289e0f22e3e435484a7

Contents?: true

Size: 482 Bytes

Versions: 13

Compression:

Stored size: 482 Bytes

Contents

class Text
  def self.replace_in_glob(glob,search,replace)
     Dir.glob(glob).each{ |f| replace_in_file(f,search,replace) }
   end
   
   def self.replace_in_file(filename,search,replace)
     text1 = IO.read(filename).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
     #File.read(f,:encoding=>'UTF-8')
     text2 = text1.gsub(search) { |str| str=replace }
     unless text1==text2
       File.open(filename,"w") { |f| f.puts text2 }
     end
   end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dev_commands-0.0.54 lib/text.rb
dev_commands-0.0.53 lib/text.rb
dev_commands-0.0.52 lib/text.rb
dev_commands-0.0.51 lib/text.rb
dev_commands-0.0.50 lib/text.rb
dev_commands-0.0.33 lib/text.rb
dev_commands-0.0.32 lib/text.rb
dev_commands-0.0.31 lib/text.rb
dev_commands-0.0.30 lib/text.rb
dev_commands-0.0.29 lib/text.rb
dev_commands-0.0.28 lib/text.rb
dev_commands-0.0.27 lib/text.rb
dev_commands-0.0.26 lib/text.rb