summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorjkeiser <jkeiser@opscode.com>2013-01-16 07:10:11 -0800
committerJohn Keiser <jkeiser@opscode.com>2013-06-07 13:12:20 -0700
commit30eedb5bba2cf9a3774e8d28708ebfd92a544a59 (patch)
treee2e674a207d986c5d14514054fceac14420741ff /lib
parent3d9dc86eb32d3acde262309e3108208a500b2b9f (diff)
downloadchef-30eedb5bba2cf9a3774e8d28708ebfd92a544a59.tar.gz
Make format_path take an entry, not a path
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/chef_fs/knife.rb3
-rw-r--r--lib/chef/knife/delete.rb6
-rw-r--r--lib/chef/knife/deps.rb6
-rw-r--r--lib/chef/knife/diff.rb2
-rw-r--r--lib/chef/knife/download.rb2
-rw-r--r--lib/chef/knife/list.rb8
-rw-r--r--lib/chef/knife/upload.rb2
7 files changed, 15 insertions, 14 deletions
diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb
index 8fd779cbee..53b881610f 100644
--- a/lib/chef/chef_fs/knife.rb
+++ b/lib/chef/chef_fs/knife.rb
@@ -149,7 +149,8 @@ class Chef
end
# Print the given server path, relative to the current directory
- def format_path(server_path)
+ def format_path(entry)
+ server_path = entry.path
if base_path && server_path[0,base_path.length] == base_path
if server_path == base_path
return "."
diff --git a/lib/chef/knife/delete.rb b/lib/chef/knife/delete.rb
index fb827c1143..417336b56b 100644
--- a/lib/chef/knife/delete.rb
+++ b/lib/chef/knife/delete.rb
@@ -67,7 +67,7 @@ class Chef
def format_path_with_root(entry)
root = entry.root == chef_fs ? " (remote)" : " (local)"
- "#{format_path(entry.path)}#{root}"
+ "#{format_path(entry)}#{root}"
end
def delete_result(*results)
@@ -92,9 +92,9 @@ class Chef
end
end
if deleted_any
- output("Deleted #{format_path(results[0].path)}")
+ output("Deleted #{format_path(results[0])}")
elsif !found_any
- ui.error "#{format_path(results[0].path)}: No such file or directory"
+ ui.error "#{format_path(results[0])}: No such file or directory"
error = true
end
error
diff --git a/lib/chef/knife/deps.rb b/lib/chef/knife/deps.rb
index a1818fc4c6..2e8effdf06 100644
--- a/lib/chef/knife/deps.rb
+++ b/lib/chef/knife/deps.rb
@@ -52,13 +52,13 @@ class Chef
child_entry = Chef::ChefFS::FileSystem.resolve_path(@root, child)
print_flattened_dependencies(child_entry, dependencies)
end
- output format_path(entry.path)
+ output format_path(entry)
end
end
def print_dependencies_tree(entry, dependencies, printed = {}, depth = 0)
dependencies[entry.path] = get_dependencies(entry) if !dependencies[entry.path]
- output "#{' '*depth}#{format_path(entry.path)}"
+ output "#{' '*depth}#{format_path(entry)}"
if !printed[entry.path] && (config[:recurse] || depth == 0)
printed[entry.path] = true
dependencies[entry.path].each do |child|
@@ -108,7 +108,7 @@ class Chef
[]
end
rescue Chef::ChefFS::FileSystem::NotFoundError => e
- ui.error "#{format_path(e.entry.path)}: No such file or directory"
+ ui.error "#{format_path(e.entry)}: No such file or directory"
self.exit_code = 2
[]
end
diff --git a/lib/chef/knife/diff.rb b/lib/chef/knife/diff.rb
index c59ff22c29..cd35898664 100644
--- a/lib/chef/knife/diff.rb
+++ b/lib/chef/knife/diff.rb
@@ -35,7 +35,7 @@ class Chef
# Get the matches (recursively)
patterns.each do |pattern|
- Chef::ChefFS::CommandLine.diff_print(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, output_mode, proc { |entry| format_path(entry.path) } ) do |diff|
+ Chef::ChefFS::CommandLine.diff_print(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, output_mode, proc { |entry| format_path(entry) } ) do |diff|
stdout.print diff
end
end
diff --git a/lib/chef/knife/download.rb b/lib/chef/knife/download.rb
index d9077bbef9..94f1b1b17f 100644
--- a/lib/chef/knife/download.rb
+++ b/lib/chef/knife/download.rb
@@ -42,7 +42,7 @@ class Chef
error = false
pattern_args.each do |pattern|
- error ||= Chef::ChefFS::FileSystem.copy_to(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry.path) })
+ error ||= Chef::ChefFS::FileSystem.copy_to(pattern, chef_fs, local_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
end
if error
exit 1
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb
index e9a60ddaf6..e78251b469 100644
--- a/lib/chef/knife/list.rb
+++ b/lib/chef/knife/list.rb
@@ -49,7 +49,7 @@ class Chef
elsif result.exists?
results << result
elsif pattern.exact_path
- ui.error "#{format_path(result.path)}: No such file or directory"
+ ui.error "#{format_path(result)}: No such file or directory"
self.exit_code = 1
end
end
@@ -78,7 +78,7 @@ class Chef
else
printed_something = true
end
- output "#{format_path(result.path)}:"
+ output "#{format_path(result)}:"
print_results(children.map { |result| maybe_add_slash(result.name, result.dir?) }.sort, "")
end
@@ -89,7 +89,7 @@ class Chef
begin
children = result.children.sort_by { |child| child.name }
rescue Chef::ChefFS::FileSystem::NotFoundError => e
- ui.error "#{format_path(e.entry.path)}: No such file or directory"
+ ui.error "#{format_path(e.entry)}: No such file or directory"
return []
end
@@ -105,7 +105,7 @@ class Chef
end
def print_result_paths(results, indent = "")
- print_results(results.map { |result| maybe_add_slash(format_path(result.path), result.dir?) }, indent)
+ print_results(results.map { |result| maybe_add_slash(format_path(result), result.dir?) }, indent)
end
def print_results(results, indent)
diff --git a/lib/chef/knife/upload.rb b/lib/chef/knife/upload.rb
index 25233eef13..2b3fbd0e30 100644
--- a/lib/chef/knife/upload.rb
+++ b/lib/chef/knife/upload.rb
@@ -42,7 +42,7 @@ class Chef
error = false
pattern_args.each do |pattern|
- error ||= Chef::ChefFS::FileSystem.copy_to(pattern, local_fs, chef_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry.path) })
+ error ||= Chef::ChefFS::FileSystem.copy_to(pattern, local_fs, chef_fs, config[:recurse] ? nil : 1, config, ui, proc { |entry| format_path(entry) })
end
if error
exit 1