Module: EPM::FileHelpers
Instance Method Summary collapse
Instance Method Details
#file_guard(file) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/epm/utils.rb', line 155 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
171 172 173 174 175 |
# File 'lib/epm/utils.rb', line 171 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 |