def atomic_write(file_name)
      temp_dir = File.join(Geminabox.data, "_temp")
      FileUtils.mkdir_p(temp_dir)
      temp_file = Tempfile.new("." + File.basename(file_name), temp_dir)
      temp_file.binmode
      yield temp_file
      temp_file.close
      File.rename(temp_file.path, file_name)
      File.chmod(Geminabox.gem_permissions, file_name)
    end
def atomic_write(file_name)
      temp_dir = File.join(Geminabox.data, "_temp")
      FileUtils.mkdir_p(temp_dir)
      temp_file = Tempfile.new("." + File.basename(file_name), temp_dir)
      temp_file.binmode
      yield temp_file
      temp_file.close
      File.rename(temp_file.path, file_name)
      File.chmod(Geminabox.gem_permissions, file_name)
    end
based on http://as.rubyonrails.org/classes/File.html