Module: EasyInstaller::InstallHelper
- Included in:
- MethodValidateHelper
- Defined in:
- lib/easy_installer/autoload.rb,
lib/easy_installer/install_helpers/zip.rb,
lib/easy_installer/install_helpers/template.rb,
lib/easy_installer/methods/ftp/install_helper.rb,
lib/easy_installer/methods/local/install_helper.rb,
lib/easy_installer/methods/sample/install_helper.rb
Defined Under Namespace
Instance Method Summary collapse
-
#chmod(remote_file, chmod) ⇒ Object
-
Args : -
remote_file
-> path to file -chmod
-> 3 digits of chmod * Returns : - true.
-
-
#chmod_r(remote_dir, chmod) ⇒ Object
need to test.
-
#create_directory(dirpath, chmod = 664) ⇒ Object
e.g.
- #delete_directory(dirpath) ⇒ Object
-
#move_directory(local_directory, remote_directory) ⇒ Object
copy local directory to remote can be used to push data to server e.g.
-
#move_file(local_file, remote_file, chmod = 664) ⇒ Object
-
Args : -
local_file
-> path to local file -remote_file
-> path where put file -chmod
-> 3 digits of chmod * Returns : - true.
-
-
#remove_directory(dirpath) ⇒ Object
-
Args : -
dirpath
-> path to dir * Returns : - true.
-
- #setup(params = {}) ⇒ Object
Instance Method Details
#chmod(remote_file, chmod) ⇒ Object
-
Args :
-
remote_file
-> path to file
-
- chmod
-> 3 digits of chmod
-
Returns :
-
true
-
88 89 90 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 88 def chmod(remote_file, chmod) @ftp.sendcmd("SITE CHMOD 0#{chmod} #{remote_file}") end |
#chmod_r(remote_dir, chmod) ⇒ Object
need to test
97 98 99 100 101 102 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 97 def chmod_r(remote_dir, chmod) @ftp.sendcmd("SITE CHMOD 0#{chmod} #{remote_dir}") @ftp.list(remote_dir).each do |element| chmod_r(File.joint(remote_dir, element)) end end |
#create_directory(dirpath, chmod = 664) ⇒ Object
e.g. create_directory(“tmp”, 664)
-
Args :
-
dirpath
-> path to dir
-
- chmod
-> 3 digits of chmod
-
Returns :
-
true
-
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 48 def create_directory(dirpath, chmod=664) dir = dirpath.split '/' dir.each_index do |index| begin @ftp.mkdir(dir[0..index].join '/') # @ftp.sendcmd("SITE CHMOD 0#{chmod} #{dir[0..index].join '/'}") puts "SITE CHMOD 0#{chmod} #{dir[0..index].join '/'}" rescue # @ftp.sendcmd("SITE CHMOD 0#{chmod} #{dir[0..index].join '/'}") puts "Can't create #{dir[0..index].join '/'}" end end end |
#delete_directory(dirpath) ⇒ Object
23 24 25 |
# File 'lib/easy_installer/methods/local/install_helper.rb', line 23 def delete_directory(dirpath) FileUtils::rm_rf(dirpath) end |
#move_directory(local_directory, remote_directory) ⇒ Object
copy local directory to remote can be used to push data to server e.g. move_directory(“joomla_installer”, @inputs)
-
Args :
-
local_directory
-> path to local directory -
remote_directory
-> path where put directory
-
-
Returns :
-
true
-
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 19 def move_directory(local_directory,remote_directory) begin puts remote_directory @ftp.mkdir(remote_directory) rescue puts "can't create directory" end Dir.entries(local_directory).each do |element| if element == "." || element == ".." next end if File.directory?(local_directory+"/"+element) move_directory(local_directory+"/"+element, remote_directory+"/"+element) else puts "binary put " puts local_directory+"/"+element @ftp.putbinaryfile(local_directory+"/"+element, remote_directory+"/"+element) puts "send" end end end |
#move_file(local_file, remote_file, chmod = 664) ⇒ Object
-
Args :
-
local_file
-> path to local file -
remote_file
-> path where put file
-
- chmod
-> 3 digits of chmod
-
Returns :
-
true
-
77 78 79 80 81 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 77 def move_file(local_file,remote_file, chmod=664) create_directory(File.dirname(remote_file), chmod) @ftp.putbinaryfile(local_file, remote_file) @ftp.sendcmd("SITE CHMOD 0#{chmod} #{remote_file}") end |
#remove_directory(dirpath) ⇒ Object
-
Args :
-
dirpath
-> path to dir
-
-
Returns :
-
true
-
67 68 69 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 67 def remove_directory(dirpath) @ftp.rmdir(dirpath) end |
#setup(params = {}) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/easy_installer/methods/ftp/install_helper.rb', line 4 def setup params = {} host = params["ftp_host"] username = params["ftp_username"] password = params["ftp_password"] @ftp = Net::FTP.new(host) @ftp.login(username, password) end |