class Oc::Run::Domain

Public Instance Methods

create(*args) click to toggle source
# File lib/system/run/commands/domain.rb, line 77
def create(*args)
  name = args[0]
  type = args[1]
  data = args[2]
  if data.nil? or type.nil? or data.nil?
    puts "Argument Error".red
    puts "Usage".yellow
    puts "$ oc domain create [DOMAIN_NAME] [TYPE] [IP]".yellow
  else
    result = barge.domain.create_record(name.to_s, {:type => name.to_s, :data => data.to_s})
    if !result.success?
      puts "#{result.message}".red
    else
      puts "Domain created".green
    end
  end
end
destroy(*args) click to toggle source
# File lib/system/run/commands/domain.rb, line 59
def destroy(*args)
  domain = args[0]
  if domain.nil?
    puts "Argument Error".red
    puts "Usage".yellow
    puts "$ oc domain destroy [DOMAIN_NAME]".yellow
  else
    result = barge.domain.destroy(domain.to_s)
    if !result.success?
      puts "#{result.message}".red
    else
      puts "Domain destroyed".green
    end
  end
end
run() click to toggle source
# File lib/system/run/commands/domain.rb, line 6
def run
  result = barge.domain.all
  if !result.success?
    puts "#{result.error}".red
  else
    puts "Domains".yellow
    rows = []
    rows << [
      'Name',
      'TTL'
    ]
    result.domains.each do |domain|
      rows << [
        domain.name.to_s.red,
        domain.ttl
      ]
    end
    table = Terminal::Table.new :rows => rows
    puts table
  end
end
show(*args) click to toggle source
# File lib/system/run/commands/domain.rb, line 30
def show(*args)
  domain = args[0]
  if domain.nil?
    puts "Argument Error".red
    puts "Usage".yellow
    puts "$ oc domain show [DOMAIN_NAME]".yellow
  else
    result = barge.domain.show(domain.to_s)
    if !result.success?
      puts "#{result.message}".red
    else
      puts "Domain Information - #{domain}".yellow
      rows = []
      rows << [
        'Name',
        'TTL'
      ]
      rows << [
        result.domain.name.to_s.red,
        result.domain.ttl
      ]
      table = Terminal::Table.new :rows => rows
      puts table
    end
  end
end

Private Instance Methods

barge() click to toggle source
# File lib/system/run/commands/domain.rb, line 96
def barge
  puts "I'm thinking, please wait..".blue
  Oc::Config.get_barge
end