class Verto::DSL::File
Public Class Methods
new(filename, path: Verto.config.project.path)
click to toggle source
# File lib/verto/dsl/file.rb, line 6 def initialize(filename, path: Verto.config.project.path) @filename = filename @path = Pathname.new(path) end
Public Instance Methods
append(content)
click to toggle source
# File lib/verto/dsl/file.rb, line 27 def append(content) file.open('a') do |f| f << content end end
prepend(content)
click to toggle source
# File lib/verto/dsl/file.rb, line 33 def prepend(content) file_content = file.read file.open('w') do |f| f << (content + file_content) end end
replace(to_match, to_replace)
click to toggle source
# File lib/verto/dsl/file.rb, line 11 def replace(to_match, to_replace) content = file.read file.open('w') do |f| f << content.sub(to_match, to_replace) end end
Also aliased as: sub
replace_all(to_match, to_replace)
click to toggle source
# File lib/verto/dsl/file.rb, line 19 def replace_all(to_match, to_replace) content = file.read file.open('w') do |f| f << content.gsub(to_match, to_replace) end end
Also aliased as: gsub
Private Instance Methods
file()
click to toggle source
# File lib/verto/dsl/file.rb, line 46 def file @path.join(@filename) end