lib/kuzushi.rb in kuzushi-0.0.34 vs lib/kuzushi.rb in kuzushi-0.0.35
- old
+ new
@@ -11,20 +11,19 @@
## ruby 1.9 compatibility
## nested configs
## user configs
class Kuzushi
- attr_accessor :config, :config_names
+ attr_accessor :config
def initialize(url)
@url = url
@base_url = File.dirname(url)
- if @url =~ /s3.amazonaws.com.*\/([^\/]*).(\d+).tar.gz/
+ if @url =~ /s3.amazonaws.com.*\/([^\/]*)[.](\d+)[.]tar[.]gz/
@name = $1
@version = $2
end
- @config_names = []
@configs = []
@packages = []
@tasks = []
end
@@ -35,16 +34,19 @@
def boot
shell "mkdir -p /tmp/kuzushi/"
shell "cd /tmp/kuzushi/ ; curl --silent '#{@url}' | tar xzv"
@config = JSON.parse(File.read("/tmp/kuzushi/#{@name}/config.json"))
- @config_names = [ @name ]
end
def start
# load_config_stack(@name)
boot
+ run
+ end
+
+ def run
process_stack
log "----"
@tasks.each do |t|
log "TASK: #{t[:description]}"
t[:blk].call
@@ -62,20 +64,10 @@
def http_get(url)
RestClient.get(url)
end
- def load_config_stack(name)
- @config_names << name
- @configs << JSON.parse(http_get("#{@base_url}/#{name}").body)
- if import = @configs.last["import"]
- load_config_stack(import)
- else
- @config = @configs.reverse.inject({}) { |i,c| i.merge(c) }
- end
- end
-
def process_stack
script get("before")
process :packages
process :local_packages
@@ -110,14 +102,10 @@
end
def process_packages
@packages = get_array("packages")
task "install packages" do
-# shell "apt-get update"
shell "apt-get install -y #{@packages.join(" ")}" unless @packages.empty?
-# @packages.each do |pkg|
-# shell "apt-get install -y #{pkg}"
-# end
end
end
def process_local_packages(p)
package(p) do |file|