lib/line_containing.rb in line_containing-0.1.1 vs lib/line_containing.rb in line_containing-0.1.2

- old
+ new

@@ -3,11 +3,11 @@ # module LineContaining def self.add_before(str_orig, str_add, path) path_old = path path_new = "#{path_old}.new" - file_w = open(path_new, 'w') + file_w = File.open(path_new, 'w') File.readlines(path_old).each do |line| file_w.write("#{str_add}\n") if line.include? str_orig file_w.write(line) end file_w.close @@ -16,11 +16,11 @@ end def self.add_after(str_orig, str_add, path) path_old = path path_new = "#{path_old}.new" - file_w = open(path_new, 'w') + file_w = File.open(path_new, 'w') File.readlines(path_old).each do |line| file_w.write(line) if line.include? str_orig file_w.write("\n") if line[-1] != "\n" file_w.write("#{str_add}\n") @@ -32,11 +32,11 @@ end def self.replace(str_orig, str_new, path) path_old = path path_new = "#{path_old}.new" - file_w = open(path_new, 'w') + file_w = File.open(path_new, 'w') File.readlines(path_old).each do |line| if line.include? str_orig file_w.write("#{str_new}\n") else file_w.write(line) @@ -48,11 +48,11 @@ end def self.delete(str_orig, path) path_old = path path_new = "#{path_old}.new" - file_w = open(path_new, 'w') + file_w = File.open(path_new, 'w') File.readlines(path_old).each do |line| if line.include? str_orig # Print NOTHING else file_w.write(line) @@ -64,10 +64,10 @@ end def self.delete_between(str1, str2, path) path_old = path path_new = "#{path_old}.new" - file_w = open(path_new, 'w') + file_w = File.open(path_new, 'w') to_delete = false File.readlines(path_old).each do |line| if line.include? str1 file_w.write(line) to_delete = true