module FtpParadise

#

require 'ftp_paradise/base/cliner.rb'

#
#

require 'ftp_paradise/base/colours.rb'

#
#

require 'ftp_paradise/base/reset.rb'

#
#

This file will add colour-related methods to the ftp_paradise project.

#

require 'ftp_paradise/colours/colours.rb'

#
#

require 'ftp_paradise/colours/use_colours.rb'

#
#

require 'ftp_paradise/configuration/configuration.rb'

#
#

require 'ftp_paradise/connection/constants.rb'

#
#

require 'ftp_paradise/connection/data.rb'

#
#

require 'ftp_paradise/connection/debug.rb'

#
#

require 'ftp_paradise/connection/directory_handling.rb'

#
#

require 'ftp_paradise/connection/do_login.rb'

#
#

require 'ftp_paradise/connection/download.rb'

#
#

require 'ftp_paradise/connection/file_handling.rb'

#
#

require 'ftp_paradise/connection/ftp_object.rb'

#
#

require 'ftp_paradise/connection/initialize.rb'

#
#

require 'ftp_paradise/connection/initialize_a_new_net_ftp_object_with_this_url.rb'

#
#

require 'ftp_paradise/connection/is_connected.rb'

#
#

require 'ftp_paradise/connection/misc.rb'

#
#

require 'ftp_paradise/connection/notify.rb'

#
#

require 'ftp_paradise/connection/password.rb'

#
#

require 'ftp_paradise/connection/port.rb'

#
#

require 'ftp_paradise/connection/remote_pwd.rb'

#
#

require 'ftp_paradise/connection/remote_url.rb'

#
#

require 'ftp_paradise/connection/remove.rb'

#
#

require 'ftp_paradise/connection/reset.rb'

#
#

require 'ftp_paradise/connection/run.rb'

#
#

require 'ftp_paradise/connection/set_array_available_hosts.rb'

#
#

require 'ftp_paradise/connection/set_input.rb'

#
#

require 'ftp_paradise/connection/show.rb'

#
#

require 'ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb'

#
#

require 'ftp_paradise/connection/transfer_mode.rb'

#
#

require 'ftp_paradise/connection/upload.rb'

#
#

require 'ftp_paradise/connection/use_default_dataset.rb'

#
#

require 'ftp_paradise/connection/username.rb'

#
#

require 'ftp_paradise/constants/constants.rb'

#
#

require 'ftp_paradise/constants/misc.rb'

#
#

require 'ftp_paradise/constants/namespace.rb'

#
#

require 'ftp_paradise/constants/newline.rb'

#
#

require 'ftp_paradise/constants/roebe.rb' FILE_ROEBE_FTP HOME_DIRECTOY_OF_USER_X

#
#

require 'ftp_paradise/constants/roebe_ftp_constants.rb' include FtpParadise::RoebeFtpConstants

#
#

FtpParadise::Entry

This class is sort of similar to class Net::FTP::List::Entry.

We want to parse a FTP entry into corresponding slots on the object.

The input should be an individual line from a remote Net::FTP object.

The output would be an object such as:

<FtpParadise::Entry:0x000055561f61b370 @basename="usher-0.0.12.gem", @filesize=2048, @mtime=2014-10-25 00:00:00 +0200, @raw="-rw-r--r--    1 330        330              6144 Dec 27  2015 usher-0.0.12.gem", @server_type="Unix", @symlink=false, @dir=true, @file=false, @device=false, @splitted=["-rw-r--r--", "1", "330", "330", "6144", "Dec", "27", "2015", "usher-0.0.12.gem"]
#

require 'ftp_paradise/entry/entry.rb' FtpParadise::Entry.new

#
#

FtpParadise::GUI::Gtk::FtpParadiseModule

The purpose of this class is to provide a GTK-FTP Client, loosely modelled after the client called “gftp”.

#

require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb' include ::FtpParadise::GUI::Gtk::FtpParadiseModule

#
#

All constants for class Interactive shall be stored in this file here.

#

require 'ftp_paradise/interactive_ftp/constants.rb'

#
#

require 'ftp_paradise/interactive_ftp/directory_handling.rb'

#
#

require 'ftp_paradise/interactive_ftp/help.rb'

#
#

require 'ftp_paradise/interactive_ftp/initialize.rb'

#
#

require 'ftp_paradise/interactive_ftp/main_loop.rb'

#
#

require 'ftp_paradise/interactive_ftp/menu.rb'

#
#

require 'ftp_paradise/interactive_ftp/misc.rb'

