class Bixby::Provision::Base

Constants

PATH

Attributes

manifest[RW]
proxy[RW]

Public Class Methods

new(obj=nil) click to toggle source
# File lib/bixby/provision/dsl/base.rb, line 20
def initialize(obj=nil)
  if obj.kind_of? Base then
    @manifest = obj.manifest
    @proxy    = obj.proxy
  end
end

Public Instance Methods

get_gid(group) click to toggle source
# File lib/bixby/provision/dsl/base.rb, line 53
def get_gid(group)
  return group if group.nil? or group.kind_of? Fixnum
  return group.to_i if group =~ /^[0-9]+$/ # convert to int, e.g. "500"
  begin
    return Etc.getgrnam(group).gid
  rescue ArgumentError => ex
    # TODO raise
    logger.warn("Group '#{group}' was invalid: #{ex.message}")
  end
  nil
end
get_group(gid) click to toggle source
# File lib/bixby/provision/dsl/base.rb, line 65
def get_group(gid)
  begin
    return Etc.getgrgid(gid).name
  rescue ArgumentError => ex
    # TODO raise
    logger.warn("Group '#{group}' was invalid: #{ex.message}")
  end
  nil
end
get_uid(user) click to toggle source
# File lib/bixby/provision/dsl/base.rb, line 31
def get_uid(user)
  return user if user.nil? or user.kind_of? Fixnum
  return user.to_i if user =~ /^[0-9]+$/ # convert to int, e.g. "500"
  begin
    return Etc.getpwnam(user).uid
  rescue ArgumentError => ex
    # TODO raise
    logger.warn("Username '#{user}' was invalid: #{ex.message}")
  end
  nil
end
get_user(uid) click to toggle source
# File lib/bixby/provision/dsl/base.rb, line 43
def get_user(uid)
  begin
    return Etc.getpwuid(uid).name
  rescue ArgumentError => ex
    # TODO raise
    logger.warn("Username '#{user}' was invalid: #{ex.message}")
  end
  nil
end
tap(&block) click to toggle source
# File lib/bixby/provision/dsl/base.rb, line 27
def tap(&block)
  self.instance_eval(&block)
end
tempfile(close=false) click to toggle source

Create a temporary file

@param [Boolean] close If true, close the file handle before returning it (default: false)

@return [Tempfile]

# File lib/bixby/provision/dsl/base.rb, line 80
def tempfile(close=false)
  t = Tempfile.new("bixby-provision-")
  t.close if close
  t
end