class Dynamic53::Cli

Attributes

hostname[RW]
local_ip[RW]
record[RW]
route53[RW]
update_hostname[RW]
user[RW]
zone[RW]

Public Class Methods

new(params) click to toggle source
# File lib/dynamic53/cli.rb, line 10
def initialize(params)
  @user = params[0]
  @hostname = params[1]
  @update_hostname = params[2] ? params[2] : stringify_computer
  update_dns 
end
start(params) click to toggle source
# File lib/dynamic53/cli.rb, line 4
def self.start(params)
  new(params)
end

Public Instance Methods

update_dns() click to toggle source
# File lib/dynamic53/cli.rb, line 17
def update_dns
  if record
    record.update(nil,nil,nil,[local_ip])
  else
    create_record
  end
end

Private Instance Methods

create_record() click to toggle source
# File lib/dynamic53/cli.rb, line 27
def create_record
  record = Route53::DNSRecord.new("#{update_hostname}.#{hostname}.","A","60",[local_ip], zone)
  record.create
end
stringify_computer() click to toggle source
# File lib/dynamic53/cli.rb, line 32
def stringify_computer
  `/usr/sbin/scutil --get ComputerName`.chomp.downcase.gsub(" ", "-").gsub(/[^a-z0-9]/i, "")
end