Class: Woro::Adapters::Ftp
Instance Attribute Summary collapse
-
#folder ⇒ Object
Returns the value of attribute folder.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
-
.setup ⇒ Hash
Setup configuration for adapter Highline CLI helpers can be used for interactivity.
Instance Method Summary collapse
-
#initialize(options = []) ⇒ Ftp
constructor
A new instance of Ftp.
-
#list_contents ⇒ Hash
Returns the list of rake files included in the remote collection with their contents.
-
#list_files ⇒ Array
Returns the list of rake files included in the remote collection.
-
#push(task) ⇒ Object
Push this task’s file content to ftp server.
-
#raw_url(file_name) ⇒ String
The raw url is for downloading the rake task content via ftp.
Methods inherited from Base
create_initial_remote_task, #extract_description
Constructor Details
#initialize(options = []) ⇒ Ftp
Returns a new instance of Ftp.
19 20 21 22 23 24 |
# File 'lib/woro/adapters/ftp.rb', line 19 def initialize( = []) self.host = ['host'] self.user = ['user'] self.password = ['password'] self.folder = ['folder'] || '/' end |
Instance Attribute Details
#folder ⇒ Object
Returns the value of attribute folder.
5 6 7 |
# File 'lib/woro/adapters/ftp.rb', line 5 def folder @folder end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/woro/adapters/ftp.rb', line 5 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
5 6 7 |
# File 'lib/woro/adapters/ftp.rb', line 5 def password @password end |
#user ⇒ Object
Returns the value of attribute user.
5 6 7 |
# File 'lib/woro/adapters/ftp.rb', line 5 def user @user end |
Class Method Details
.setup ⇒ Hash
Setup configuration for adapter Highline CLI helpers can be used for interactivity.
10 11 12 13 14 15 16 17 |
# File 'lib/woro/adapters/ftp.rb', line 10 def self.setup { 'host' => ask('FTP Host: '), 'user' => ask('FTP User: '), 'password' => ask('FTP Passwod: '), 'folder' => ask('FTP Folder: ') { |q| q.default = '/' } } end |
Instance Method Details
#list_contents ⇒ Hash
Returns the list of rake files included in the remote collection with their contents.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/woro/adapters/ftp.rb', line 39 def list_contents {}.tap do |files| remote_files do |file| ftp.gettextfile(file) do |line, newline| content.concat newline ? line + "\n" : line end # temporarly downloads the file FileUtils.rm file files[file] = { data: content } end end end |
#list_files ⇒ Array
Returns the list of rake files included in the remote collection.
28 29 30 31 32 33 34 |
# File 'lib/woro/adapters/ftp.rb', line 28 def list_files [].tap do |files| remote_files do |file| files << file end end end |
#push(task) ⇒ Object
Push this task’s file content to ftp server. Existing contents by the same #file_name will be overriden.
53 54 55 56 57 58 |
# File 'lib/woro/adapters/ftp.rb', line 53 def push(task) client do |ftp| ftp.chdir(folder) ftp.put(task.file_path, task.file_name) end end |
#raw_url(file_name) ⇒ String
The raw url is for downloading the rake task content via ftp.
63 64 65 |
# File 'lib/woro/adapters/ftp.rb', line 63 def raw_url(file_name) "ftp://#{user}@#{host}#{folder}#{file_name}" end |