Created
March 2, 2023 14:21
-
-
Save moofkit/9a4ae6e3ad99e79bf2d43fc9e8447860 to your computer and use it in GitHub Desktop.
Delete matched line from file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
files = Dir.glob("app/jobs/**/*.rb") | |
puts "Found #{files.count} files" | |
files.each do |file| | |
content = File.read(file).split("\n") | |
content.each_with_index do |line, index| | |
if match = line.match(/Worker/) | |
puts "Found #{match[1]}Worker" | |
content.delete_at(index) | |
content.delete_at(index-1) | |
File.write(file, content.join("\n")+"\n") | |
break | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment