Class: HrrRbSftp::Protocol::Version3::Extensions
- Inherits:
-
Object
- Object
- HrrRbSftp::Protocol::Version3::Extensions
- Includes:
- Loggable
- Defined in:
- lib/hrr_rb_sftp/protocol/version3/extensions.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/extension.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/fsync_at_openssh_com.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/hardlink_at_openssh_com.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/lsetstat_at_openssh_com.rb,
lib/hrr_rb_sftp/protocol/version3/extensions/posix_rename_at_openssh_com.rb
Overview
This class implements SFTP protocol version 3 extension formats and responders.
Defined Under Namespace
Classes: Extension, FsyncAtOpensshCom, HardlinkAtOpensshCom, LsetstatAtOpensshCom, PosixRenameAtOpensshCom
Instance Attribute Summary
Attributes included from Loggable
Class Method Summary collapse
-
.extension_classes ⇒ Array<Class>
A list of classes that has EXTENSION_NAME constant.
-
.extension_pairs ⇒ Array
A list of extension-pair that the library supports.
Instance Method Summary collapse
-
#conditional_reply_format ⇒ Hash{Symbol=>Hash{String=>Array<Array(Object, Symbol)>}}
Conditional format used in extended-reply packet.
-
#conditional_request_format ⇒ Hash{Symbol=>Hash{String=>Array<Array(Object, Symbol)>}}
Conditional format used in extended-request packet.
-
#initialize(context, logger: nil) ⇒ Extensions
constructor
A new instance of Extensions.
-
#respond_to(request) ⇒ Hash{Symbol=>Object] Response represented in Hash.
Hash{Symbol=>Object] Response represented in Hash.
-
#respond_to?(request) ⇒ Boolean
True if request’s extended-request is supported.
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn
Constructor Details
#initialize(context, logger: nil) ⇒ Extensions
Returns a new instance of Extensions.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 31 def initialize context, logger: nil self.logger = logger @conditional_request_format = conditional_request_format @conditional_reply_format = conditional_reply_format @extensions = extension_classes.map{ |c| extension = c.new(context, logger: logger) (c::REQUEST_FORMAT[:"extended-request"] || {}).keys.map{|key| {key => extension} }.inject({}, :merge) }.inject({}, :merge) end |
Class Method Details
.extension_classes ⇒ Array<Class>
Returns A list of classes that has EXTENSION_NAME constant.
14 15 16 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 14 def self.extension_classes constants.map{|c| const_get(c)}.select{|c| c.respond_to?(:const_defined?) && c.const_defined?(:EXTENSION_NAME)} end |
.extension_pairs ⇒ Array
Returns A list of extension-pair that the library supports.
21 22 23 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 21 def self.extension_pairs extension_classes.map{|c| {:"extension-name" => c::EXTENSION_NAME, :"extension-data" => c::EXTENSION_DATA}} end |
Instance Method Details
#conditional_reply_format ⇒ Hash{Symbol=>Hash{String=>Array<Array(Object, Symbol)>}}
Returns Conditional format used in extended-reply packet.
68 69 70 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 68 def conditional_reply_format @conditional_reply_format ||= reply_formats.inject({}){|h1,h2| h1.merge(h2){|k,v1,v2| v1.merge(v2)}} end |
#conditional_request_format ⇒ Hash{Symbol=>Hash{String=>Array<Array(Object, Symbol)>}}
Returns Conditional format used in extended-request packet.
61 62 63 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 61 def conditional_request_format @conditional_request_format ||= request_formats.inject({}){|h1,h2| h1.merge(h2){|k,v1,v2| v1.merge(v2)}} end |
#respond_to(request) ⇒ Hash{Symbol=>Object] Response represented in Hash.
Returns Hash{Symbol=>Object] Response represented in Hash.
53 54 55 56 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 53 def respond_to request extended_request = request[:"extended-request"] @extensions[extended_request].respond_to request end |
#respond_to?(request) ⇒ Boolean
Returns true if request’s extended-request is supported. false if not.
45 46 47 48 |
# File 'lib/hrr_rb_sftp/protocol/version3/extensions.rb', line 45 def respond_to? request extended_request = request[:"extended-request"] @extensions.has_key?(extended_request) end |