summaryrefslogtreecommitdiff
path: root/lib/chef/knife/core
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/knife/core')
-rw-r--r--lib/chef/knife/core/cookbook_scm_repo.rb5
-rw-r--r--lib/chef/knife/core/gem_glob_loader.rb6
-rw-r--r--lib/chef/knife/core/generic_presenter.rb15
-rw-r--r--lib/chef/knife/core/hashed_command_loader.rb2
-rw-r--r--lib/chef/knife/core/node_presenter.rb7
-rw-r--r--lib/chef/knife/core/status_presenter.rb4
-rw-r--r--lib/chef/knife/core/subcommand_loader.rb5
-rw-r--r--lib/chef/knife/core/text_formatter.rb4
-rw-r--r--lib/chef/knife/core/ui.rb9
9 files changed, 26 insertions, 31 deletions
diff --git a/lib/chef/knife/core/cookbook_scm_repo.rb b/lib/chef/knife/core/cookbook_scm_repo.rb
index 4779bb5405..e909066b02 100644
--- a/lib/chef/knife/core/cookbook_scm_repo.rb
+++ b/lib/chef/knife/core/cookbook_scm_repo.rb
@@ -31,7 +31,7 @@ class Chef
attr_reader :use_current_branch
attr_reader :ui
- def initialize(repo_path, ui, opts={})
+ def initialize(repo_path, ui, opts = {})
@repo_path = repo_path
@ui = ui
@default_branch = "master"
@@ -119,7 +119,7 @@ class Chef
end
def branch_exists?(branch_name)
- git("branch --no-color").stdout.lines.any? {|l| l =~ /\s#{Regexp.escape(branch_name)}(?:\s|$)/ }
+ git("branch --no-color").stdout.lines.any? { |l| l =~ /\s#{Regexp.escape(branch_name)}(?:\s|$)/ }
end
def get_current_branch()
@@ -157,4 +157,3 @@ class Chef
end
end
end
-
diff --git a/lib/chef/knife/core/gem_glob_loader.rb b/lib/chef/knife/core/gem_glob_loader.rb
index 2aabf4cf46..6802be29ef 100644
--- a/lib/chef/knife/core/gem_glob_loader.rb
+++ b/lib/chef/knife/core/gem_glob_loader.rb
@@ -50,7 +50,7 @@ class Chef
files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")]
subcommand_files = {}
files.each do |knife_file|
- rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1]
+ rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
subcommand_files[rel_path] = knife_file
end
subcommand_files
@@ -77,7 +77,7 @@ class Chef
private
- def find_files_latest_gems(glob, check_load_path=true)
+ def find_files_latest_gems(glob, check_load_path = true)
files = []
if check_load_path
@@ -103,7 +103,7 @@ class Chef
def latest_gem_specs
@latest_gem_specs ||= if Gem::Specification.respond_to? :latest_specs
- Gem::Specification.latest_specs(true) # find prerelease gems
+ Gem::Specification.latest_specs(true) # find prerelease gems
else
Gem.source_index.latest_specs(true)
end
diff --git a/lib/chef/knife/core/generic_presenter.rb b/lib/chef/knife/core/generic_presenter.rb
index 4ba9a15100..bbe0249b3d 100644
--- a/lib/chef/knife/core/generic_presenter.rb
+++ b/lib/chef/knife/core/generic_presenter.rb
@@ -32,7 +32,7 @@ class Chef
option :attribute,
:short => "-a ATTR1 [-a ATTR2]",
:long => "--attribute ATTR1 [--attribute ATTR2] ",
- :proc => lambda {|val| @attrs_to_show << val},
+ :proc => lambda { |val| @attrs_to_show << val },
:description => "Show one or more attributes"
end
end
@@ -133,7 +133,7 @@ class Chef
end
def format_list_for_display(list)
- config[:with_uri] ? list : list.keys.sort { |a,b| a <=> b }
+ config[:with_uri] ? list : list.keys.sort { |a, b| a <=> b }
end
def format_for_display(data)
@@ -142,7 +142,7 @@ class Chef
elsif config[:id_only]
name_or_id_for(data)
elsif config[:environment] && data.respond_to?(:chef_environment)
- {"chef_environment" => data.chef_environment}
+ { "chef_environment" => data.chef_environment }
else
data
end
@@ -162,7 +162,7 @@ class Chef
else
raise ArgumentError, "format_data_subset_for_display requires attribute, run_list, or id_only config option to be set"
end
- {name_or_id_for(data) => subset }
+ { name_or_id_for(data) => subset }
end
def name_or_id_for(data)
@@ -173,7 +173,6 @@ class Chef
config[:attribute] || config[:run_list]
end
-
def extract_nested_value(data, nested_value_spec)
nested_value_spec.split(".").each do |attr|
if data.nil?
@@ -181,7 +180,7 @@ class Chef
# Must check :[] before attr because spec can include
# `keys` - want the key named `keys`, not a list of
# available keys.
- elsif data.respond_to?(:[]) && data.has_key?(attr)
+ elsif data.respond_to?(:[]) && data.has_key?(attr)
data = data[attr]
elsif data.respond_to?(attr.to_sym)
data = data.send(attr.to_sym)
@@ -207,10 +206,10 @@ class Chef
end
else
versions_by_cookbook = item.inject({}) do |collected, ( cookbook, versions )|
- collected[cookbook] = versions["versions"].map {|v| v["version"]}
+ collected[cookbook] = versions["versions"].map { |v| v["version"] }
collected
end
- key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map {|name| name.size }.max + 2
+ key_length = versions_by_cookbook.empty? ? 0 : versions_by_cookbook.keys.map { |name| name.size }.max + 2
versions_by_cookbook.sort.map do |cookbook, versions|
"#{cookbook.ljust(key_length)} #{versions.join(' ')}"
end
diff --git a/lib/chef/knife/core/hashed_command_loader.rb b/lib/chef/knife/core/hashed_command_loader.rb
index aecf738332..7b6c1c4c08 100644
--- a/lib/chef/knife/core/hashed_command_loader.rb
+++ b/lib/chef/knife/core/hashed_command_loader.rb
@@ -38,7 +38,7 @@ class Chef
find_longest_key(manifest[KEY]["plugins_by_category"], category_words, " ")
end
- def list_commands(pref_category=nil)
+ def list_commands(pref_category = nil)
if pref_category || manifest[KEY]["plugins_by_category"].key?(pref_category)
{ pref_category => manifest[KEY]["plugins_by_category"][pref_category] }
else
diff --git a/lib/chef/knife/core/node_presenter.rb b/lib/chef/knife/core/node_presenter.rb
index a5837f268c..cdb664ec33 100644
--- a/lib/chef/knife/core/node_presenter.rb
+++ b/lib/chef/knife/core/node_presenter.rb
@@ -98,7 +98,7 @@ class Chef
# special case ec2 with their split horizon whatsis.
ip = (node[:ec2] && node[:ec2][:public_ipv4]) || node[:ipaddress]
- summarized=<<-SUMMARY
+ summarized = <<-SUMMARY
#{ui.color('Node Name:', :bold)} #{ui.color(node.name, :bold)}
SUMMARY
show_policy = !(node.policy_name.nil? && node.policy_group.nil?)
@@ -128,13 +128,13 @@ ROLES
#{key('Tags:')} #{node.tags.join(', ')}
SUMMARY
if config[:medium_output] || config[:long_output]
- summarized +=<<-MORE
+ summarized += <<-MORE
#{key('Attributes:')}
#{text_format(node.normal_attrs)}
MORE
end
if config[:long_output]
- summarized +=<<-MOST
+ summarized += <<-MOST
#{key('Default Attributes:')}
#{text_format(node.default_attrs)}
#{key('Override Attributes:')}
@@ -157,4 +157,3 @@ MOST
end
end
end
-
diff --git a/lib/chef/knife/core/status_presenter.rb b/lib/chef/knife/core/status_presenter.rb
index 13bcf5cab2..68c1acf4f1 100644
--- a/lib/chef/knife/core/status_presenter.rb
+++ b/lib/chef/knife/core/status_presenter.rb
@@ -93,7 +93,7 @@ class Chef
# the volume of output is adjusted accordingly. Uses colors if enabled
# in the ui object.
def summarize(list)
- summarized=""
+ summarized = ""
list.each do |data|
node = data
# special case ec2 with their split horizon whatsis.
@@ -130,7 +130,7 @@ class Chef
line_parts << platform
end
- summarized=summarized + line_parts.join(", ") + ".\n"
+ summarized = summarized + line_parts.join(", ") + ".\n"
end
summarized
end
diff --git a/lib/chef/knife/core/subcommand_loader.rb b/lib/chef/knife/core/subcommand_loader.rb
index 2b8bbc929d..95ab219c80 100644
--- a/lib/chef/knife/core/subcommand_loader.rb
+++ b/lib/chef/knife/core/subcommand_loader.rb
@@ -96,7 +96,7 @@ class Chef
end
def force_load
- @loaded=false
+ @loaded = false
load_commands
end
@@ -128,7 +128,6 @@ class Chef
category_words, " ")
end
-
#
# This is shared between the custom_manifest_loader and the gem_glob_loader
#
@@ -137,7 +136,7 @@ class Chef
files = Dir[File.join(Chef::Util::PathHelper.escape_glob(File.expand_path("../../../knife", __FILE__)), "*.rb")]
subcommand_files = {}
files.each do |knife_file|
- rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/,1]
+ rel_path = knife_file[/#{CHEF_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
subcommand_files[rel_path] = knife_file
end
subcommand_files
diff --git a/lib/chef/knife/core/text_formatter.rb b/lib/chef/knife/core/text_formatter.rb
index 006a6fc9cf..8775e2e76f 100644
--- a/lib/chef/knife/core/text_formatter.rb
+++ b/lib/chef/knife/core/text_formatter.rb
@@ -45,7 +45,7 @@ class Chef
buffer = ""
if data.respond_to?(:keys)
- justify_width = data.keys.map {|k| k.to_s.size }.max.to_i + 1
+ justify_width = data.keys.map { |k| k.to_s.size }.max.to_i + 1
data.sort.each do |key, value|
# key: ['value'] should be printed as key: value
if value.kind_of?(Array) && value.size == 1 && is_singleton(value[0])
@@ -68,7 +68,7 @@ class Chef
buffer << text_format(data[index])
# Separate items with newlines if it's an array of hashes or an
# array of arrays
- buffer << "\n" if !is_singleton(data[index]) && index != data.size-1
+ buffer << "\n" if !is_singleton(data[index]) && index != data.size - 1
end
else
buffer << "#{data}\n"
diff --git a/lib/chef/knife/core/ui.rb b/lib/chef/knife/core/ui.rb
index f5002c8598..ee92127898 100644
--- a/lib/chef/knife/core/ui.rb
+++ b/lib/chef/knife/core/ui.rb
@@ -137,7 +137,7 @@ class Chef
@presenter.interchange?
end
- def ask_question(question, opts={})
+ def ask_question(question, opts = {})
question = question + "[#{opts[:default]}] " if opts[:default]
if opts[:default] and config[:defaults]
@@ -163,7 +163,6 @@ class Chef
end
end
-
# Hash -> Hash
# Works the same as edit_data but
# returns a hash rather than a JSON string/Fully infated object
@@ -172,7 +171,7 @@ class Chef
Chef::JSONCompat.parse(raw)
end
- def edit_data(data, parse_output=true)
+ def edit_data(data, parse_output = true)
output = Chef::JSONCompat.to_json_pretty(data)
if (!config[:disable_editing])
Tempfile.open([ "knife-edit-", ".json" ]) do |tf|
@@ -226,7 +225,7 @@ class Chef
end
# See confirm method for argument information
- def confirm_without_exit(question, append_instructions=true, default_choice=nil)
+ def confirm_without_exit(question, append_instructions = true, default_choice = nil)
return true if config[:yes]
stdout.print question
@@ -264,7 +263,7 @@ class Chef
# append_instructions => Should print '? (Y/N)' as instructions
# default_choice => Set to true for 'Y', and false for 'N' as default answer
#
- def confirm(question, append_instructions=true, default_choice=nil)
+ def confirm(question, append_instructions = true, default_choice = nil)
unless confirm_without_exit(question, append_instructions, default_choice)
exit 3
end