#
#

require 'ftp_paradise/interactive_ftp/mode.rb'

#
#

The Readline component will belong to class FtpParadise::InteractiveFtp.

It would not make any sense to use it elsewhere within the FtpParadise project, as we don't have other interactive elements elsewhere.

#

require 'ftp_paradise/interactive_ftp/readline.rb'

#
#

require 'ftp_paradise/interactive_ftp/remove.rb'

#
#

require 'ftp_paradise/interactive_ftp/reset.rb'

#
#

require 'ftp_paradise/interactive_ftp/run.rb'

#
#

require 'ftp_paradise/interactive_ftp/show.rb'

#
#

require 'ftp_paradise/interactive_ftp/upload.rb'

#
#

require 'ftp_paradise/interactive_ftp/user_input.rb'

#
#

require 'ftp_paradise/project/project.rb'

#
#

require 'ftp_paradise/requires/require_the_toplevel_methods.rb'

#
#

require 'ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb'

#
#

require 'ftp_paradise/toplevel_methods/clear_user_dataset.rb'

#
#

require 'ftp_paradise/toplevel_methods/connect.rb'

#
#

require 'ftp_paradise/toplevel_methods/data.rb'

#
#

require 'ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb'

#
#

require 'ftp_paradise/toplevel_methods/directory_related_actions.rb'

#
#

require 'ftp_paradise/toplevel_methods/e.rb'

#
#

require 'file_related_actions.rb'

#
#

require 'ftp_paradise/toplevel_methods/ftp_object.rb'

#
#

require 'ftp_paradise/toplevel_methods/is_on_roebe.rb'

#
#

require 'ftp_paradise/toplevel_methods/login_name.rb'

#
#

require 'ftp_paradise/toplevel_methods/misc.rb'

#
#

require 'ftp_paradise/toplevel_methods/opn.rb'

#
#

require 'ftp_paradise/toplevel_methods/password.rb'

#
#

require 'ftp_paradise/toplevel_methods/port.rb'

#
#

require 'ftp_paradise/toplevel_methods/rds.rb'

#
#

require 'ftp_paradise/toplevel_methods/remote_url.rb'

#
#

require 'ftp_paradise/toplevel_methods/time.rb'

#
#

require 'ftp_paradise/toplevel_methods/upload_and_download.rb' FtpParadise.download

#
#

require 'ftp_paradise/version/version.rb'

#

Constants

ARRAY_BINARY_FILES
#

ARRAY_BINARY_FILES

Just note down the extension names.

#
ARRAY_HELP_OPTIONS
#

ARRAY_HELP_OPTIONS

This Array is only required in the interactive variant though.

#
ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL
#

ARRAY_VALID_OPTIONS_FOR_EXITING_THE_SHELL

#
FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL
#

FtpParadise::FILE_AUTOMATICALLY_CONNECT_ON_STARTUP_OF_THE_INTERACTIVE_FTP_SHELL

#
FILE_ROEBE_FTP
#

FILE_ROEBE_FTP

In theory you could change this if you use a similar .yml file.

This will, on my home directory, expand to:

/home/x/DATA/PC/OS/LINUX/FTP/YAML/roebe_ftp.yml
#
HOME_DIRECTORY_OF_USER_X
#

HOME_DIRECTORY_OF_USER_X

This is also only useful on my home setup.

#
N
#

N

#
NAMESPACE
#

NAMESPACE

#
PROJECT_BASE_DIRECTORY
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.

#
SHALL_WE_DEBUG
#

SHALL_WE_DEBUG

#
VERSION
#

VERSION

#
YAML_DIRECTORY

Public Class Methods

can_connect_to_remote_site?() click to toggle source
#

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.

#
# File lib/ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb, line 17
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) click to toggle source
#

FtpParadise.chdir (cd tag)

Change directory through this method here.

Usage Example:

FtpParadise.chdir('pub/lang/ruby/contrib')
FtpParadise.cd('pub/lang/ruby/contrib')
#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 189
def self.chdir(i)
  @ftp_object.chdir(i)
end
clear_user_dataset() click to toggle source
#

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.

#
# File lib/ftp_paradise/toplevel_methods/clear_user_dataset.rb, line 22
def self.clear_user_dataset
  FtpParadise.set_remote_url(nil)
  FtpParadise.set_user_name(nil)
  FtpParadise.set_password(nil)
end
close() click to toggle source
#

FtpParadise.close

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 126
def self.close
  @ftp_object.close
end
config?() click to toggle source
#

