Module: EM::FTPD::FSD::Base
- Defined in:
- lib/em-ftpd-fsd/base.rb
Overview
Base module to include in custom drivers
Constant Summary collapse
- COMMANDS =
Supported FTP commands.
{ bytes: { on_error_value: nil }, dir_contents: { on_error_value: nil }, get_file: { on_error_value: nil }, change_dir: { on_error_value: false }, delete_dir: { on_error_value: false }, delete_file: { on_error_value: false }, rename: { on_error_value: false }, make_dir: { on_error_value: false }, put_file: { on_error_value: false }, }
Class Method Summary collapse
-
.included(klass) ⇒ Object
Extend hooks module to load ‘before’ and ‘after’ class functions.
Instance Method Summary collapse
-
#base_path ⇒ String
Absolute path to FTP base directory.
-
#initialize(options = {}) ⇒ Object
Initiliaze the driver with basic options.
-
#method_missing(method, *args, &block) {|Object| ... } ⇒ Object
Metaprogrammed redirection to FTP commands defined by FileOperation class.
-
#respond_to?(method, include_private = false) ⇒ Boolean
Return true if obj respond to given method or method correspond to an implemented ftp command.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) {|Object| ... } ⇒ Object
Metaprogrammed redirection to FTP commands defined by FileOperation class.
86 87 88 89 90 91 |
# File 'lib/em-ftpd-fsd/base.rb', line 86 def method_missing( method, *args, &block ) raise NoMethodError, "#{method}" unless COMMANDS.include?( method ) raise ArgumentError, "Block needed" unless block_given? yield ftp_methods( method, args ) end |
Class Method Details
Instance Method Details
#base_path ⇒ String
Absolute path to FTP base directory.
75 76 77 |
# File 'lib/em-ftpd-fsd/base.rb', line 75 def base_path File.( @base_path || "" ) end |
#initialize(options = {}) ⇒ Object
Initiliaze the driver with basic options
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/em-ftpd-fsd/base.rb', line 57 def initialize( = {} ) opts = { base_path: Dir.pwd, authentication: { plain: { user: "admin", password: "root" } } }.merge( ) load_auth_module( opts[:authentication] ) @base_path = opts[:base_path] end |
#respond_to?(method, include_private = false) ⇒ Boolean
Return true if obj respond to given method or method correspond to an implemented ftp command.
97 98 99 |
# File 'lib/em-ftpd-fsd/base.rb', line 97 def respond_to?( method, include_private = false ) super( method, include_private ) || COMMANDS.include?( method ) end |