Top Level Namespace

Defined Under Namespace

Modules: GenerateFromTemplates, HasDirectories, HasOptionMethods, OverridesPermissions, Source, StepPlugin, Target, ZipDirectories Classes: FilePathAndPermissions, GpmCli, Object, PackagingTask

Constant Summary collapse

GPM_LOG_LEVEL =
::Logger.constants.include?(env_log_level) ? ::Logger.const_get(env_log_level) : ::Logger::INFO
GPM_LOG_DESTINATION =
STDOUT

Instance Method Summary collapse

Instance Method Details

#read_file_contents(files, base_directory) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/gpm/io_helpers.rb', line 18

def read_file_contents(files,base_directory)
  file_contents = {}
  files.each do |f|
    path = File.expand_path(File.join(base_directory,f))
    permissions = File.lstat(path).mode % 4096
    file_contents[FilePathAndPermissions.new(f,permissions)] = File.read(path) if File.file?(path)
  end
  file_contents
end

#write_file_contents(file_contents) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/gpm/io_helpers.rb', line 2

def write_file_contents(file_contents)
  file_contents.each do |file_name, content|
    FileUtils.mkdir_p(File.dirname(file_name))
    File.open(file_name,"w") do |file|
      file.print content
    end
    File.chmod(file_name.permissions, file_name.to_s) if file_name.is_a? FilePathAndPermissions
  end
end

#write_file_contents_in_directory(file_contents, directory) ⇒ Object



12
13
14
15
16
17
# File 'lib/gpm/io_helpers.rb', line 12

def write_file_contents_in_directory(file_contents,directory)
  FileUtils.mkdir_p directory
  Dir.chdir(directory) do
    write_file_contents(file_contents)
  end
end