FtpParadise.config?

Query method towards the Configuration object.

#
# File lib/ftp_paradise/configuration/configuration.rb, line 45
def self.config?
  @configuration
end
connect( where_to = {} ) click to toggle source
#

FtpParadise.connect

To use this convenient connection-method, do this:

_ = FtpParadise.connect to: :shevy
#
# 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) # This ought to be a Hash anyway.
  end
end
create_file(i) click to toggle source
#

FtpParadise.create_file

Create a local file, via .touch().

#
# File lib/ftp_paradise/toplevel_methods/file_related_actions.rb, line 31
def self.create_file(i)
  FileUtils.touch(i)
end
data?() click to toggle source
#

FtpParadise.data?

This method will return the name of the user; the password; and the remote URL. It is mostly just a convenience method.

#
# File lib/ftp_paradise/toplevel_methods/data.rb, line 19
def self.data?
  {
    user_name:  FtpParadise.username?,
    password:   FtpParadise.password?,
    remote_url: FtpParadise.remote_url?
  }
end
delete(i) click to toggle source
#

FtpParadise.delete (del tag)

Consistently use this method if you wish to delete a (local) file.

#
# File lib/ftp_paradise/toplevel_methods/file_related_actions.rb, line 40
def self.delete(i) # ← Added this method as of April 2014.
  i = i.to_s # We don't want nil-errors here.
  if File.exist? i
    File.delete(i)
  else
    e "No file at #{sfile(i)} appears to exist."
  end
end
determine_user_dataset_from_this_hash(i) click to toggle source
#

FtpParadise.determine_user_dataset_from_this_hash

This method can set relevant entries from an input Hash.

The IDs should be 'url', 'user_name' and 'password'.

#
# File lib/ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb, line 20
def self.determine_user_dataset_from_this_hash(i)
  if i.is_a? Hash
    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
  end
end
disable_colours() click to toggle source
#

FtpParadise.disable_colours

Use this method to disable colours.

#
# File lib/ftp_paradise/colours/use_colours.rb, line 44
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 ) click to toggle source
#

FtpParadise.do_login (login tag)

This method combines setting the remote URL, before doing the login action.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 50
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
  # ======================================================================= #
  # === :bytehost
  # ======================================================================= #
  when :bytehost
    FtpParadise.set_remote_url(:infer)
    use_this_as_the_remote_url = remote_url?
  end
  # ======================================================================= #
  # Sanitize the default user (user name aka login name).
  # ======================================================================= #
  case user
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    if is_on_roebe?
      set_login_name(:infer)
      user = login_name?
    else
      user = 'anonymous'
    end
  end
  # ======================================================================= #
  # Sanitize the given password next.
  # ======================================================================= #
  case passwd
  # ======================================================================= #
  # === :default_or_nil
  # ======================================================================= #
  when :default_or_nil
    if is_on_roebe?
      set_password(:infer)
      passwd = password?
    else
      passwd = nil
    end
  end
  # ======================================================================= #
  # puts "Debug: user name is: #{user} password is: #{passwd} account is: #{acct}"
  # ======================================================================= #
  @ftp_object.login(
    user, passwd, acct
  ) # Delegate to the main object here.
  return @ftp_object # And mandatory return here.
end
do_start_gui() click to toggle source
#

FtpParadise.do_start_gui

This will output what will be done, then start the GUI bindings.

This method can be invoked via:

ftpparadise --gui
#
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 687
def self.do_start_gui
  opnn; puts 'We will next start the GUI.'
  FtpParadise::GUI::Gtk::FtpParadiseModule.start_gtk
end
download( this_remote_file, use_this_ftp_object ) click to toggle source
#

FtpParadise.download

#
# File lib/ftp_paradise/toplevel_methods/upload_and_download.rb, line 67
def self.download(
    this_remote_file,
    use_this_ftp_object
  )
  use_this_ftp_object.gettextfile(
    this_remote_file
  )
end
e(i = '') click to toggle source
#

FtpParadise.e

#
# File lib/ftp_paradise/toplevel_methods/e.rb, line 12
def self.e(i = '')
  puts i
end
ftp_object() click to toggle source
#

FtpParadise.ftp_object

Reader method to return the @ftp_object.

This method should ideally come last in this .rb file.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 201
def self.ftp_object
  @ftp_object
end
get_files( from = '*' ) click to toggle source
#

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.

