Module: SftpTree
- Defined in:
- lib/sftp_tree.rb,
lib/sftp_tree/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
- .get_core_tree(host, username, password, path) ⇒ Object
- .get_tree(host, username, password, path, name = nil) ⇒ Object
Class Method Details
.get_core_tree(host, username, password, path) ⇒ Object
29 30 31 32 33 |
# File 'lib/sftp_tree.rb', line 29 def self.get_core_tree(host, username, password, path) data = self.get_tree(host,username,password,path) root_data = { :data => data } return root_data end |
.get_tree(host, username, password, path, name = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sftp_tree.rb', line 5 def self.get_tree(host, username, password, path, name=nil) data = {:text =>(name || path)} data[:children] = children = [] Net::SFTP.start(host, username, :password => password) do |sftp| sftp.dir.foreach(path) do |entry| next if (entry.name == '..' || entry.name == '.') if entry.longname.start_with?('d') children << self.get_tree(host,username,password, path + entry.name + '/') end if !entry.longname.start_with?('d') children << entry.name end end end return data end |