lib/kuzushi.rb in kuzushi-0.0.44 vs lib/kuzushi.rb in kuzushi-0.0.45

- old
+ new

@@ -16,20 +16,23 @@ attr_accessor :config def self.version end - def initialize(url) - @url = url - @base_url = File.dirname(url) - if @url =~ /s3.amazonaws.com.*\/([^\/]*)[.](\d+)[.]tar[.]gz/ - @name = $1 - @version = $2 + def initialize(url = nil) + if url + @url = url + @base_url = File.dirname(url) + if @url =~ /s3.amazonaws.com.*\/([^\/]*)[.](\d+)[.]tar[.]gz/ + @name = $1 + @version = $2 + end + @scripts = true + @configs = [] + @packages = [] + @tasks = [] end - @configs = [] - @packages = [] - @tasks = [] end def init @init = true start @@ -45,18 +48,33 @@ # load_config_stack(@name) boot run end + def setup + @init = (ENV['JUDO_FIRSTBOOT'] == "true") + @config = JSON.parse(File.read("config.json")) + @scripts = false + + process :packages + process :volumes + + execute_tasks + end + def run process_stack - log "----" + execute_tasks + end + + def execute_tasks + log "---- BEGIN KUZUSHI " @tasks.each do |t| log "TASK: #{t[:description]}" t[:blk].call end - log "----" + log "---- END KUZUSHI " end protected def system @@ -89,11 +107,11 @@ def process(type) ## if the file takes no args - just call it once if method("process_#{type}").arity == 0 send("process_#{type}") else - ## else call it once per item + ## else call it once per item get_array(type).each do |item| script item["before"] if item.is_a? Hash send("process_#{type}", OpenStruct.new(item)) else @@ -275,9 +293,10 @@ end end def script(scripts) + return unless @scripts to_array(scripts).each do |s| if s =~ /^#!/ inline_script(s) else external_script(s)