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.
-
#uninstall ⇒ Object
Calls Cfruby::Packages::PackageManager.uninstall() on the String, allowing for: ‘apache’.uninstall().
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, = {}) 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
81 82 83 |
# File 'lib/libcfruby/cfrubyscript.rb', line 81 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
75 76 77 |
# File 'lib/libcfruby/cfrubyscript.rb', line 75 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()
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
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)
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 |
#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
93 94 95 |
# File 'lib/libcfruby/cfrubyscript.rb', line 93 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
63 64 65 |
# File 'lib/libcfruby/cfrubyscript.rb', line 63 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
69 70 71 |
# File 'lib/libcfruby/cfrubyscript.rb', line 69 def must_not_contain(str, ={}) Cfruby::FileEdit.file_must_not_contain(self, str, ) 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, ={}) Cfruby::FileEdit.set(self, variable, value, ) end |
#uninstall ⇒ Object
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 |