Sha256: c8299fc1c0ce402d68731325fa77589909c6aafa7d3457a2595b5c6329031fe0
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
require "ansi" require "date" class DomainCheck::ConsoleFormatter def initialize(result, available_only = false) @result = result @available_only = available_only end def format if @result return if @available_only && @result[:status] != :available domain = @result[:domain].ljust(24).ansi.bold.blue if @result[:status] == :available status = @result[:status].to_s.upcase.ansi.bold.green puts "#{ domain } #{ status }" elsif @result[:status] == :registered status = @result[:status].to_s.upcase.ansi.bold.red contact_name = @result[:contact_name] contact_email = @result[:contact_email] created_on = @result[:created_at] created_on = created_on.to_date.to_s if created_on expires_in = nil if @result[:expires_at] today = Date.today days = (@result[:expires_at].to_date - today).to_i expires_in = "#{ days } days" if days <= 60 expires_in = expires_in.ansi.yellow.bold end end params = { contact: contact_name, email: contact_email, created: created_on, expires: expires_in } params.reject! { |k,v| v.nil? } param_string = params.to_a.map { |a| "#{ a[0] }: #{ a[1] }" }.join(", ") puts "#{ domain } #{ status }" + (", #{ param_string }" if param_string) elsif @result[:status] == :unknown puts "#{ domain } #{ "UNKNOWN".ansi.red.negative.bold }" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
domain_check-0.0.3 | lib/domain_check/console_formatter.rb |