module Soaspec module FileHelpers require 'fileutils' def self.create_file(options) filename = options[:filename] raise 'Need to pass filename' unless filename content = options[:content] raise 'Need to pass contents to insert into file' unless content if File.exist? filename old_content = File.read(filename) if old_content != content && !options[:ignore_if_present] warn "!! #{filename} already exists and differs from template" end else File.open(filename, 'w') do |f| f.puts content end puts 'Created: ' + filename end end def self.create_folder(folder) if File.exists? folder unless File.directory? folder $stderr.puts "!! #{folder} already exists and is not a directory" end else FileUtils.mkdir folder puts "Created folder: #{folder}/" end end end end