#
# File lib/ftp_paradise/toplevel_methods/file_related_actions.rb, line 18
def self.get_files(
    from = '*'
  )
  entries = Dir[from]
  entries.select! {|entry| File.file?(entry) }
  entries
end
getbinaryfile( a = 'nif.rb-0.91.gz', b = 'nif.gz', c = 1024 ) click to toggle source
#

FtpParadise.getbinaryfile

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 159
def self.getbinaryfile(
    a = 'nif.rb-0.91.gz',
    b = 'nif.gz',
    c = 1024
  )
  @ftp_object.getbinaryfile(a,b,c)
end
gtk_widget() click to toggle source
#

FtpParadise.gtk_widget

This method will return a useable GTK widget that can be embedded into other applications.

#
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 705
def self.gtk_widget
  FtpParadise::GUI::Gtk::FtpParadiseModule
end
initialize() click to toggle source
#

FtpParadise.initialize

This method will assign to the general configuration object stored in the variable @configuration.

#
# File lib/ftp_paradise/configuration/configuration.rb, line 26
def self.initialize
  if Object.const_defined? :Roebe
    # ===================================================================== #
    # Load up all .yml files from the path to the yaml directory:
    # ===================================================================== #
    @configuration = ::Roebe::Configuration::Configuration.new(FtpParadise.yaml_directory?)
  end
end
initialize_ftp_object(use_this_url = nil) click to toggle source
#

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.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 33
def self.initialize_ftp_object(use_this_url = nil)
  case use_this_url
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    use_this_url = YAML.load_file(FILE_ROEBE_FTP)['podserver']['url']
  end
  @ftp_object = Net::FTP.new(use_this_url)
end
is_directory?( i, connect_to_this_host = :shevy ) click to toggle source
#

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.

#
# 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?() click to toggle source
#

FtpParadise.is_on_roebe?

#
# 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 = '') click to toggle source
#

FtpParadise.lightyellow

#
# File lib/ftp_paradise/colours/colours.rb, line 99
def self.lightyellow(i = '')
  if use_colours?
    return ::Colours.lightyellow(i)
  end
  return "#{Colours.yellow}#{i}#{Colours.rev}"
end
list(i = 'n*') click to toggle source
#

FtpParadise.list

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 119
def self.list(i = 'n*')
  @ftp_object.list(i)
end
login_name?() click to toggle source
#

FtpParadise.login_name?

#
# File lib/ftp_paradise/toplevel_methods/login_name.rb, line 20
def self.login_name?
  @login_name
end
mlsd( pathname = nil ) click to toggle source
#

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.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 141
def self.mlsd(
    pathname = nil
  )
  @ftp_object.mlsd(pathname)
end
new( remote_host = :default, run_already = FtpParadise::Connection::RUN_ALREADY, &block ) click to toggle source
#

FtpParadise.new

Module-method to create a new Connection object.

#
# 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 } ) click to toggle source
#

FtpParadise.opn

#
# 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?() click to toggle source
#

FtpParadise.password?

#
# File lib/ftp_paradise/toplevel_methods/password.rb, line 24
def self.password?
  @password
end
port?() click to toggle source
#

FtpParadise.port?

#
# File lib/ftp_paradise/toplevel_methods/port.rb, line 32
def self.port?
  @port
end
project_base_dir?() click to toggle source
#

FtpParadise.project_base_dir?

#
# File lib/ftp_paradise/project/project.rb, line 28
def self.project_base_dir?
  PROJECT_BASE_DIRECTORY
end
project_yaml_dir?() click to toggle source
#

FtpParadise.project_yaml_dir?

This method here must be defined before FtpParadise.initialize() is to be invoked.

#
# File lib/ftp_paradise/project/project.rb, line 48
def self.project_yaml_dir?
  "#{PROJECT_BASE_DIRECTORY}yaml/"
end
rds(i) click to toggle source
#

FtpParadise.rds

Use this method to remove double '//' entry.

#
# File lib/ftp_paradise/toplevel_methods/rds.rb, line 14
def self.rds(i)
  i.squeeze '/'
end
remote_host?() click to toggle source
#

FtpParadise.remote_host?

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 170
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 ) click to toggle source
#

FtpParadise.remote_mkdir

This method will create a remote directory. Make sure to have a valid (active) FTP connection before you invoke this method.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 224
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?() click to toggle source
#

FtpParadise.remote_url?

Return the @remote_url variable.

#
# File lib/ftp_paradise/toplevel_methods/remote_url.rb, line 21
def self.remote_url?
  @remote_url
end
require_the_toplevel_methods() click to toggle source
#

