Is it possible using Thor actions to delete a line(s) of text from a file. For example I would like to delete ruby comments.
So far I have found 2 actions: comment_lines - which comments out lines, and gsub_file
Thanks
Does this not work to remove comments?
gsub_file(filename, /#.*$/, '')
Edit:
If you want to remove comments and delete lines with only comment information, you could try:
gsub_file(filename, /\S*#.*$/, '') # removes partial comments
gsub_file(filename, /^\s*#.*\n/, '') # removes full line comments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With