From 0ffdf42cf2171deb0bdd4c54f8281c1c1257ee86 Mon Sep 17 00:00:00 2001 From: elijah Date: Sat, 22 Jun 2013 15:52:48 -0700 Subject: improve `leap inspect` --- lib/leap_cli/config/manager.rb | 9 +++++---- lib/leap_cli/config/node.rb | 15 --------------- lib/leap_cli/config/object.rb | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 19 deletions(-) (limited to 'lib/leap_cli/config') diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb index 8ab8e2f..29721e7 100644 --- a/lib/leap_cli/config/manager.rb +++ b/lib/leap_cli/config/manager.rb @@ -17,6 +17,7 @@ module LeapCli ## attr_reader :services, :tags, :nodes, :provider, :common, :secrets + attr_reader :base_services, :base_tags, :base_provider, :base_common def facts @facts ||= JSON.parse(Util.read_file(:facts) || "{}") @@ -33,10 +34,10 @@ module LeapCli @provider_dir = Path.provider # load base - base_services = load_all_json(Path.named_path([:service_config, '*'], Path.provider_base), Config::Tag) - base_tags = load_all_json(Path.named_path([:tag_config, '*'], Path.provider_base), Config::Tag) - base_common = load_json(Path.named_path(:common_config, Path.provider_base), Config::Object) - base_provider = load_json(Path.named_path(:provider_config, Path.provider_base), Config::Object) + @base_services = load_all_json(Path.named_path([:service_config, '*'], Path.provider_base), Config::Tag) + @base_tags = load_all_json(Path.named_path([:tag_config, '*'], Path.provider_base), Config::Tag) + @base_common = load_json(Path.named_path(:common_config, Path.provider_base), Config::Object) + @base_provider = load_json(Path.named_path(:provider_config, Path.provider_base), Config::Object) # load provider provider_path = Path.named_path(:provider_config, @provider_dir) diff --git a/lib/leap_cli/config/node.rb b/lib/leap_cli/config/node.rb index 15a2d3d..5b911bf 100644 --- a/lib/leap_cli/config/node.rb +++ b/lib/leap_cli/config/node.rb @@ -15,21 +15,6 @@ module LeapCli; module Config @file_paths = [] end - # - # Make a copy of ourselves, except only including the specified keys. - # - # Also, the result is flattened to a single hash, so a key of 'a.b' becomes 'a_b' - # - def pick(*keys) - keys.map(&:to_s).inject(self.class.new(@manager)) do |hsh, key| - value = self.get(key) - if !value.nil? - hsh[key.gsub('.','_')] = value - end - hsh - end - end - # # returns true if this node has an ip address in the range of the vagrant network # diff --git a/lib/leap_cli/config/object.rb b/lib/leap_cli/config/object.rb index 1edef3f..00997b1 100644 --- a/lib/leap_cli/config/object.rb +++ b/lib/leap_cli/config/object.rb @@ -184,6 +184,21 @@ module LeapCli self.deep_merge!(object, true) end + # + # Make a copy of ourselves, except only including the specified keys. + # + # Also, the result is flattened to a single hash, so a key of 'a.b' becomes 'a_b' + # + def pick(*keys) + keys.map(&:to_s).inject(self.class.new(@manager)) do |hsh, key| + value = self.get(key) + if !value.nil? + hsh[key.gsub('.','_')] = value + end + hsh + end + end + protected # -- cgit v1.2.3