Class: Crane::Commands::Test

Inherits:
Engine show all
Includes:
Config
Defined in:
lib/crane/commands/test.rb

Instance Method Summary collapse

Methods included from Config

get_ignored_files, has_config_file?, load_config, make_config, save_config

Methods inherited from Engine

#connect_ftp, #get_ignored_files, #initialize, #is_option, #no_command, #version

Methods inherited from Shell::Run

#initialize

Constructor Details

This class inherits a constructor from Crane::Engine

Instance Method Details

#ftp_remote_dir?Boolean

Returns:

  • (Boolean)


48
49
50
51
# File 'lib/crane/commands/test.rb', line 48

def ftp_remote_dir?
  @ftp = Crane::Ftp.new if @ftp.nil?
  @ftp.remote_dir_exists?
end

#has_ftp_connection?Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
# File 'lib/crane/commands/test.rb', line 40

def has_ftp_connection?
  @ftp = Crane::Ftp.new
  return false if @ftp.connection.nil?
  if @ftp.connection.respond_to?("closed?")
    !@ftp.connection.closed?
  end
end

#helpObject



53
54
55
# File 'lib/crane/commands/test.rb', line 53

def help
  puts "Tests environment."
end

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/crane/commands/test.rb', line 11

def run
  puts "Starting tests:"

  # has configuration file?
  if Config.has_config_file?
    puts "\tConfiguration file: ok."
  else
    puts "\tConfiguration file: failed."
    exit
  end

  # has connection?
  if has_ftp_connection?
    puts "\tFTP connection: ok."
  else
    puts "\tFTP connection: failed"
    exit
  end

  # can change dir?
  if ftp_remote_dir?
    puts "\tFTP remote dir: ok."
  else
    puts "\tFTP remote dir: failed => inexistent remote dir"
  end

  puts "Everything's ok." if @errors == false
end