Sha256: 54b9485c833690e8637252212eb46df02bdcbceb799fdbc62919a16be4533964

Contents?: true

Size: 427 Bytes

Versions: 4

Compression:

Stored size: 427 Bytes

Contents

# encoding: utf-8

require 'fileutils'

module FileHelper
  def create_file(file_path, content)
    file_path = File.expand_path(file_path)

    dir_path = File.dirname(file_path)
    FileUtils.makedirs dir_path unless File.exist?(dir_path)

    File.open(file_path, 'w') do |file|
      case content
      when String
        file.puts content
      when Array
        file.puts content.join("\n")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.20.1 spec/support/file_helper.rb
rubocop-0.20.0 spec/support/file_helper.rb
rubocop-0.19.1 spec/support/file_helper.rb
rubocop-0.19.0 spec/support/file_helper.rb