lib/io_streams/paths/sftp.rb
# Search for files on the remote sftp server that match the provided pattern.
#
# The pattern matching works like Net::SFTP::Operations::Dir.glob and Dir.glob
# Each child also returns attributes that contain the file size, ownership, file dates and other details.
#
# Example Code:
# IOStreams.
#   path("sftp://sftp.example.org/my_files", username: username, password: password).
#   each_child('**/*.{csv,txt}') do |input, attributes|
#     puts "#{input.to_s} #{attributes}"
#   end
#
# Example Output:
# sftp://sftp.example.org/a/b/c/test.txt {:type=>1, :size=>37, :owner=>"test_owner", :group=>"test_group",
#   :permissions=>420, :atime=>1572378136, :mtime=>1572378136, :link_count=>1, :extended=>{}}
Search for files on the remote sftp server that match the provided pattern.




Search for files on the remote sftp server that match the provided pattern .
def each_child(pattern = "*", case_sensitive: true, directories: false, hidden: false)
        unless block_given?
          return to_enum(__method__, pattern,
                         case_sensitive: case_sensitive, directories: directories, hidden: hidden)
        end
        Utils.load_soft_dependency("net-sftp", "SFTP glob capability", "net/sftp") unless defined?(Net::SFTP)
        flags = ::File::FNM_EXTGLOB
        flags |= ::File::FNM_CASEFOLD unless case_sensitive
        flags |= ::File::FNM_DOTMATCH if hidden
        Net::SFTP.start(hostname, username, build_ssh_options) do |sftp|
          sftp.dir.glob(".", pattern, flags) do |path|
            next if !directories && !path.file?
            new_path = self.class.new("sftp://#{hostname}/#{path.name}", username: username, password: password, **ssh_options)
            yield(new_path, path.attributes.attributes)
          end
        end
        nil
      end
def each_child ( pattern = "*" , case_sensitive : true , directories : false , hidden : false ) unless block_given? return to_enum ( __method__ , pattern , case_sensitive : case_sensitive , directories : directories , hidden : hidden ) end Utils . load_soft_dependency ( "net-sftp" , "SFTP glob capability" , "net/sftp" ) unless defined? ( Net :: SFTP ) flags = :: File :: FNM_EXTGLOB flags |= :: File :: FNM_CASEFOLD unless case_sensitive flags |= :: File :: FNM_DOTMATCH if hidden Net :: SFTP . start ( hostname , username , build_ssh_options ) do | sftp | sftp . dir . glob ( "." , pattern , flags ) do | path | next if ! directories && ! path . file? new_path = self . class . new ( "sftp://#{hostname}/#{path.name}" , username : username , password : password , ** ssh_options ) yield ( new_path , path . attributes . attributes ) end end nil end
Search for files on the remote sftp server that match the provided pattern.
Search for files on the remote sftp server that match the provided pattern .
pattern
case_sensitive
directories
hidden