mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-25 21:28:40 -05:00
(#24) Improve 'get' output
This commit updates how hosts are formated when shown to the user. It applies a domain to each hostname instead of being a different key.
This commit is contained in:
parent
06206456c7
commit
a6c5f1dceb
4 changed files with 13 additions and 6 deletions
|
|
@ -8,10 +8,15 @@ class Utils
|
|||
host_hash = {}
|
||||
|
||||
hostname_hash.delete("ok")
|
||||
domain = hostname_hash["domain"]
|
||||
hostname_hash.each do |type, hosts|
|
||||
if type == "domain"
|
||||
host_hash[type] = hosts
|
||||
else
|
||||
if type != "domain"
|
||||
if hosts["hostname"].kind_of?(Array)
|
||||
hosts["hostname"].map!{|host| host + "." + domain }
|
||||
else
|
||||
hosts["hostname"] = hosts["hostname"] + "." + domain
|
||||
end
|
||||
|
||||
host_hash[type] = hosts["hostname"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
class Version
|
||||
@version = '0.3.1'
|
||||
@version = '0.4.0'
|
||||
|
||||
def self.get
|
||||
@version
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ describe Utils do
|
|||
describe "#get_hosts" do
|
||||
before :each do
|
||||
@hostname_hash = "{\"ok\":true,\"debian-7-i386\":{\"hostname\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"]},\"debian-7-x86_64\":{\"hostname\":\"zb91y9qbrbf6d3q\"},\"domain\":\"company.com\"}"
|
||||
@format_hash = "{\"debian-7-i386\":[\"sc0o4xqtodlul5w\",\"4m4dkhqiufnjmxy\"],\"debian-7-x86_64\":\"zb91y9qbrbf6d3q\",\"domain\":\"company.com\"}"
|
||||
@format_hash = "{\"debian-7-i386\":[\"sc0o4xqtodlul5w.company.com\",\"4m4dkhqiufnjmxy.company.com\"],\"debian-7-x86_64\":\"zb91y9qbrbf6d3q.company.com\"}"
|
||||
end
|
||||
|
||||
it "formats a hostname hash into os, hostnames, and domain name" do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
require 'vmfloaty/version'
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'vmfloaty'
|
||||
s.version = '0.3.1'
|
||||
s.version = Version.get
|
||||
s.authors = ['Brian Cain']
|
||||
s.email = ['brian.cain@puppetlabs.com']
|
||||
s.license = 'Apache'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue