Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/libcfruby/cfrubyscript.rb

Overview

Including cfrubyscript adds a number of new helper methods to String that are useful in cutting down the verbosity of system administration scripts.

Instance Method Summary collapse

Instance Method Details

#chmod(mode, options = {}) ⇒ Object

Calls Cfruby::FileOps.chmod on the file named in the String



87
88
89
# File 'lib/libcfruby/cfrubyscript.rb', line 87

def chmod(mode, options = {})
	Cfruby::FileOps.chmod(self, mode, options)
end

#chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), options = {}) ⇒ Object

Calls Cfruby::FileOps.chown on the file named in the String



81
82
83
# File 'lib/libcfruby/cfrubyscript.rb', line 81

def chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), options = {})
	Cfruby::FileOps.chown(self, owner, group, options)
end

#chown_mod(owner, group, mode, options = {}) ⇒ Object

Calls Cfruby::FileOps.chown_mod on the file named in the String



75
76
77
# File 'lib/libcfruby/cfrubyscript.rb', line 75

def chown_mod(owner, group, mode, options = {})
	Cfruby::FileOps.chown_mod(self, owner, group, mode, options)
end

#execObject

Calls Cfruby::Exec.exec on the String, allowing for: ‘/usr/local/bin/myprogram’.exec()



53
54
55
# File 'lib/libcfruby/cfrubyscript.rb', line 53

def exec()
	return(Cfruby::Exec.exec(self))
end

#exist?Boolean Also known as: exists?

returns true if the file named in the String exists

Returns:

  • (Boolean)


99
100
101
# File 'lib/libcfruby/cfrubyscript.rb', line 99

def exist?()
	return(FileTest.exist?(self))
end

#fileempty?Boolean

returns true if the file named in the String is empty (as defined in Cfruby::FileFind.find() when passed the option :empty => true)

Returns:

  • (Boolean)


107
108
109
110
111
112
113
# File 'lib/libcfruby/cfrubyscript.rb', line 107

def fileempty?()
	Cfruby::FileFind.find(self, :empty => true) { |filename|
		return(true)
	}
	
	return(false)
end

#installObject

Calls Cfruby::Packages::PackageManager.install() on the String, allowing for: ‘apache’.install()



35
36
37
38
39
# File 'lib/libcfruby/cfrubyscript.rb', line 35

def install()
	os = Cfruby::OS::OSFactory.new.get_os()
	pkg_manager = os.get_package_manager()
	pkg_manager.install(self)
end

#mkdir(options = {}) ⇒ Object

Calls Cfruby::FileOps.mkdir on the file named in the String



93
94
95
# File 'lib/libcfruby/cfrubyscript.rb', line 93

def mkdir(options = {})
	Cfruby::FileOps.mkdir(self, options)
end

#must_contain(str, options = {}) ⇒ Object

Calls Cfruby::FileEdit.file_must_contain on the file named in the String



63
64
65
# File 'lib/libcfruby/cfrubyscript.rb', line 63

def must_contain(str, options={})
	Cfruby::FileEdit.file_must_contain(self, str, options)
end

#must_not_contain(str, options = {}) ⇒ Object

Calls Cfruby::FileEdit.file_must_not_contain on the file named in the String



69
70
71
# File 'lib/libcfruby/cfrubyscript.rb', line 69

def must_not_contain(str, options={})
	Cfruby::FileEdit.file_must_not_contain(self, str, options)
end

#set(variable, value, options = {}) ⇒ Object

Calls Cfruby::FileEdit.set on the file named in the String



58
59
60
# File 'lib/libcfruby/cfrubyscript.rb', line 58

def set(variable, value, options={})
	Cfruby::FileEdit.set(self, variable, value, options)
end

#uninstallObject

Calls Cfruby::Packages::PackageManager.uninstall() on the String, allowing for: ‘apache’.uninstall()



44
45
46
47
48
# File 'lib/libcfruby/cfrubyscript.rb', line 44

def uninstall()
	os = Cfruby::OS::OSFactory.new.get_os()
	pkg_manager = os.get_package_manager()
	pkg_manager.uninstall(self)
end