Class: String
- Inherits:
-
Object
- Object
- String
- 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
-
#chmod(mode, options = {}) ⇒ Object
Calls Cfruby::FileOps.chmod on the file named in the String.
-
#chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), options = {}) ⇒ Object
Calls Cfruby::FileOps.chown on the file named in the String.
-
#chown_mod(owner, group, mode, options = {}) ⇒ Object
Calls Cfruby::FileOps.chown_mod on the file named in the String.
-
#exec ⇒ Object
Calls Cfruby::Exec.exec on the String, allowing for: ‘/usr/local/bin/myprogram’.exec().
-
#exist? ⇒ Boolean
(also: #exists?)
returns true if the file named in the String exists.
-
#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).
-
#install ⇒ Object
Calls Cfruby::Packages::PackageManager.install() on the String, allowing for: ‘apache’.install().
-
#mkdir(options = {}) ⇒ Object
Calls Cfruby::FileOps.mkdir on the file named in the String.
-
#must_contain(str, options = {}) ⇒ Object
Calls Cfruby::FileEdit.file_must_contain on the file named in the String.
-
#must_not_contain(str, options = {}) ⇒ Object
Calls Cfruby::FileEdit.file_must_not_contain on the file named in the String.
-
#set(variable, value, options = {}) ⇒ Object
Calls Cfruby::FileEdit.set on the file named in the String.
Instance Method Details
#chmod(mode, options = {}) ⇒ Object
Calls Cfruby::FileOps.chmod on the file named in the String
78 79 80 |
# File 'lib/libcfruby/cfrubyscript.rb', line 78 def chmod(mode, = {}) Cfruby::FileOps.chmod(self, mode, ) end |
#chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), options = {}) ⇒ Object
Calls Cfruby::FileOps.chown on the file named in the String
72 73 74 |
# File 'lib/libcfruby/cfrubyscript.rb', line 72 def chown(owner = Process::Sys.geteuid(), group = Process::Sys.getegid(), = {}) Cfruby::FileOps.chown(self, owner, group, ) end |
#chown_mod(owner, group, mode, options = {}) ⇒ Object
Calls Cfruby::FileOps.chown_mod on the file named in the String
66 67 68 |
# File 'lib/libcfruby/cfrubyscript.rb', line 66 def chown_mod(owner, group, mode, = {}) Cfruby::FileOps.chown_mod(self, owner, group, mode, ) end |
#exec ⇒ Object
Calls Cfruby::Exec.exec on the String, allowing for:
'/usr/local/bin/myprogram'.exec()
44 45 46 |
# File 'lib/libcfruby/cfrubyscript.rb', line 44 def exec() return(Cfruby::Exec.exec(self)) end |
#exist? ⇒ Boolean Also known as: exists?
returns true if the file named in the String exists
90 91 92 |
# File 'lib/libcfruby/cfrubyscript.rb', line 90 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)
98 99 100 101 102 103 104 |
# File 'lib/libcfruby/cfrubyscript.rb', line 98 def fileempty?() Cfruby::FileFind.find(self, :empty => true) { |filename| return(true) } return(false) end |
#install ⇒ Object
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
84 85 86 |
# File 'lib/libcfruby/cfrubyscript.rb', line 84 def mkdir( = {}) Cfruby::FileOps.mkdir(self, ) end |
#must_contain(str, options = {}) ⇒ Object
Calls Cfruby::FileEdit.file_must_contain on the file named in the String
54 55 56 |
# File 'lib/libcfruby/cfrubyscript.rb', line 54 def must_contain(str, ={}) Cfruby::FileEdit.file_must_contain(self, str, ) end |
#must_not_contain(str, options = {}) ⇒ Object
Calls Cfruby::FileEdit.file_must_not_contain on the file named in the String
60 61 62 |
# File 'lib/libcfruby/cfrubyscript.rb', line 60 def must_not_contain(str, ={}) Cfruby::FileEdit.file_must_not_contain(self, str, ) end |