instance method remove_line_from_file

Ruby on Rails 1.2.3

Since v1.0.3 Last seen in v2.2.3 Private

Available in: v1.0.3 v1.1.6 v1.2.3 v2.0.3 v2.1.0 v2.2.3

Signature

remove_line_from_file(path, pattern)

No documentation comment.

Parameters

path req
pattern req
Source
# File lib/importmap/commands.rb, line 120
    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 120 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Importmap::Commands

Type at least 2 characters to search.

↑↓ navigate · open · esc close