Skip to content

Commit

Permalink
(#24) Improve 'get' output
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
briancain committed Jul 2, 2016
1 parent 0620645 commit a6c5f1d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
11 changes: 8 additions & 3 deletions lib/vmfloaty/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ def self.format_hosts(hostname_hash)
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
Expand Down
2 changes: 1 addition & 1 deletion lib/vmfloaty/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

class Version
@version = '0.3.1'
@version = '0.4.0'

def self.get
@version
Expand Down
2 changes: 1 addition & 1 deletion spec/vmfloaty/utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down
4 changes: 3 additions & 1 deletion vmfloaty.gemspec
Original file line number Diff line number Diff line change
@@ -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 = ['[email protected]']
s.license = 'Apache'
Expand Down

0 comments on commit a6c5f1d

Please sign in to comment.