class Propro::Script
Public Class Methods
load(file)
click to toggle source
# File lib/propro/script.rb, line 3 def self.load(file) script = new script.load_file(file) script end
new()
click to toggle source
# File lib/propro/script.rb, line 9 def initialize @sources = [] @options = [] @commands = [] @server = nil @password = nil source :lib end
Public Instance Methods
get_password()
click to toggle source
# File lib/propro/script.rb, line 34 def get_password @password end
get_server()
click to toggle source
# File lib/propro/script.rb, line 30 def get_server @server end
get_user()
click to toggle source
# File lib/propro/script.rb, line 38 def get_user @user end
load_file(file)
click to toggle source
# File lib/propro/script.rb, line 18 def load_file(file) @file = file @file_name = File.basename(@file) instance_eval(File.read(file)) end
provision(*commands)
click to toggle source
# File lib/propro/script.rb, line 50 def provision(*commands) @commands.concat(commands.flatten.map { |c| Command.new(c) }) end
server(host, opts = {})
click to toggle source
# File lib/propro/script.rb, line 24 def server(host, opts = {}) @server = host @password = opts[:password] @user = opts[:user] || 'root' end
set(key, value)
click to toggle source
# File lib/propro/script.rb, line 46 def set(key, value) @options << Option.new(key, value) end
source(src)
click to toggle source
# File lib/propro/script.rb, line 42 def source(src) @sources.concat(Package.sources_for_path(src)) end
to_bash()
click to toggle source
# File lib/propro/script.rb, line 54 def to_bash <<-SH #!/usr/bin/env bash #{Propro.comment_banner} # # Built from: #{@file_name} unset UCF_FORCE_CONFFOLD export UCF_FORCE_CONFFNEW="YES" export DEBIAN_FRONTEND="noninteractive" #{sources_bash} # Options from: #{@file_name} #{options_bash} function main { #{commands_bash} finished reboot-system } main SH end
Private Instance Methods
commands_bash()
click to toggle source
# File lib/propro/script.rb, line 91 def commands_bash @commands.map(&:to_bash).join("\n ") end
options_bash()
click to toggle source
# File lib/propro/script.rb, line 83 def options_bash @options.map(&:to_bash).join("\n").strip end
sources_bash()
click to toggle source
# File lib/propro/script.rb, line 87 def sources_bash @sources.map(&:to_bash).join("\n").strip end