Class: Boxes::Environment
- Inherits:
-
Object
- Object
- Boxes::Environment
- Defined in:
- lib/boxes/environment.rb
Overview
For creating and managing the environment which boxes uses.
Instance Method Summary collapse
- #available_scripts ⇒ Object
- #available_templates ⇒ Object
- #hidden_scripts ⇒ Object
- #hidden_templates ⇒ Object
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
4 5 6 7 8 9 |
# File 'lib/boxes/environment.rb', line 4 def initialize FileUtils.mkdir_p(Boxes.config.working_dir) copy_templates copy_scripts end |
Instance Method Details
#available_scripts ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/boxes/environment.rb', line 30 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 |
#available_templates ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/boxes/environment.rb', line 11 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 |
#hidden_scripts ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/boxes/environment.rb', line 39 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 |
#hidden_templates ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/boxes/environment.rb', line 21 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 |