FtpParadise.require_the_toplevel_methods

#
# File lib/ftp_paradise/requires/require_the_toplevel_methods.rb, line 13
def self.require_the_toplevel_methods
  Dir["#{PROJECT_BASE_DIRECTORY}toplevel_methods/*.rb"].each {|this_file|
    require this_file
  }
end
return_date() click to toggle source
#

FtpParadise.return_date

This method will return a String such as “03.12.2014”.

#
# File lib/ftp_paradise/toplevel_methods/time.rb, line 14
def self.return_date
  Time.now.strftime('%d.%m.%Y')
end
return_pwd() click to toggle source
#

FtpParadise.return_pwd

#
# File lib/ftp_paradise/toplevel_methods/misc.rb, line 12
def self.return_pwd
  return ("#{Dir.pwd}/").squeeze('/')
end
return_time() click to toggle source
#

FtpParadise.return_time

This method will return a String such as “15:55:30”.

#
# File lib/ftp_paradise/toplevel_methods/time.rb, line 30
def self.return_time
  Time.now.strftime('%H:%M:%S')
end
royalblue(i = '') click to toggle source
#

FtpParadise.royalblue

#
# File lib/ftp_paradise/colours/colours.rb, line 109
def self.royalblue(i = '')
  if use_colours?
    return ::Colours.royalblue(i)
  end
  return i
end
sdir(i) click to toggle source
#

FtpParadise.sdir

#
# File lib/ftp_paradise/colours/colours.rb, line 24
def self.sdir(i)
  return Colours.sdir(i) if use_colours?
  i
end
set_login_name( i = :try_to_infer_automatically ) click to toggle source
#

FtpParadise.set_login_name

#
# File lib/ftp_paradise/toplevel_methods/login_name.rb, line 27
def self.set_login_name(
    i = :try_to_infer_automatically
  )
  case i
  # ======================================================================= #
  # === :try_to_infer_automatically
  # ======================================================================= #
  when :try_to_infer_automatically,
       :infer
    if File.exist? FILE_ROEBE_FTP
      i = YAML.load_file(FILE_ROEBE_FTP)['podserver']['user_name']
    end
  end
  @login_name = i
end
set_password( i = :try_to_infer_automatically ) click to toggle source
#

FtpParadise.set_password

#
# File lib/ftp_paradise/toplevel_methods/password.rb, line 31
def self.set_password(
    i = :try_to_infer_automatically
  )
  case i
  # === :try_to_infer_automatically
  when :try_to_infer_automatically,
       :infer
    if File.exist? FILE_ROEBE_FTP
      i = YAML.load_file(FILE_ROEBE_FTP)['bytehost']['password']
    end
  end
  @password = i
end
set_port( i = :try_to_infer_automatically ) click to toggle source
#

FtpParadise.set_port

#
# 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)['podcast']['port']
    end
  end
  @port = i
end
set_remote_url( i = :try_to_infer ) click to toggle source
#

FtpParadise.set_remote_url

Setter-method for @remote_url. Will be nil initially.

#
# File lib/ftp_paradise/toplevel_methods/remote_url.rb, line 33
def self.set_remote_url(
    i = :try_to_infer
  )
  case i
  when nil, :infer, :try_to_infer
    if is_on_roebe?
      if File.exist? FILE_ROEBE_FTP
        i = YAML.load_file(FILE_ROEBE_FTP)['bytehost']['url']
      end
    end
  end
  @remote_url = i
end
sfancy(i) click to toggle source
#

FtpParadise.sfancy

#
# File lib/ftp_paradise/colours/colours.rb, line 48
def self.sfancy(i)
  return Colours.sfancy(i) if use_colours? # Else we won't modify this at all.
  return i
end
sfile(i) click to toggle source
#

FtpParadise.sfile

#
# File lib/ftp_paradise/colours/colours.rb, line 40
def self.sfile(i)
  return Colours.sfile(i) if use_colours?
  return i
end
show_list() click to toggle source
#

FtpParadise.show_list

By default this method will exclude the '.' and '..' entries.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 211
def self.show_list
  result = @ftp_object.list
  result.each {|line|
    e line unless line.end_with? '.'
  }
end
simp(i) click to toggle source
#

FtpParadise.simp

#
# File lib/ftp_paradise/colours/colours.rb, line 56
def self.simp(i)
  return Colours.simp(i) if use_colours? # Else we won't modify this.
  return i
end
slateblue(i = '') click to toggle source
#

FtpParadise.slateblue

