diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-09 07:53:56 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-09 07:53:56 -0800 |
commit | f073747786abbe6ada55ed24b696a03e39c3c45d (patch) | |
tree | 7971d871e89d522a58291713761a6c83f68e8d19 /lib/chef/chef_fs | |
parent | c6e69783705cfd48bfea0c943dc071964dd21311 (diff) | |
download | chef-f073747786abbe6ada55ed24b696a03e39c3c45d.tar.gz |
auto fixing some rubocops
Style/NegatedWhile
Style/ParenthesesAroundCondition
Style/WhileUntilDo
Style/WordArray
Performance/ReverseEach
Style/ColonMethodCall
Diffstat (limited to 'lib/chef/chef_fs')
-rw-r--r-- | lib/chef/chef_fs/chef_fs_data_store.rb | 6 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_pattern.rb | 24 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/base_fs_object.rb | 4 | ||||
-rw-r--r-- | lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/knife.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/parallelizer.rb | 2 | ||||
-rw-r--r-- | lib/chef/chef_fs/parallelizer/parallel_enumerable.rb | 6 | ||||
-rw-r--r-- | lib/chef/chef_fs/path_utils.rb | 6 |
9 files changed, 28 insertions, 28 deletions
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb index 7cf7d5f8d9..f1a114e7f1 100644 --- a/lib/chef/chef_fs/chef_fs_data_store.rb +++ b/lib/chef/chef_fs/chef_fs_data_store.rb @@ -327,7 +327,7 @@ class Chef relative << path[1] end relative = relative + file[:path].split("/") - file["url"] = ChefZero::RestBase::build_uri(request.base_uri, relative) + file["url"] = ChefZero::RestBase.build_uri(request.base_uri, relative) end end end @@ -610,7 +610,7 @@ class Chef private def use_memory_store?(path) - return path[0] == "sandboxes" || path[0] == "file_store" && path[1] == "checksums" || path == [ "environments", "_default" ] + return path[0] == "sandboxes" || path[0] == "file_store" && path[1] == "checksums" || path == %w(environments _default) end def write_cookbook(path, data, *options) @@ -704,7 +704,7 @@ class Chef # /acls/containers|nodes|.../x.json # /acls/organization.json - if path.length == 3 || path == [ "acls", "organization" ] + if path.length == 3 || path == %w(acls organization) path = path.dup path[-1] = "#{path[-1]}.json" end diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb index 5beec6dfdd..a308a0fe2c 100644 --- a/lib/chef/chef_fs/file_pattern.rb +++ b/lib/chef/chef_fs/file_pattern.rb @@ -72,11 +72,11 @@ class Chef def could_match_children?(path) return false if path == "" # Empty string is not a path - argument_is_absolute = Chef::ChefFS::PathUtils::is_absolute?(path) + argument_is_absolute = Chef::ChefFS::PathUtils.is_absolute?(path) return false if is_absolute != argument_is_absolute path = path[1, path.length - 1] if argument_is_absolute - path_parts = Chef::ChefFS::PathUtils::split(path) + path_parts = Chef::ChefFS::PathUtils.split(path) # If the pattern is shorter than the path (or same size), children will be larger than the pattern, and will not match. return false if regexp_parts.length <= path_parts.length && !has_double_star # If the path doesn't match up to this point, children won't match either. @@ -111,8 +111,8 @@ class Chef # # This method assumes +could_match_children?(path)+ is +true+. def exact_child_name_under(path) - path = path[1, path.length - 1] if Chef::ChefFS::PathUtils::is_absolute?(path) - dirs_in_path = Chef::ChefFS::PathUtils::split(path).length + path = path[1, path.length - 1] if Chef::ChefFS::PathUtils.is_absolute?(path) + dirs_in_path = Chef::ChefFS::PathUtils.split(path).length return nil if exact_parts.length <= dirs_in_path return exact_parts[dirs_in_path] end @@ -124,8 +124,8 @@ class Chef # abc/x\\yz.exact_path == 'abc/xyz' def exact_path return nil if has_double_star || exact_parts.any? { |part| part.nil? } - result = Chef::ChefFS::PathUtils::join(*exact_parts) - is_absolute ? Chef::ChefFS::PathUtils::join("", result) : result + result = Chef::ChefFS::PathUtils.join(*exact_parts) + is_absolute ? Chef::ChefFS::PathUtils.join("", result) : result end # Returns the normalized version of the pattern, with / as the directory @@ -149,7 +149,7 @@ class Chef # abc/*/def.match?('abc/foo/def') == true # abc/*/def.match?('abc/foo') == false def match?(path) - argument_is_absolute = Chef::ChefFS::PathUtils::is_absolute?(path) + argument_is_absolute = Chef::ChefFS::PathUtils.is_absolute?(path) return false if is_absolute != argument_is_absolute path = path[1, path.length - 1] if argument_is_absolute !!regexp.match(path) @@ -184,7 +184,7 @@ class Chef def calculate if !@regexp - @is_absolute = Chef::ChefFS::PathUtils::is_absolute?(@pattern) + @is_absolute = Chef::ChefFS::PathUtils.is_absolute?(@pattern) full_regexp_parts = [] normalized_parts = [] @@ -192,8 +192,8 @@ class Chef @exact_parts = [] @has_double_star = false - Chef::ChefFS::PathUtils::split(pattern).each do |part| - regexp, exact, has_double_star = FilePattern::pattern_to_regexp(part) + Chef::ChefFS::PathUtils.split(pattern).each do |part| + regexp, exact, has_double_star = FilePattern.pattern_to_regexp(part) if has_double_star @has_double_star = true end @@ -232,14 +232,14 @@ class Chef end end - @regexp = Regexp.new("^#{full_regexp_parts.join(Chef::ChefFS::PathUtils::regexp_path_separator)}$") + @regexp = Regexp.new("^#{full_regexp_parts.join(Chef::ChefFS::PathUtils.regexp_path_separator)}$") @normalized_pattern = Chef::ChefFS::PathUtils.join(*normalized_parts) @normalized_pattern = Chef::ChefFS::PathUtils.join("", @normalized_pattern) if @is_absolute end end def self.pattern_special_characters - if Chef::ChefFS::windows? + if Chef::ChefFS.windows? @pattern_special_characters ||= /(\*\*|\*|\?|[\*\?\.\|\(\)\[\]\{\}\+\\\\\^\$])/ else # Unix also supports character regexes and backslashes diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb index 5865dd4b7c..415556300c 100644 --- a/lib/chef/chef_fs/file_system.rb +++ b/lib/chef/chef_fs/file_system.rb @@ -72,7 +72,7 @@ class Chef # Otherwise, go through all children and find any matches elsif entry.dir? - results = Parallelizer::parallelize(entry.children) { |child| Chef::ChefFS::FileSystem.list(child, pattern) } + results = Parallelizer.parallelize(entry.children) { |child| Chef::ChefFS::FileSystem.list(child, pattern) } results.flatten(1).each(&block) end end @@ -101,7 +101,7 @@ class Chef end result = entry - Chef::ChefFS::PathUtils::split(path).each do |part| + Chef::ChefFS::PathUtils.split(path).each do |part| result = result.child(part) end result 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 19f98f2bdd..cf1aed552f 100644 --- a/lib/chef/chef_fs/file_system/base_fs_object.rb +++ b/lib/chef/chef_fs/file_system/base_fs_object.rb @@ -27,7 +27,7 @@ class Chef @parent = parent @name = name if parent - @path = Chef::ChefFS::PathUtils::join(parent.path, name) + @path = Chef::ChefFS::PathUtils.join(parent.path, name) else if name != "" raise ArgumentError, "Name of root object must be empty string: was '#{name}' instead" @@ -149,7 +149,7 @@ class Chef if parent_path == "." name else - Chef::ChefFS::PathUtils::join(parent.path_for_printing, name) + Chef::ChefFS::PathUtils.join(parent.path_for_printing, name) end else name 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 a6a062ab3c..3a08768baf 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 @@ -153,7 +153,7 @@ class Chef return [ !exists?, nil, nil ] end are_same = true - Chef::ChefFS::CommandLine::diff_entries(self, other, nil, :name_only).each do |type, old_entry, new_entry| + Chef::ChefFS::CommandLine.diff_entries(self, other, nil, :name_only).each do |type, old_entry, new_entry| if [ :directory_to_file, :file_to_directory, :deleted, :added, :modified ].include?(type) are_same = false end diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb index 399bf1c434..1731e19ce1 100644 --- a/lib/chef/chef_fs/knife.rb +++ b/lib/chef/chef_fs/knife.rb @@ -131,7 +131,7 @@ class Chef ui.error("Current working directory is '#{@chef_fs_config.cwd}'.") exit(1) else - inferred_path = Chef::ChefFS::PathUtils::join(@chef_fs_config.base_path, arg) + inferred_path = Chef::ChefFS::PathUtils.join(@chef_fs_config.base_path, arg) end Chef::ChefFS::FilePattern.new(inferred_path) end diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb index 5d05f41e94..ccbf7ad96e 100644 --- a/lib/chef/chef_fs/parallelizer.rb +++ b/lib/chef/chef_fs/parallelizer.rb @@ -87,7 +87,7 @@ class Chef def worker_loop begin - while !@stop_thread[Thread.current] + until @stop_thread[Thread.current] begin task = @tasks.pop task.call diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb index 8df6a76e13..9d02bbab78 100644 --- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb @@ -157,7 +157,7 @@ class Chef @parent_task_queue.push(method(:process_one)) stop_processing_input = false - while !@unconsumed_output.empty? + until @unconsumed_output.empty? output, index, input, type = @unconsumed_output.pop yield output, index, input, type if type == :exception && @options[:stop_on_exception] @@ -178,13 +178,13 @@ class Chef end end - while !finished? + until finished? # yield thread to others (for 1.8.7) if @unconsumed_output.empty? sleep(0.01) end - while !@unconsumed_output.empty? + until @unconsumed_output.empty? yield @unconsumed_output.pop end diff --git a/lib/chef/chef_fs/path_utils.rb b/lib/chef/chef_fs/path_utils.rb index 8ec5c3df78..7b2de5e3e0 100644 --- a/lib/chef/chef_fs/path_utils.rb +++ b/lib/chef/chef_fs/path_utils.rb @@ -57,7 +57,7 @@ class Chef end def self.regexp_path_separator - Chef::ChefFS::windows? ? '[\/\\\\]' : "/" + Chef::ChefFS.windows? ? '[\/\\\\]' : "/" end # Given a server path, determines if it is absolute. @@ -83,7 +83,7 @@ class Chef # File.dirname happens to return the path as its own dirname if you're # at the root (such as at \\foo\bar, C:\ or /) - until parent_path == path do + until parent_path == path # This can occur if a path such as "C:" is given. Ruby gives the parent as "C:." # for reasons only it knows. raise ArgumentError "Invalid path segment #{path}" if parent_path.length > path.length @@ -101,7 +101,7 @@ class Chef # Compares two path fragments according to the case-sentitivity of the host platform. def self.os_path_eq?(left, right) - Chef::ChefFS::windows? ? left.casecmp(right) == 0 : left == right + Chef::ChefFS.windows? ? left.casecmp(right) == 0 : left == right end # Given two general OS-dependent file paths, determines the relative path of the |