lib/kuzushi.rb in kuzushi-0.0.23 vs lib/kuzushi.rb in kuzushi-0.0.24
- old
+ new
@@ -7,10 +7,12 @@
## IDEAS
## firewall until ready
## ruby 1.9 compatibility
+## nested configs
+## user configs
class Kuzushi
attr_accessor :config, :config_names
def initialize(url)
@@ -241,22 +243,30 @@
fetch("/packages/#{p}_#{package_arch}.deb") do |file|
block.call(file)
end
end
+
+ def script(scripts)
+ to_array(scripts).each do |s|
+ if s =~ /^#!/
+ inline_script(s)
+ else
+ external_script(s)
+ end
+ end
+ end
+
def inline_script(script)
tmpfile(script) do |tmp|
task "run inline script" do
shell "#{tmp}"
end
end
end
- def script(script)
- return if script.nil?
- return inline_script(script) if script =~ /^#!/
-
+ def external_script(script)
fetch("/scripts/#{script}") do |file|
task "run script #{script}" do
shell "#{file}"
end
end
@@ -269,11 +279,11 @@
path
end
def file(f, &blk)
## no magic here - move along
- fetch("/templates/#{f.template}", lambda { |data| erb data }, &blk) if f.template
+ fetch("/templates/#{f.template}", lambda { |data| erb data }, &blk) if f.template
fetch("/files/#{f.source || File.basename(f.file)}", &blk) unless f.template
end
def fetch(file, filter = lambda { |d| d }, &block)
names = config_names.clone
@@ -299,10 +309,14 @@
def get(key)
config[key.to_s]
end
def get_array(key)
- [ get(key) || [] ].flatten
+ to_array( get(key) )
+ end
+
+ def to_array(value)
+ [ value || [] ].flatten
end
def wait_for_volume(vol)
## Maybe use ohai here instead -- FIXME
until dev_exists? vol do