#
# File lib/ftp_paradise/colours/colours.rb, line 119
def self.slateblue(i = '')
  if use_colours?
    return ::Colours.slateblue(i)
  end
  return i
end
start_gtk() click to toggle source
#

FtpParadise.start_gtk

#
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 695
def self.start_gtk
  FtpParadise::GUI::Gtk::FtpParadiseModule.run
end
swarn(i) click to toggle source
#

FtpParadise.swarn

#
# 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() click to toggle source
#

FtpParadise.testing_colours (colour test, testing colours)

This just is a test whether we use colours or whether we won't.

#
# File lib/ftp_paradise/colours/colours.rb, line 131
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 ) click to toggle source
#

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.

#
# File lib/ftp_paradise/toplevel_methods/upload_and_download.rb, line 84
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 ) { || ... } click to toggle source
#

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
#
# File lib/ftp_paradise/toplevel_methods/upload_and_download.rb, line 29
def self.upload_this_binary_file(
    file,
    be_verbose             = :be_silent,
    use_this_as_ftp_object = nil
  )
  yielded = nil
  yielded = yield if block_given?
  case yielded
  when :be_quiet
    be_verbose = false
  end
  case be_verbose
  when :be_silent
    be_verbose = false
  end
  unless use_this_as_ftp_object
    require 'ftp_paradise/connection/connection.rb'
    use_this_as_ftp_object = ::FtpParadise::Connection.new(:dont_run_yet) { :default_dataset }
    if be_verbose
      use_this_as_ftp_object.be_verbose
    else
      use_this_as_ftp_object.be_quiet
    end
    use_this_as_ftp_object.set_binary_mode
  end
  if yielded
    if yielded.is_a? Hash
      if yielded.has_key? :cd_into_this_directory
        use_this_as_ftp_object.remote_cd(yielded[:cd_into_this_directory])
      end
    end
  end
  use_this_as_ftp_object.upload(file, be_verbose) # Here, do the FTP upload finally.
end
use_colours?() click to toggle source
#

FtpParadise.use_colours?

This can be delegated towards the configuration object.

#
# File lib/ftp_paradise/colours/use_colours.rb, line 30
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) click to toggle source
#

FtpParadise.use_this_as_ftp_object

Assignment to a new FTP object can come through this method.

#
# File lib/ftp_paradise/toplevel_methods/ftp_object.rb, line 111
def self.use_this_as_ftp_object(i)
  @ftp_object = i
end

Public Instance Methods

return_date() click to toggle source
#

return_date

#
# File lib/ftp_paradise/toplevel_methods/time.rb, line 21
def return_date
  FtpParadise.return_date
end
return_time() click to toggle source
#

return_time

#
# File lib/ftp_paradise/toplevel_methods/time.rb, line 37
def return_time
  FtpParadise.return_time
end
rev() click to toggle source
#

rev

#
# File lib/ftp_paradise/colours/colours.rb, line 16
def rev
  return Colours.rev if use_colours?
  return ''
end
sdir(i) click to toggle source
#

sdir

#
# File lib/ftp_paradise/colours/colours.rb, line 78
def sdir(i)
  FtpParadise.sdir(i)
end
sfancy(i) click to toggle source
#

sfancy

#
# File lib/ftp_paradise/colours/colours.rb, line 64
def sfancy(i)
  FtpParadise.sfancy(i) # We can delegate here, because FtpParadise.sfancy() will take care of colours.
end
sfile(i) click to toggle source
#

sfile

#
# File lib/ftp_paradise/colours/colours.rb, line 85
def sfile(i)
  FtpParadise.sfile(i)
end
simp(i) click to toggle source
#

simp

#
# File lib/ftp_paradise/colours/colours.rb, line 71
def simp(i) # Link to FtpParadise.simp
  FtpParadise.simp(i) # We can delegate here, because FtpParadise.sfancy will take care of colours.
end
swarn(i) click to toggle source
#

swarn

#
# File lib/ftp_paradise/colours/colours.rb, line 92
def swarn(i)
  FtpParadise.swarn(i)
end
use_colours?() click to toggle source
#

use_colours?

Whether we will use colours or whether we will not.

#
# File lib/ftp_paradise/colours/use_colours.rb, line 53
def use_colours?
  FtpParadise.use_colours?
end
yaml_directory?() click to toggle source
#

yaml_directory?

#
# File lib/ftp_paradise/project/project.rb, line 55
def yaml_directory?
  FtpParadise.yaml_directory?
end