class Setup::Base
Common base class for all Setup
build classes.
Attributes
config[R]
force[RW]
io[RW]
project[R]
quiet[RW]
trace[RW]
trial[RW]
Public Class Methods
new(project, configuration, options={})
click to toggle source
# File lib/setup/base.rb, line 32 def initialize(project, configuration, options={}) @project = project @config = configuration initialize_hooks options.each do |k,v| __send__("#{k}=", v) if respond_to?("#{k}=") end end
Public Instance Methods
bash(*args)
click to toggle source
Shellout executation.
# File lib/setup/base.rb, line 75 def bash(*args) $stderr.puts args.join(' ') if trace? system(*args) or raise RuntimeError, "system(#{args.map{|a| a.inspect }.join(' ')}) failed" end
Also aliased as: command
force?()
click to toggle source
# File lib/setup/base.rb, line 67 def force? ; @force ; end
force_remove_file(path)
click to toggle source
# File lib/setup/base.rb, line 116 def force_remove_file(path) begin remove_file(path) rescue end end
initialize_hooks()
click to toggle source
Hooking into the setup process, use extension scripts according to the name of the class. For instance to augment the behavior of the Installer
, use:
.setup/installer.rb
# File lib/setup/base.rb, line 49 def initialize_hooks file = META_EXTENSION_DIR + "/#{self.class.name.downcase}.rb" if File.exist?(file) script = File.read(file) (class << self; self; end).class_eval(script) end end
quiet?()
click to toggle source
# File lib/setup/base.rb, line 64 def quiet? ; @quiet ; end
remove_file(path)
click to toggle source
# File lib/setup/base.rb, line 124 def remove_file(path) File.chmod 0777, path File.unlink(path) end
rm_f(path)
click to toggle source
# File lib/setup/base.rb, line 109 def rm_f(path) io.puts "rm -f #{path}" if trace? or trial? return if trial? force_remove_file(path) end
rmdir(path)
click to toggle source
# File lib/setup/base.rb, line 130 def rmdir(path) io.puts "rmdir #{path}" if trace? or trial? return if trial? Dir.rmdir(path) end
rootdir()
click to toggle source
# File lib/setup/base.rb, line 70 def rootdir project.rootdir end
ruby(*args)
click to toggle source
Shellout a ruby command.
# File lib/setup/base.rb, line 84 def ruby(*args) bash(config.rubyprog, *args) end
trace?()
click to toggle source
# File lib/setup/base.rb, line 61 def trace? ; @trace ; end
trace_off() { || ... }
click to toggle source
# File lib/setup/base.rb, line 97 def trace_off #:yield: begin save, @trace = trace?, false yield ensure @trace = save end end
trial?()
click to toggle source
# File lib/setup/base.rb, line 58 def trial? ; @trial ; end