Sha256: 7dc5cf5dc43252d847bf9f05c048e307c5d28b90eecda3f211d9fd91ca6bd677
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
module HammerCLIForeman::Output module Formatters class OSNameFormatter < HammerCLI::Output::Formatters::FieldFormatter def tags [:flat] end def format(os) return nil if os.nil? name = os['name'] || os[:name] major = os['major'] || os[:major] minor = os['minor'] || os[:minor] formatted_name = "%s %s" % [name, major] formatted_name += ".%s" % minor if (!minor.nil? && !minor.empty?) formatted_name end end class ServerFormatter < HammerCLI::Output::Formatters::FieldFormatter def tags [:flat] end def format(server) if server.kind_of? Hash name = server[:name] || server['name'] url = server[:url] || server['url'] "#{name} (#{url})" else server end end end HammerCLI::Output::Output.register_formatter(OSNameFormatter.new, :OSName) HammerCLI::Output::Output.register_formatter(ServerFormatter.new, :Server) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hammer_cli_foreman-0.1.0 | lib/hammer_cli_foreman/output/formatters.rb |