Class: Vpsb::Helpers::FileReplace
- Inherits:
-
Object
- Object
- Vpsb::Helpers::FileReplace
- Defined in:
- lib/vpsb/helpers/file_replace.rb
Class Method Summary collapse
Class Method Details
.replace_json(path, hash) ⇒ Object
7 8 9 |
# File 'lib/vpsb/helpers/file_replace.rb', line 7 def self.replace_json(path, hash) replace_text(path, hash.to_json) end |
.replace_text(path, text) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/vpsb/helpers/file_replace.rb', line 11 def self.replace_text(path, text) file_path = File.join(Dir.pwd, path) FileUtils.rm(file_path) if File.exist?(file_path) File.open(file_path,"w") do |f| f.write(text) end end |