Class: Dreamy::Command::Domains

Inherits:
Base
  • Object
show all
Defined in:
lib/dreamy/commands/domains.rb

Instance Attribute Summary

Attributes inherited from Base

#args

Instance Method Summary collapse

Methods inherited from Base

#ask, #display, #extract_option, #home_directory, #initialize, #running_on_windows?, #shell

Constructor Details

This class inherits a constructor from Dreamy::Command::Base

Instance Method Details

#httpObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dreamy/commands/domains.rb', line 10

def http
  domains = @account.domains.reject { |d| d.type != 'http'}
  
  if domains.empty?
    display "No HTTP domains on this account"
  else
    domain_table = table do |t|
      t.headings = 'Domain Name', 'Server', 'Type', 'User', 'WWW or Not'
      domains.each { |d| t << [d.domain,d.short_home,d.hosting_type,d.user,d.www_or_not]}
    end
    display domain_table
  end
end

#indexObject



6
7
8
# File 'lib/dreamy/commands/domains.rb', line 6

def index
  http
end

#mysqlObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dreamy/commands/domains.rb', line 24

def mysql
  domains = @account.domains.reject { |d| d.type != 'mysqldns'}
  
  if domains.empty?
    display "No MySQL domains on this account"
  else
    domain_table = table do |t|
      t.headings = 'Domain Name', 'Server'
      domains.each { |d| t << [d.domain,d.short_home]}
    end
    display domain_table
  end
end

#statusObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/dreamy/commands/domains.rb', line 38

def status
  domains = @account.domains
  domains.each do |d|
    if host_available?(d.domain)
      display "#{d.domain} is up"
    else
      display "#{d.domain} is down!"
      if host_available?(d.home)
        display "  But its host server (#{d.home}) is up"
      else
        display "  And its host server (#{d.home}) is down"
      end
    end
  end
end