Class: PoolParty::Script

Inherits:
Object show all
Includes:
Parenting
Defined in:
lib/poolparty/poolparty/script.rb

Class Method Summary collapse

Class Method Details

.for_save_stringObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/poolparty/poolparty/script.rb', line 31

def self.for_save_string
  out = []
  pools.collect {|n,pl| pl}.each do |pl|
    out << "pool :#{pl.name} do"
    clouds.each do |n,cl|
      # grossy-gross
      minimum_runnable_options_string = cl.minimum_runnable_options.collect do |o|
        "#{o} #{cl.send(o).respec_string}" unless cl.send(o).nil?
      end
      out << <<-EOE
cloud :#{cl.name} do
  #{minimum_runnable_options_string.join("\n")}
end
      EOE
    end
    out << "end"
  end
  out.join("\n")
end

.inflate(script, file = "__SCRIPT__") ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/poolparty/poolparty/script.rb', line 11

def self.inflate(script, file="__SCRIPT__")
  module_eval script, file
  # a = new
  # a.instance_eval <<-EOM
  #   def run_child(pa)
  #     context_stack.push pa
  #     #{str}
  #     context_stack.pop
  #     remove_method(:run_child)
  #     self
  #   end
  # EOM
  # a.run_child(self)
  # a
end

.inflate_file(file) ⇒ Object



7
8
9
# File 'lib/poolparty/poolparty/script.rb', line 7

def self.inflate_file(file)
  inflate open(file).read if file
end

.save!(to_file = true) ⇒ Object



51
52
53
54
# File 'lib/poolparty/poolparty/script.rb', line 51

def self.save!(to_file=true)
  write_to_file_in_storage_directory(Default.default_specfile_name, for_save_string) if to_file
  for_save_string
end

.to_ruby(opts = {}, &blk) ⇒ Object



27
28
29
# File 'lib/poolparty/poolparty/script.rb', line 27

def self.to_ruby(opts={},&blk)
  blk.to_ruby(opts)
end