Sha256: 9f1a5ae5d2862c0ae3e97012e18724186ba63d82e27614b46d263ff4f9a55d59

Contents?: true

Size: 468 Bytes

Versions: 17

Compression:

Stored size: 468 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

17 entries across 17 versions & 1 rubygems

Version Path
dev_commands-0.0.55 lib/text.rb
dev_commands-0.0.49 lib/text.rb
dev_commands-0.0.48 lib/text.rb
dev_commands-0.0.47 lib/text.rb
dev_commands-0.0.46 lib/text.rb
dev_commands-0.0.45 lib/text.rb
dev_commands-0.0.44 lib/text.rb
dev_commands-0.0.43 lib/text.rb
dev_commands-0.0.42 lib/text.rb
dev_commands-0.0.41 lib/text.rb
dev_commands-0.0.40 lib/text.rb
dev_commands-0.0.39 lib/text.rb
dev_commands-0.0.38 lib/text.rb
dev_commands-0.0.37 lib/text.rb
dev_commands-0.0.36 lib/text.rb
dev_commands-0.0.35 lib/text.rb
dev_commands-0.0.34 lib/text.rb