instance method
append_file_with_newline
Ruby on Rails 8.0.4
Since v6.1.7.10 PrivateSignature
append_file_with_newline(path, str, options = {})
Append string to a file with a newline if necessary
Parameters
-
pathreq -
strreq -
optionsopt = {}
Source
# File railties/lib/rails/generators/actions.rb, line 511
def append_file_with_newline(path, str, options = {})
gsub_file path, /\n?\z/, options do |match|
match.end_with?("\n") ? "" : "\n#{str}\n"
end
end
Defined in railties/lib/rails/generators/actions.rb line 511
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Generators::Actions