Sha256: e053e47e5201463c8e987b21a1cad5d6affe0fb5668c831dd9a697c808c196c8
Contents?: true
Size: 1.96 KB
Versions: 19
Compression:
Stored size: 1.96 KB
Contents
module Boxes # For creating and managing the environment which boxes uses. class Environment def initialize FileUtils.mkdir_p(Boxes.config.working_dir) copy_templates copy_scripts end def available_templates t = Dir.glob("#{Boxes.config.working_dir}/templates/*/**") a = t.collect { |c| c.include?('preseed.cfg') ? next : c }.compact a.collect do |c| c = c.gsub(Boxes.config.working_dir.to_s + '/templates/', '') c.gsub('.erb', '') end end def hidden_templates t = Dir.glob("#{Boxes.config.working_dir}/templates/*/**") a = t.collect { |c| c.include?('preseed.cfg') ? c : next }.compact a.collect do |c| c.gsub(Boxes.config.working_dir.to_s + '/templates/', '') end end def available_scripts t = Dir.glob("#{Boxes.config.working_dir}/scripts/*") a = t.collect { |c| c.include?('purge.sh') ? next : c }.compact a.collect do |c| c.gsub(Boxes.config.working_dir.to_s + '/scripts/', '') end end def hidden_scripts t = Dir.glob("#{Boxes.config.working_dir}/scripts/*") a = t.collect { |c| c.include?('purge.sh') ? c : next }.compact a.collect do |c| c.gsub(Boxes.config.working_dir.to_s + '/scripts/', '') end end private def copy_templates templates_dir = Boxes.config.working_dir + 'templates' FileUtils.mkdir_p(templates_dir) Boxes.config.template_paths.each do |template_path| Dir.glob("#{template_path}/*").each do |src_template| FileUtils.cp_r(src_template, templates_dir) end end end def copy_scripts scripts_dir = Boxes.config.working_dir + 'scripts' FileUtils.mkdir_p(Boxes.config.working_dir + 'scripts') Boxes.config.script_paths.each do |script_path| Dir.glob("#{script_path}/*").each do |src_script| FileUtils.cp_r(src_script, scripts_dir) end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems