instance method
remove_line_from_file
Ruby on Rails 2.1.0
Since v1.0.3 Last seen in v2.2.3 PrivateSignature
remove_line_from_file(path, pattern)
No documentation comment.
Parameters
-
pathreq -
patternreq
Source
# File lib/importmap/commands.rb, line 133
def remove_line_from_file(path, pattern)
path = File.expand_path(path, destination_root)
all_lines = File.readlines(path)
with_lines_removed = all_lines.select { |line| line !~ pattern }
File.open(path, "w") do |file|
with_lines_removed.each { |line| file.write(line) }
end
end
Defined in lib/importmap/commands.rb line 133
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Importmap::Commands