Module: FtpParadise
- Defined in:
- lib/ftp_paradise/base/base.rb,
lib/ftp_paradise/shell/menu.rb,
lib/ftp_paradise/entry/entry.rb,
lib/ftp_paradise/shell/shell.rb,
lib/ftp_paradise/colours/colours.rb,
lib/ftp_paradise/project/project.rb,
lib/ftp_paradise/version/version.rb,
lib/ftp_paradise/toplevel_methods/e.rb,
lib/ftp_paradise/colours/use_colours.rb,
lib/ftp_paradise/constants/constants.rb,
lib/ftp_paradise/toplevel_methods/opn.rb,
lib/ftp_paradise/toplevel_methods/rds.rb,
lib/ftp_paradise/connection/connection.rb,
lib/ftp_paradise/toplevel_methods/misc.rb,
lib/ftp_paradise/toplevel_methods/port.rb,
lib/ftp_paradise/toplevel_methods/time.rb,
lib/ftp_paradise/gui/gtk3/ftp_client/misc.rb,
lib/ftp_paradise/toplevel_methods/connect.rb,
lib/ftp_paradise/toplevel_methods/dataset.rb,
lib/ftp_paradise/toplevel_methods/password.rb,
lib/ftp_paradise/configuration/configuration.rb,
lib/ftp_paradise/toplevel_methods/ftp_object.rb,
lib/ftp_paradise/toplevel_methods/login_name.rb,
lib/ftp_paradise/toplevel_methods/remote_url.rb,
lib/ftp_paradise/toplevel_methods/is_on_roebe.rb,
lib/ftp_paradise/gui/gtk3/ftp_client/constants.rb,
lib/ftp_paradise/gui/gtk3/ftp_client/ftp_client.rb,
lib/ftp_paradise/toplevel_methods/upload_and_download.rb,
lib/ftp_paradise/requires/require_the_toplevel_methods.rb,
lib/ftp_paradise/toplevel_methods/file_related_actions.rb,
lib/ftp_paradise/toplevel_methods/directory_related_actions.rb
Overview
#
require ‘ftp_paradise/toplevel_methods/directory_related_actions.rb’
#
Defined Under Namespace
Modules: Base, GUI
Classes: Connection, Entry, Shell
Constant Summary
collapse
- PROJECT_BASE_DIRECTORY =
#
FtpParadise::PROJECT_BASE_DIRECTORY
#
File.absolute_path("#{__dir__}/..")+'/'
- PROJECT_YAML_DIRECTORY =
#
PROJECT_YAML_DIRECTORY
This constant specifies where the project-specific yaml/ directory will be kept at for the ftp_paradise project. Ideally you should use the method rather than this constant, though.
#
"#{PROJECT_BASE_DIRECTORY}yaml/"
- YAML_DIRECTORY =
PROJECT_YAML_DIRECTORY
- VERSION =
'1.5.4'
- LAST_UPDATE =
'01.06.2023'
- NAMESPACE =
inspect
- N =
"\n"
- SHALL_WE_DEBUG =
false
- ARRAY_HELP_OPTIONS =
#
ARRAY_HELP_OPTIONS
This Array is only required in the interactive variant though.
#
%w(
HELP --help help hel he h hlep
)
- ARRAY_BINARY_FILES =
#
ARRAY_BINARY_FILES
Just note down the extension names.
#
%w(
pdf
docx
odt
doc
)
- ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL =
#
ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL
#
%w(
q
quit
exit
break
)
- FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL =
#
FtpParadise::FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL
#
"#{PROJECT_YAML_DIRECTORY}automatically_connect_on_startup_of_the_interactive_ftp_shell.yml"
- HOME_DIRECTORY_OF_USER_X =
#
HOME_DIRECTORY_OF_USER_X
This is also only useful on my home setup.
#
'/home/x/'
- FILE_ROEBE_FTP =
#
FILE_ROEBE_FTP
This constant specifies to where I keep track of my ftp-dataset, for the remote websites I use. This is thus not useful for other people to know. :D
In theory you could change this if you use a similar .yml file.
This will, on my home directory, expand to:
/home/x/data/personal/yaml/ftp/roebe_ftp.yml
#
"#{HOME_DIRECTORY_OF_USER_X}data/personal/yaml/ftp/roebe_ftp.yml"
Class Method Summary
collapse
-
.can_connect_to_remote_site? ⇒ Boolean
# === FtpParadise.can_connect_to_remote_site?.
-
.chdir(i) ⇒ Object
# === FtpParadise.chdir (cd tag).
-
.clear_user_dataset ⇒ Object
# === FtpParadise.clear_user_dataset.
-
.close ⇒ Object
# === FtpParadise.close ========================================================================= #.
-
.config? ⇒ Boolean
# === FtpParadise.config?.
-
.connect(where_to = {}) ⇒ Object
# === FtpParadise.connect.
-
.create_file(i) ⇒ Object
# === FtpParadise.create_file.
-
.data? ⇒ Boolean
# === FtpParadise.data?.
-
.delete(i) ⇒ Object
# === FtpParadise.delete (del tag).
-
.determine_user_dataset_from_this_hash(i, optional_use_this_entry = nil) ⇒ Object
# === FtpParadise.determine_user_dataset_from_this_hash.
-
.disable_colours ⇒ Object
# === FtpParadise.disable_colours.
-
.do_login(use_this_as_the_remote_url = nil, user = :default, passwd = :default_or_nil, acct = nil) ⇒ Object
# === FtpParadise.do_login (login tag).
-
.do_start_the_gui ⇒ Object
# === FtpParadise.do_start_the_gui.
-
.download(this_remote_file, use_this_ftp_object) ⇒ Object
# === FtpParadise.download ========================================================================= #.
-
.e(i = '') ⇒ Object
# === FtpParadise.e ========================================================================= #.
-
.ftp_object ⇒ Object
# === FtpParadise.ftp_object.
-
.get_files(from = '*') ⇒ Object
# === FtpParadise.get_files.
-
.getbinaryfile(a = 'nif.rb-0.91.gz', b = 'nif.gz', c = 1024) ⇒ Object
# === FtpParadise.getbinaryfile ========================================================================= #.
-
.gtk_widget ⇒ Object
-
.initialize ⇒ Object
# === FtpParadise.initialize.
-
.initialize_ftp_object(use_this_url = nil) ⇒ Object
# === FtpParadise.initialize_ftp_object.
-
.is_directory?(i, connect_to_this_host = :shevy) ⇒ Boolean
# === FtpParadise.is_directory?.
-
.is_on_roebe? ⇒ Boolean
# === FtpParadise.is_on_roebe? ========================================================================= #.
-
.lightyellow(i = '') ⇒ Object
# === FtpParadise.lightyellow ========================================================================= #.
-
.list(i = 'n*') ⇒ Object
# === FtpParadise.list ========================================================================= #.
-
.login_name? ⇒ Boolean
# === FtpParadise.login_name? ========================================================================= #.
-
.mlsd(pathname = nil) ⇒ Object
# === FtpParadise.mlsd.
-
.my_ftp_file? ⇒ Boolean
# === FtpParadise.my_ftp_file?.
-
.new(remote_host = :default, run_already = FtpParadise::Connection::RUN_ALREADY, &block) ⇒ Object
# === FtpParadise.new.
-
.opn(i = { namespace: NAMESPACE }) ⇒ Object
# === FtpParadise.opn ========================================================================= #.
-
.password? ⇒ Boolean
# === FtpParadise.password? ========================================================================= #.
-
.port? ⇒ Boolean
# === FtpParadise.port? ========================================================================= #.
-
.project_base_dir? ⇒ Boolean
# === FtpParadise.project_base_dir? ========================================================================= #.
-
.project_yaml_dir? ⇒ Boolean
# === FtpParadise.project_yaml_dir?.
-
.rds(i) ⇒ Object
# === FtpParadise.rds.
-
.remote_host? ⇒ Boolean
# === FtpParadise.remote_host? ========================================================================= #.
-
.remote_mkdir(create_this_remote_directory, connection = @ftp_object, connect_to_this_host = :shevy) ⇒ Object
# === FtpParadise.remote_mkdir.
-
.remote_url? ⇒ Boolean
# === FtpParadise.remote_url?.
-
.require_the_toplevel_methods ⇒ Object
# === FtpParadise.require_the_toplevel_methods ========================================================================= #.
-
.return_date ⇒ Object
# === FtpParadise.return_date.
-
.return_pwd ⇒ Object
# === FtpParadise.return_pwd ========================================================================= #.
-
.return_time ⇒ Object
# === FtpParadise.return_time.
-
.royalblue(i = '') ⇒ Object
# === FtpParadise.royalblue ========================================================================= #.
-
.sdir(i = '') ⇒ Object
# === FtpParadise.sdir ========================================================================= #.
-
.set_login_name(i = :try_to_infer_automatically, use_this_entry_point = 'bplaced') ⇒ Object
# === FtpParadise.set_login_name ========================================================================= #.
-
.set_password(i = :try_to_infer_automatically) ⇒ Object
# === FtpParadise.set_password ========================================================================= #.
-
.set_port(i = :try_to_infer_automatically) ⇒ Object
# === FtpParadise.set_port ========================================================================= #.
-
.set_remote_url(i = :try_to_infer) ⇒ Object
# === FtpParadise.set_remote_url.
-
.sfancy(i, use_colours = use_colours?) ) ⇒ Object
# === FtpParadise.sfancy ========================================================================= #.
-
.sfile(i, use_colours = use_colours?) ) ⇒ Object
# === FtpParadise.sfile ========================================================================= #.
-
.shell(i = ARGV) ⇒ Object
# === FtpParadise.shell.
-
.show_list ⇒ Object
# === FtpParadise.show_list.
-
.simp(i, use_colours = use_colours?) ) ⇒ Object
# === FtpParadise.simp ========================================================================= #.
-
.slateblue(i = '') ⇒ Object
# === FtpParadise.slateblue ========================================================================= #.
-
.swarn(i = '') ⇒ Object
# === FtpParadise.swarn ========================================================================= #.
-
.testing_colours ⇒ Object
# === FtpParadise.testing_colours (colour test, testing colours).
-
.upload(local_target, remote_target = :short_variant, use_this_ftp_object = :shevy, &block) ⇒ Object
# === FtpParadise.upload.
-
.upload_this_binary_file(file, be_verbose = :be_silent, use_this_as_ftp_object = nil) ⇒ Object
# === FtpParadise.upload_this_binary_file.
-
.use_colours? ⇒ Boolean
# === FtpParadise.use_colours?.
-
.use_this_as_ftp_object(i) ⇒ Object
# === FtpParadise.use_this_as_ftp_object.
Instance Method Summary
collapse
-
#return_date ⇒ Object
# === return_date ========================================================================= #.
-
#return_time ⇒ Object
# === return_time ========================================================================= #.
-
#rev ⇒ Object
# === rev ========================================================================= #.
-
#sdir(i) ⇒ Object
# === sdir ========================================================================= #.
-
#sfancy(i) ⇒ Object
# === sfancy ========================================================================= #.
-
#sfile(i) ⇒ Object
# === sfile ========================================================================= #.
-
#simp(i) ⇒ Object
# === simp ========================================================================= #.
-
#swarn(i) ⇒ Object
# === swarn ========================================================================= #.
-
#use_colours? ⇒ Boolean
# === use_colours?.
-
#yaml_directory? ⇒ Boolean
# === yaml_directory? ========================================================================= #.
Class Method Details
.can_connect_to_remote_site? ⇒ Boolean
#
FtpParadise.can_connect_to_remote_site?
This method can be used to query whether we can connect to a remote website via the FtpParadise project.
The method will return a boolean: either true or false.
#
24
25
26
27
28
29
|
# File 'lib/ftp_paradise/toplevel_methods/misc.rb', line 24
def self.can_connect_to_remote_site?
require 'ftp_paradise/connection/connection.rb'
ftp = FtpParadise::Connection.new(:dont_run_yet) { :use_default_dataset }
ftp.be_quiet
return ftp.is_connected?
end
|
.chdir(i) ⇒ Object
#
FtpParadise.chdir (cd tag)
Change directory through this method here.
Usage Example:
FtpParadise.chdir('pub/lang/ruby/contrib')
FtpParadise.cd('pub/lang/ruby/contrib')
#
190
191
192
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 190
def self.chdir(i)
@ftp_object.chdir(i)
end
|
.clear_user_dataset ⇒ Object
#
FtpParadise.clear_user_dataset
This method will reset the user-dataset to nil again, that is, user name, password and remote url.
This method had to be added so that we can easily clean-up on a disconnect-action.
#
.close ⇒ Object
127
128
129
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 127
def self.close
@ftp_object.close
end
|
.config? ⇒ Boolean
#
FtpParadise.config?
Query method towards the Configuration object.
#
48
49
50
|
# File 'lib/ftp_paradise/configuration/configuration.rb', line 48
def self.config?
@configuration
end
|
.connect(where_to = {}) ⇒ Object
#
FtpParadise.connect
To use this convenient connection-method, do this:
_ = FtpParadise.connect to: :shevy
#
17
18
19
20
21
22
23
24
|
# File 'lib/ftp_paradise/toplevel_methods/connect.rb', line 17
def self.connect(
where_to = {}
)
if where_to.is_a? Hash
require 'ftp_paradise/connection/connection.rb'
FtpParadise::Connection.new(where_to) end
end
|
.create_file(i) ⇒ Object
#
FtpParadise.create_file
Create a local file, via .touch().
#
32
33
34
|
# File 'lib/ftp_paradise/toplevel_methods/file_related_actions.rb', line 32
def self.create_file(i)
FileUtils.touch(i)
end
|
.data? ⇒ Boolean
#
FtpParadise.data?
This method will return the name of the user; the password; and the remote URL. It is mostly just a convenience method.
#
.delete(i) ⇒ Object
#
FtpParadise.delete (del tag)
Consistently use this method if you wish to delete a (local) file.
#
153
154
155
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 153
def self.delete(i)
FtpParadise.ftp_object.delete(i)
end
|
.determine_user_dataset_from_this_hash(i, optional_use_this_entry = nil) ⇒ Object
#
FtpParadise.determine_user_dataset_from_this_hash
This method can set relevant entries from an input Hash.
The IDs should be ‘url’, ‘user_name’, ‘password’ and ‘port’.
Usage example:
FtpParadise.determine_user_dataset_from_this_hash(YAML.load_file(FtpParadise.my_yaml_file), :default)
#
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/ftp_paradise/toplevel_methods/dataset.rb', line 58
def self.determine_user_dataset_from_this_hash(
i, optional_use_this_entry = nil
)
case optional_use_this_entry
when :default
optional_use_this_entry = 'bplaced'
end
if i.is_a? Hash
if optional_use_this_entry and i.has_key?(optional_use_this_entry)
i = i[optional_use_this_entry]
end
if i.has_key? 'url'
_ = i.fetch('url')
FtpParadise.set_remote_url(_)
end
if i.has_key? 'user_name'
_ = i.fetch('user_name')
FtpParadise.set_user_name(_)
end
if i.has_key? 'password'
_ = i.fetch('password')
FtpParadise.set_password(_)
end
if i.has_key? 'port'
_ = i.fetch('port')
FtpParadise.set_port(_)
end
return main_hash? end
end
|
.disable_colours ⇒ Object
#
FtpParadise.disable_colours
Use this method to disable colours.
#
49
50
51
|
# File 'lib/ftp_paradise/colours/use_colours.rb', line 49
def self.disable_colours
FtpParadise.config?.use_colours = false
end
|
.do_login(use_this_as_the_remote_url = nil, user = :default, passwd = :default_or_nil, acct = nil) ⇒ Object
#
FtpParadise.do_login (login tag)
This method combines setting the remote URL, before doing the login action.
#
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 51
def self.do_login(
use_this_as_the_remote_url = nil,
user = :default,
passwd = :default_or_nil,
acct = nil
)
if use_this_as_the_remote_url and FtpParadise.ftp_object?.nil?
FtpParadise.set_remote_url(use_this_as_the_remote_url)
end
case use_this_as_the_remote_url
when :bytehost
FtpParadise.set_remote_url(:infer)
use_this_as_the_remote_url = remote_url?
end
case user
when :default
if is_on_roebe?
set_login_name(:infer)
user = login_name?
else
user = 'anonymous'
end
end
case passwd
when :default_or_nil
if is_on_roebe?
set_password(:infer)
passwd = password?
else
passwd = nil
end
end
@ftp_object.login(
user, passwd, acct
) return @ftp_object end
|
.do_start_the_gui ⇒ Object
#
FtpParadise.do_start_the_gui
This will output what will be done, then start the GUI bindings.
This method can be invoked via:
ftpparadise --gui
#
1177
1178
1179
1180
|
# File 'lib/ftp_paradise/gui/gtk3/ftp_client/ftp_client.rb', line 1177
def self.do_start_the_gui
opnn; puts 'We will next start the GUI.'
FtpParadise::GUI::Gtk::FtpClient.run(ARGV)
end
|
.download(this_remote_file, use_this_ftp_object) ⇒ Object
68
69
70
71
72
73
74
75
|
# File 'lib/ftp_paradise/toplevel_methods/upload_and_download.rb', line 68
def self.download(
this_remote_file,
use_this_ftp_object
)
use_this_ftp_object.gettextfile(
this_remote_file
)
end
|
.e(i = '') ⇒ Object
12
13
14
|
# File 'lib/ftp_paradise/toplevel_methods/e.rb', line 12
def self.e(i = '')
puts i
end
|
.ftp_object ⇒ Object
#
FtpParadise.ftp_object
Reader method to return the @ftp_object.
This method should ideally come last in this .rb file.
#
202
203
204
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 202
def self.ftp_object
@ftp_object
end
|
.get_files(from = '*') ⇒ Object
#
FtpParadise.get_files
Use this method whenever you want to get all (local) files.
By default, this method will return all files from the current directory.
#
19
20
21
22
23
24
25
|
# File 'lib/ftp_paradise/toplevel_methods/file_related_actions.rb', line 19
def self.get_files(
from = '*'
)
entries = Dir[from]
entries.select! {|entry| File.file?(entry) }
return entries
end
|
.getbinaryfile(a = 'nif.rb-0.91.gz', b = 'nif.gz', c = 1024) ⇒ Object
#
FtpParadise.getbinaryfile
#
160
161
162
163
164
165
166
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 160
def self.getbinaryfile(
a = 'nif.rb-0.91.gz',
b = 'nif.gz',
c = 1024
)
@ftp_object.getbinaryfile(a,b,c)
end
|
#
This method will return a useable GTK widget that can be embedded into other applications.
#
1189
1190
1191
|
# File 'lib/ftp_paradise/gui/gtk3/ftp_client/ftp_client.rb', line 1189
def self.gtk_widget
FtpParadise::GUI::Gtk::FtpClient
end
|
.initialize ⇒ Object
#
FtpParadise.initialize
This method will assign to the general configuration object stored in the variable @configuration.
#
28
29
30
31
32
33
34
35
36
|
# File 'lib/ftp_paradise/configuration/configuration.rb', line 28
def self.initialize
if Object.const_defined? :Roebe
use_this_directory = FtpParadise.yaml_directory?
@configuration = ::Roebe::Configuration.new(use_this_directory)
end
end
|
.initialize_ftp_object(use_this_url = nil) ⇒ Object
#
FtpParadise.initialize_ftp_object
Use this method if you wish to initialize a new FTP object. This will be, by default, a blank-state initializer.
#
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 33
def self.initialize_ftp_object(use_this_url = nil)
case use_this_url
when :default
use_this_url = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['url']
end
@ftp_object = Net::FTP.new(use_this_url)
return @ftp_object
end
|
.is_directory?(i, connect_to_this_host = :shevy) ⇒ Boolean
#
FtpParadise.is_directory?
This will return a boolean - true if the remote target is a directory and false otherwise.
By default this method will connect to the :shevy host.
#
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/ftp_paradise/toplevel_methods/directory_related_actions.rb', line 17
def self.is_directory?(
i,
connect_to_this_host = :shevy
)
require 'ftp_paradise/connection/connection.rb'
FtpParadise::Connection.new(
i,
connect_to_this_host: connect_to_this_host
).is_a_directory?(i)
end
|
.is_on_roebe? ⇒ Boolean
#
FtpParadise.is_on_roebe?
#
12
13
14
|
# File 'lib/ftp_paradise/toplevel_methods/is_on_roebe.rb', line 12
def self.is_on_roebe?
ENV['IS_ROEBE'].to_s == '1'
end
|
.lightyellow(i = '') ⇒ Object
#
FtpParadise.lightyellow
#
75
76
77
78
79
80
|
# File 'lib/ftp_paradise/colours/colours.rb', line 75
def self.lightyellow(i = '')
if use_colours?
return ::Colours.lightyellow(i)
end
return "#{Colours.yellow}#{i}#{Colours.rev}"
end
|
.list(i = 'n*') ⇒ Object
120
121
122
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 120
def self.list(i = 'n*')
@ftp_object.list(i)
end
|
.login_name? ⇒ Boolean
#
FtpParadise.login_name?
#
20
21
22
|
# File 'lib/ftp_paradise/toplevel_methods/login_name.rb', line 20
def self.login_name?
@login_name
end
|
.mlsd(pathname = nil) ⇒ Object
#
FtpParadise.mlsd
This method will return an Array of the entries of the directory specified by pathname.
Each entry has the facts (e.g., size, last modification time, etc.) and the pathname. If a block is given, it iterates through the listing.
If pathname is omitted, the current directory is assumed.
#
142
143
144
145
146
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 142
def self.mlsd(
pathname = nil
)
@ftp_object.mlsd(pathname)
end
|
.my_ftp_file? ⇒ Boolean
#
FtpParadise.my_ftp_file?
Feedback where my custom ftp file is.
#
93
94
95
|
# File 'lib/ftp_paradise/constants/constants.rb', line 93
def self.my_ftp_file?
FILE_ROEBE_FTP
end
|
.new(remote_host = :default, run_already = FtpParadise::Connection::RUN_ALREADY, &block) ⇒ Object
#
FtpParadise.new
Module-method to create a new Connection object.
#
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ftp_paradise/toplevel_methods/connect.rb', line 31
def self.new(
remote_host = :default,
run_already = FtpParadise::Connection::RUN_ALREADY,
&block
)
case remote_host
when :dont_run_yet
remote_host = :default
run_already = false
end
if remote_host.is_a? Symbol
run_already = remote_host
end
require 'ftp_paradise/connection/connection.rb'
FtpParadise::Connection.new(
remote_host, run_already, &block
)
end
|
.opn(i = { namespace: NAMESPACE }) ⇒ Object
18
19
20
21
22
|
# File 'lib/ftp_paradise/toplevel_methods/opn.rb', line 18
def self.opn(
i = { namespace: NAMESPACE }
)
Opn.opn(i) if Object.const_defined? :Opn
end
|
.password? ⇒ Boolean
#
FtpParadise.password?
#
24
25
26
|
# File 'lib/ftp_paradise/toplevel_methods/password.rb', line 24
def self.password?
@password
end
|
.port? ⇒ Boolean
35
36
37
|
# File 'lib/ftp_paradise/toplevel_methods/port.rb', line 35
def self.port?
@port
end
|
.project_base_dir? ⇒ Boolean
#
FtpParadise.project_base_dir?
#
17
18
19
|
# File 'lib/ftp_paradise/project/project.rb', line 17
def self.project_base_dir?
PROJECT_BASE_DIRECTORY
end
|
.project_yaml_dir? ⇒ Boolean
#
FtpParadise.project_yaml_dir?
This method here must be defined before FtpParadise.initialize() is to be invoked.
#
37
38
39
|
# File 'lib/ftp_paradise/project/project.rb', line 37
def self.project_yaml_dir?
"#{PROJECT_BASE_DIRECTORY}yaml/"
end
|
.rds(i) ⇒ Object
#
FtpParadise.rds
Use this method to remove double ‘//’ entry.
#
14
15
16
|
# File 'lib/ftp_paradise/toplevel_methods/rds.rb', line 14
def self.rds(i)
i.squeeze '/'
end
|
.remote_host? ⇒ Boolean
#
FtpParadise.remote_host?
#
171
172
173
174
175
176
177
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 171
def self.remote_host?
if @ftp_object
@ftp_object.remote_host?
else
nil
end
end
|
.remote_mkdir(create_this_remote_directory, connection = @ftp_object, connect_to_this_host = :shevy) ⇒ Object
#
FtpParadise.remote_mkdir
This method will create a remote directory. Make sure to have a valid (active) FTP connection before you invoke this method.
#
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 225
def self.remote_mkdir(
create_this_remote_directory,
connection = @ftp_object,
connect_to_this_host = :shevy
)
if create_this_remote_directory.is_a? Array
create_this_remote_directory.each {|name_of_the_remote_directory|
remote_mkdir(
name_of_the_remote_directory,
connection,
connect_to_this_host
)
}
else
create_this_remote_directory = create_this_remote_directory.to_s
if connection.nil?
require 'ftp_paradise/connection/connection.rb'
connection = FtpParadise::Connection.new(connect_to_this_host) { :do_not_run_yet }
connection.be_silent
connection.do_login
end
begin
connection.mkdir(create_this_remote_directory)
rescue Net::FTPPermError => error
pp error
e "No directory called #{create_this_remote_directory}/ could be created"
e 'as such a (remote) directory already exists.'
end
end
end
|
.remote_url? ⇒ Boolean
#
FtpParadise.remote_url?
Return the @remote_url variable.
#
25
26
27
|
# File 'lib/ftp_paradise/toplevel_methods/remote_url.rb', line 25
def self.remote_url?
@remote_url
end
|
.require_the_toplevel_methods ⇒ Object
#
FtpParadise.require_the_toplevel_methods
#
14
15
16
17
18
|
# File 'lib/ftp_paradise/requires/require_the_toplevel_methods.rb', line 14
def self.require_the_toplevel_methods
Dir["#{PROJECT_BASE_DIRECTORY}toplevel_methods/*.rb"].each {|this_file|
require this_file
}
end
|
.return_date ⇒ Object
#
FtpParadise.return_date
This method will return a String such as “03.12.2014”.
#
14
15
16
|
# File 'lib/ftp_paradise/toplevel_methods/time.rb', line 14
def self.return_date
Time.now.strftime('%d.%m.%Y')
end
|
.return_pwd ⇒ Object
#
FtpParadise.return_pwd
#
12
13
14
|
# File 'lib/ftp_paradise/toplevel_methods/misc.rb', line 12
def self.return_pwd
return ("#{Dir.pwd}/").squeeze('/')
end
|
.return_time ⇒ Object
#
FtpParadise.return_time
This method will return a String such as “15:55:30”.
#
30
31
32
|
# File 'lib/ftp_paradise/toplevel_methods/time.rb', line 30
def self.return_time
Time.now.strftime('%H:%M:%S')
end
|
.royalblue(i = '') ⇒ Object
#
FtpParadise.royalblue
#
85
86
87
88
89
90
|
# File 'lib/ftp_paradise/colours/colours.rb', line 85
def self.royalblue(i = '')
if use_colours?
return ::Colours.royalblue(i)
end
return i
end
|
.sdir(i = '') ⇒ Object
24
25
26
27
|
# File 'lib/ftp_paradise/colours/colours.rb', line 24
def self.sdir(i = '')
return Colours.sdir(i) if use_colours?
return i
end
|
.set_login_name(i = :try_to_infer_automatically, use_this_entry_point = 'bplaced') ⇒ Object
#
FtpParadise.set_login_name
#
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/ftp_paradise/toplevel_methods/login_name.rb', line 27
def self.set_login_name(
i = :try_to_infer_automatically,
use_this_entry_point = 'bplaced'
)
case i
when :try_to_infer_automatically,
:infer
if File.exist? FILE_ROEBE_FTP
i = YAML.load_file(FILE_ROEBE_FTP)[use_this_entry_point]['user_name']
end
end
@login_name = i
end
|
.set_password(i = :try_to_infer_automatically) ⇒ Object
#
FtpParadise.set_password
#
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/ftp_paradise/toplevel_methods/password.rb', line 31
def self.set_password(
i = :try_to_infer_automatically
)
case i
when :try_to_infer_automatically,
:infer
if File.exist? FILE_ROEBE_FTP
i = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['password']
end
end
@password = i
end
|
.set_port(i = :try_to_infer_automatically) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/ftp_paradise/toplevel_methods/port.rb', line 17
def self.set_port(
i = :try_to_infer_automatically
)
case i
when :try_to_infer_automatically
if File.exist? FILE_ROEBE_FTP
i = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['port']
end
end
@port = i
end
|
.set_remote_url(i = :try_to_infer) ⇒ Object
#
FtpParadise.set_remote_url
Setter-method for @remote_url. Will be nil initially.
#
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/ftp_paradise/toplevel_methods/remote_url.rb', line 34
def self.set_remote_url(
i = :try_to_infer
)
case i
when :try_to_infer,
:infer,
nil
if is_on_roebe?
if File.exist? FILE_ROEBE_FTP
i = YAML.load_file(FILE_ROEBE_FTP)['bplaced']['url']
end
end
end
@remote_url = i
end
|
.sfancy(i, use_colours = use_colours?)
) ⇒ Object
116
117
118
119
|
# File 'lib/ftp_paradise/colours/colours.rb', line 116
def self.sfancy(i, use_colours = use_colours?)
return Colours.sfancy(i) if use_colours return i
end
|
.sfile(i, use_colours = use_colours?)
) ⇒ Object
132
133
134
135
|
# File 'lib/ftp_paradise/colours/colours.rb', line 132
def self.sfile(i, use_colours = use_colours?)
return Colours.sfile(i,) if use_colours
return i
end
|
.shell(i = ARGV) ⇒ Object
#
FtpParadise.shell
This is a convenience method to instantiate a new class FtpParadise::Shell instance.
#
2313
2314
2315
|
# File 'lib/ftp_paradise/shell/shell.rb', line 2313
def self.shell(i = ARGV)
FtpParadise::Shell.new(i)
end
|
.show_list ⇒ Object
#
FtpParadise.show_list
By default this method will exclude the ‘.’ and ‘..’ entries.
#
212
213
214
215
216
217
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 212
def self.show_list
result = @ftp_object.list
result.each {|line|
e line unless line.end_with? '.'
}
end
|
.simp(i, use_colours = use_colours?)
) ⇒ Object
124
125
126
127
|
# File 'lib/ftp_paradise/colours/colours.rb', line 124
def self.simp(i, use_colours = use_colours?)
return Colours.simp(i) if use_colours return i
end
|
.slateblue(i = '') ⇒ Object
#
FtpParadise.slateblue
#
95
96
97
98
99
100
|
# File 'lib/ftp_paradise/colours/colours.rb', line 95
def self.slateblue(i = '')
if use_colours?
return ::Colours.slateblue(i)
end
return i
end
|
.swarn(i = '') ⇒ Object
32
33
34
35
|
# File 'lib/ftp_paradise/colours/colours.rb', line 32
def self.swarn(i = '')
return Colours.swarn(i) if use_colours?
return i
end
|
.testing_colours ⇒ Object
#
FtpParadise.testing_colours (colour test, testing colours)
This just is a test whether we use colours or whether we won’t.
#
107
108
109
110
111
|
# File 'lib/ftp_paradise/colours/colours.rb', line 107
def self.testing_colours
e 'We will now test some colours.'
e "Will we use colours? #{FtpParadise.use_colours?.to_s}"
e 'Testing '+sfancy('sfancy')+' next.'
end
|
.upload(local_target, remote_target = :short_variant, use_this_ftp_object = :shevy, &block) ⇒ Object
#
FtpParadise.upload
This toplevel-method can be used to upload something to a remote target.
The second argument called ‘to` will tell us where to upload to.
#
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/ftp_paradise/toplevel_methods/upload_and_download.rb', line 85
def self.upload(
local_target,
remote_target = :short_variant,
use_this_ftp_object = :shevy,
&block
)
case remote_target
when :short_variant
remote_target = File.basename(local_target)
end
if use_this_ftp_object.is_a? Symbol
require 'ftp_paradise/connection/connection.rb'
use_this_ftp_object = FtpParadise::Connection.new(:dont_run_yet)
opn; e "We will now connect to #{sfancy(use_this_ftp_object.to_s)}."
use_this_ftp_object.connect_to
use_this_ftp_object.upload(local_target)
end
use_this_ftp_object.put(
local_target,
remotefile = File.basename(localfile),
&block
)
end
|
.upload_this_binary_file(file, be_verbose = :be_silent, use_this_as_ftp_object = nil) ⇒ Object
#
FtpParadise.upload_this_binary_file
This method shall allow you to upload a binary file to a remote host.
For now, this has my FTP information hardcoded.
Usage examples:
FtpParadise.upload_this_binary_file("/home/x/src/htop/htop-2.0.2.tar.xz")
FtpParadise.upload_this_binary_file("/home/x/src/htop/htop-2.0.2.tar.xz") {{ cd_into_this_directory: 'htdocs/' }}
FtpParadise.upload_this_binary_file("/home/x/src/htop/htop-2.0.2.tar.xz") {{ cd_into_this_directory: 'www/' }}
upload_this_binary_file /home/x/src/htop/htop-2.0.2.tar.xz
upload_this_binary_file /home/x/src/htop/htop-2.0.2.tar.xz
#
.use_colours? ⇒ Boolean
#
FtpParadise.use_colours?
This can be delegated towards the configuration object.
#
35
36
37
38
39
40
41
42
|
# File 'lib/ftp_paradise/colours/use_colours.rb', line 35
def self.use_colours?
if FtpParadise.respond_to?(:config?) and
FtpParadise.config?.respond_to?(:use_colours)
FtpParadise.config?.use_colours
else
true
end
end
|
.use_this_as_ftp_object(i) ⇒ Object
#
FtpParadise.use_this_as_ftp_object
Assignment to a new FTP object can come through this method.
#
112
113
114
|
# File 'lib/ftp_paradise/toplevel_methods/ftp_object.rb', line 112
def self.use_this_as_ftp_object(i)
@ftp_object = i
end
|
Instance Method Details
#rev ⇒ Object
16
17
18
19
|
# File 'lib/ftp_paradise/colours/colours.rb', line 16
def rev
return Colours.rev if use_colours?
return ''
end
|
#sdir(i) ⇒ Object
54
55
56
|
# File 'lib/ftp_paradise/colours/colours.rb', line 54
def sdir(i)
FtpParadise.sdir(i)
end
|
#simp(i) ⇒ Object
47
48
49
|
# File 'lib/ftp_paradise/colours/colours.rb', line 47
def simp(i) FtpParadise.simp(i) end
|
#use_colours? ⇒ Boolean
#
use_colours?
Whether we will use colours or whether we will not.
#
#yaml_directory? ⇒ Boolean
44
45
46
|
# File 'lib/ftp_paradise/project/project.rb', line 44
def yaml_directory?
FtpParadise.yaml_directory?
end
|