class CMockFileWriter

CMock Project - Automatic Mock Generation for C
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
[Released under MIT License. Please refer to license.txt for details]

Attributes

config[R]

Public Class Methods

new(config) click to toggle source
# File vendor/cmock/lib/cmock_file_writer.rb, line 10
def initialize(config)
  @config = config
end

Public Instance Methods

append_file(filename, subdir) { |file, filename| ... } click to toggle source
# File vendor/cmock/lib/cmock_file_writer.rb, line 31
def append_file(filename, subdir)
  raise "Where's the block of data to create?" unless block_given?

  full_file_name = "#{@config.skeleton_path}/#{subdir + '/' if subdir}#{filename}"
  File.open(full_file_name, 'a') do |file|
    yield(file, filename)
  end
end
create_file(filename, subdir) { |file, filename| ... } click to toggle source
# File vendor/cmock/lib/cmock_file_writer.rb, line 20
def create_file(filename, subdir)
  raise "Where's the block of data to create?" unless block_given?

  full_file_name_temp = "#{@config.mock_path}/#{subdir + '/' if subdir}#{filename}.new"
  full_file_name_done = "#{@config.mock_path}/#{subdir + '/' if subdir}#{filename}"
  File.open(full_file_name_temp, 'w') do |file|
    yield(file, filename)
  end
  update_file(full_file_name_done, full_file_name_temp)
end
create_subdir(subdir) click to toggle source
# File vendor/cmock/lib/cmock_file_writer.rb, line 14
def create_subdir(subdir)
  require 'fileutils'
  FileUtils.mkdir_p "#{@config.mock_path}/" unless Dir.exist?("#{@config.mock_path}/")
  FileUtils.mkdir_p "#{@config.mock_path}/#{subdir + '/' if subdir}" if subdir && !Dir.exist?("#{@config.mock_path}/#{subdir + '/' if subdir}")
end