lib/text.rb in dev_commands-0.0.17 vs lib/text.rb in dev_commands-0.0.18
- old
+ new
@@ -1,15 +1,15 @@
-class Text
- def self.replace_in_glob(glob,search,replace)
- Dir.glob(glob).each{ |f| replace_text_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
-
+class Text
+ def self.replace_in_glob(glob,search,replace)
+ Dir.glob(glob).each{ |f| replace_text_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
\ No newline at end of file