class DLDInternet::DOctl::Compute::Domain::Command
Public Instance Methods
create(domain)
click to toggle source
# File lib/dldinternet/doctl/compute/domain/command.rb, line 66 def create(domain) formats = Hashie::Mash.new({ Domain: [ :name, '%-16s', :to_s ], TTL: [ :ttl, '%-6s', :to_i ], }) format_names = options[:format_string].split(/,/) format_templ = format_names.map { |name| formats[name][1] }.join('') @header = -> { sprintf(format_templ, *format_names) } @format = ->(o) { # h = Hashie::Mash.new(hash_it(o)) sprintf(format_templ, *(format_names.map{ |n| if o.respond_to?(formats[n][0]) o.send(formats[n][0]).send(formats[n][2]) else $stderr.write "#{n} not in #{o.class.name}::#{hash_it(o)}\n" '' end })) } command_pre(domain) command_out(DLDInternet::DOctl::API::Compute::Domain::Create.new(options, @logger).CreateDomain(domain, options[:ip_address])) 0 end
delete(domain)
click to toggle source
# File lib/dldinternet/doctl/compute/domain/command.rb, line 91 def delete(domain) @header = -> { } @format = ->(o) { o.ai } command_pre(domain) command_out(DLDInternet::DOctl::API::Compute::Domain::Delete.new(options, @logger).DeleteDomain(domain)) 0 end
get(domain)
click to toggle source
# File lib/dldinternet/doctl/compute/domain/command.rb, line 38 def get(domain) formats = Hashie::Mash.new({ Domain: [ :name, '%-16s', :to_s ], TTL: [ :ttl, '%-6s', :to_i ], }) format_names = options[:format_string].split(/,/) format_templ = format_names.map { |name| formats[name][1] }.join('') @header = -> { sprintf(format_templ, *format_names) } @format = ->(o) { # h = Hashie::Mash.new(hash_it(o)) sprintf(format_templ, *(format_names.map{ |n| if o.respond_to?(formats[n][0]) o.send(formats[n][0]).send(formats[n][2]) else $stderr.write "#{n} not in #{o.class.name}::#{hash_it(o)}\n" '' end })) } command_pre(domain) command_out(DLDInternet::DOctl::API::Compute::Domain::Get.new(options, @logger).GetDomain(domain)) 0 end
list()
click to toggle source
# File lib/dldinternet/doctl/compute/domain/command.rb, line 17 def list() command_pre res = DLDInternet::DOctl::API::Compute::Domain::List.new(options, @logger).GetDomainList() @header = -> { sprintf('%-17s%s', 'Domain', 'TTL') } @format = ->(obj) { sprintf('%-17s%s', obj[:name], obj[:ttl] ) } command_out(res) # case options[:format] # when /text|none/ # output sprintf('%-17s%s', 'Domain', 'TTL') # res.each do |obj| # output sprintf('%-17s%s', obj[:name], obj[:ttl] ) # end # else # output res # end 0 end