diff options
Diffstat (limited to 'lib/chef/chef_fs')
18 files changed, 37 insertions, 37 deletions
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb index b74f76cab3..d8bb3bb7ed 100644 --- a/lib/chef/chef_fs/chef_fs_data_store.rb +++ b/lib/chef/chef_fs/chef_fs_data_store.rb @@ -246,7 +246,7 @@ class Chef end else - if !data.is_a?(String) + unless data.is_a?(String) raise "set only works with strings" end @@ -362,7 +362,7 @@ class Chef if use_memory_store?(path) @memory_store.set(path, data, *options) else - if !data.is_a?(String) + unless data.is_a?(String) raise "set only works with strings: #{path} = #{data.inspect}" end @@ -466,7 +466,7 @@ class Chef FileSystemCache.instance.delete!(policy.file_path) found_policy = true end - raise ChefZero::DataStore::DataNotFoundError.new(path) if !found_policy + raise ChefZero::DataStore::DataNotFoundError.new(path) unless found_policy end else @@ -645,7 +645,7 @@ class Chef # Create the .uploaded-cookbook-version.json cookbooks = chef_fs.child(cookbook_type) - if !cookbooks.exists? + unless cookbooks.exists? cookbooks = chef_fs.create_child(cookbook_type) end # We are calling a cookbooks-specific API, so get multiplexed_dirs out of the way if it is there diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb index 217fb208d3..265b95e22d 100644 --- a/lib/chef/chef_fs/command_line.rb +++ b/lib/chef/chef_fs/command_line.rb @@ -132,7 +132,7 @@ class Chef end end end - if !found_match + unless found_match ui.error "#{pattern}: No such file or directory on remote or local" if ui error = true end diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb index 7940dbf1fe..48ebe75e27 100644 --- a/lib/chef/chef_fs/config.rb +++ b/lib/chef/chef_fs/config.rb @@ -150,7 +150,7 @@ class Chef hosted_everything or allow repo_mode to default} end # Default to getting *everything* from the server. - if !@chef_config[:repo_mode] + unless @chef_config[:repo_mode] if is_hosted? @chef_config[:repo_mode] = "hosted_everything" else diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb index 5e3e276541..48e28ccc39 100644 --- a/lib/chef/chef_fs/file_pattern.rb +++ b/lib/chef/chef_fs/file_pattern.rb @@ -188,7 +188,7 @@ class Chef end def calculate - if !@regexp + unless @regexp @is_absolute = Chef::ChefFS::PathUtils.is_absolute?(@pattern) full_regexp_parts = [] @@ -221,7 +221,7 @@ class Chef full_regexp_parts.pop normalized_parts.pop - if !@has_double_star + unless @has_double_star @regexp_parts.pop @exact_parts.pop end @@ -232,7 +232,7 @@ class Chef # Build up the regexp full_regexp_parts << regexp normalized_parts << part - if !@has_double_star + unless @has_double_star @regexp_parts << Regexp.new("^#{regexp}$") @exact_parts << exact end @@ -265,7 +265,7 @@ class Chef pattern.split(pattern_special_characters).each_with_index do |part, index| # Odd indexes from the split are symbols. Even are normal bits. if index.even? - exact << part if !exact.nil? + exact << part unless exact.nil? regexp << part else case part @@ -283,7 +283,7 @@ class Chef else if part[0, 1] == '\\' && part.length == 2 # backslash escapes are only supported on Unix, and are handled here by leaving the escape on (it means the same thing in a regex) - exact << part[1, 1] if !exact.nil? + exact << part[1, 1] unless exact.nil? if regexp_escape_characters.include?(part[1, 1]) regexp << part else @@ -294,7 +294,7 @@ class Chef exact = nil regexp << part else - exact += part if !exact.nil? + exact += part unless exact.nil? regexp << "\\#{part}" end end diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb index dbf0704c9e..f1e7531de5 100644 --- a/lib/chef/chef_fs/file_system.rb +++ b/lib/chef/chef_fs/file_system.rb @@ -195,7 +195,7 @@ class Chef # Check the outer regex pattern to see if it matches anything on the # filesystem that isn't on the server Chef::ChefFS::FileSystem.list(b_root, pattern).each do |b| - if !found_paths.include?(b.display_path) + unless found_paths.include?(b.display_path) a = Chef::ChefFS::FileSystem.resolve_path(a_root, b.display_path) yield [ a, b ] end @@ -229,7 +229,7 @@ class Chef # Check b for children that aren't in a b.children.each do |b_child| - if !a_children_names.include?(b_child.bare_name) + unless a_children_names.include?(b_child.bare_name) result << [ a.child(b_child.bare_name), b_child ] end end diff --git a/lib/chef/chef_fs/file_system/base_fs_object.rb b/lib/chef/chef_fs/file_system/base_fs_object.rb index e319232b0e..3d9eb5ae4d 100644 --- a/lib/chef/chef_fs/file_system/base_fs_object.rb +++ b/lib/chef/chef_fs/file_system/base_fs_object.rb @@ -108,14 +108,14 @@ class Chef # Override children to report your *actual* list of children as an array. def children - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? [] end # Expand this entry into a chef object (Chef::Role, ::Node, etc.) def chef_object - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? nil end @@ -127,7 +127,7 @@ class Chef # your entry class, and will be called without actually reading the # file_contents. This is used for knife upload /cookbooks/cookbookname. def create_child(name, file_contents) - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise OperationNotAllowedError.new(:create_child, self) end @@ -135,7 +135,7 @@ class Chef # Delete this item, possibly recursively. Entries MUST NOT delete a # directory unless recurse is true. def delete(recurse) - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise OperationNotAllowedError.new(:delete, self) end @@ -171,14 +171,14 @@ class Chef # Read the contents of this file entry. def read - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise OperationNotAllowedError.new(:read, self) end # Write the contents of this file entry. def write(file_contents) - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise OperationNotAllowedError.new(:write, self) end diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb index 67b7e992b3..73f3d4f4e6 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb @@ -85,7 +85,7 @@ class Chef parts[0, parts.length - 1].each do |part| old_container = container container = old_container.children.find { |child| part == child.name } - if !container + unless container container = CookbookSubdir.new(part, old_container, false, true) old_container.add_child(container) end @@ -117,7 +117,7 @@ class Chef end end else - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise MustDeleteRecursivelyError.new(self, "#{path_for_printing} must be deleted recursively") end @@ -133,7 +133,7 @@ class Chef end def compare_to(other) - if !other.dir? + unless other.dir? return [ !exists?, nil, nil ] end diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb index d1b415baf1..b21e13b256 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb @@ -39,7 +39,7 @@ class Chef def can_have_child?(name, is_dir) if is_dir - return false if !@recursive + return false unless @recursive else return false if @ruby_only && name !~ /\.rb$/ end diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb index dfacc7f5ec..21b7cdaff8 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb @@ -88,7 +88,7 @@ class Chef # Work around the fact that CookbookUploader doesn't understand chef_repo_path (yet) def with_actual_cookbooks_dir(actual_cookbook_path) old_cookbook_path = Chef::Config.cookbook_path - Chef::Config.cookbook_path = actual_cookbook_path if !Chef::Config.cookbook_path + Chef::Config.cookbook_path = actual_cookbook_path unless Chef::Config.cookbook_path yield ensure diff --git a/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb b/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb index 317fbb91cc..8970ad9b3e 100644 --- a/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb @@ -48,8 +48,8 @@ class Chef end def delete(recurse) - if !recurse - raise NotFoundError.new(self) if !exists? + unless recurse + raise NotFoundError.new(self) unless exists? raise MustDeleteRecursivelyError.new(self, "#{path_for_printing} must be deleted recursively") end diff --git a/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb b/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb index f213430d14..5425f8a2a5 100644 --- a/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb @@ -40,13 +40,13 @@ class Chef end def delete(recurse) - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise DefaultEnvironmentCannotBeModifiedError.new(:delete, self) end def write(file_contents) - raise NotFoundError.new(self) if !exists? + raise NotFoundError.new(self) unless exists? raise DefaultEnvironmentCannotBeModifiedError.new(:write, self) end diff --git a/lib/chef/chef_fs/file_system/memory/memory_dir.rb b/lib/chef/chef_fs/file_system/memory/memory_dir.rb index fdef10ff56..e52a4b7c0f 100644 --- a/lib/chef/chef_fs/file_system/memory/memory_dir.rb +++ b/lib/chef/chef_fs/file_system/memory/memory_dir.rb @@ -38,7 +38,7 @@ class Chef dir = self path_parts.each do |path_part| subdir = dir.child(path_part) - if !subdir.exists? + unless subdir.exists? subdir = MemoryDir.new(path_part, dir) dir.add_child(subdir) end diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb index 2d8699621b..74170cc7a9 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb @@ -70,7 +70,7 @@ class Chef # Write out .uploaded-cookbook-version.json # cookbook_file_path = File.join(file_path, cookbook_name) <- this should be the same as self.file_path - if !File.exists?(file_path) + unless File.exists?(file_path) FileUtils.mkdir_p(file_path) end uploaded_cookbook_version_path = File.join(file_path, Chef::Cookbook::CookbookVersionLoader::UPLOADED_COOKBOOK_VERSION_FILE) @@ -83,7 +83,7 @@ class Chef def chef_object cb = cookbook_version - if !cb + unless cb Chef::Log.error("Cookbook #{file_path} empty.") raise "Cookbook #{file_path} empty." end diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb index a68277d567..31ccf1b24f 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb @@ -122,7 +122,7 @@ class Chef FileSystemCache.instance.delete!(file_path) begin if dir? - if !recurse + unless recurse raise MustDeleteRecursivelyError.new(self, $!) end diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb index 6b5da9421c..2af4a9dd52 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb @@ -179,7 +179,7 @@ class Chef # def make_child_entry(name) if CHILDREN.include?(name) - return nil if !root_dir + return nil unless root_dir return root_dir.child(name) end diff --git a/lib/chef/chef_fs/file_system/repository/directory.rb b/lib/chef/chef_fs/file_system/repository/directory.rb index 1275cb4621..37a7081173 100644 --- a/lib/chef/chef_fs/file_system/repository/directory.rb +++ b/lib/chef/chef_fs/file_system/repository/directory.rb @@ -139,7 +139,7 @@ class Chef def delete(recurse) if exists? - if !recurse + unless recurse raise MustDeleteRecursivelyError.new(self, $!) end diff --git a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb index ed6a3d598c..6cb77a15a4 100644 --- a/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +++ b/lib/chef/chef_fs/file_system/repository/file_system_entry.rb @@ -109,7 +109,7 @@ class Chef def delete(recurse) if dir? - if !recurse + unless recurse raise MustDeleteRecursivelyError.new(self, $!) end diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb index 143b38aef8..1780b56239 100644 --- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb @@ -198,7 +198,7 @@ class Chef # If we exited early, perhaps due to any? finding a result, we want # to make sure and throw away any extra results (gracefully) so that # the next enumerator can start over. - if !finished? + unless finished? stop end raise |