Module: EPM::FileHelpers
Instance Method Summary collapse
Instance Method Details
#file_guard(file) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/epm/utils.rb', line 148 def file_guard file contents = File.read file dir = File.dirname(File.absolute_path(file)) unless dir == '/tmp' include_pattern = /(\(include \")(\..*)(\"\))/ if contents[include_pattern] included = File.join(dir, $2) included = $1 + included + $3 contents.gsub!(include_pattern, included) end save_temp_file contents, file else return file end end |
#save_temp_file(contents, file) ⇒ Object
164 165 166 167 168 |
# File 'lib/epm/utils.rb', line 164 def save_temp_file contents, file tmp = Tempfile.new ['epm', File.extname(file)] File.open(tmp, 'w'){|f| f.write contents} return tmp.path end |