summaryrefslogtreecommitdiff
path: root/lib/chef/chef_fs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/chef_fs')
-rw-r--r--lib/chef/chef_fs/chef_fs_data_store.rb20
-rw-r--r--lib/chef/chef_fs/config.rb9
-rw-r--r--lib/chef/chef_fs/data_handler/data_handler_base.rb8
-rw-r--r--lib/chef/chef_fs/file_pattern.rb18
-rw-r--r--lib/chef/chef_fs/file_system.rb6
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb6
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb1
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb4
-rw-r--r--lib/chef/chef_fs/file_system/memory/memory_file.rb1
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/repository/file_system_entry.rb8
-rw-r--r--lib/chef/chef_fs/knife.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer/flatten_enumerable.rb2
-rw-r--r--lib/chef/chef_fs/parallelizer/parallel_enumerable.rb2
-rw-r--r--lib/chef/chef_fs/path_utils.rb5
20 files changed, 52 insertions, 52 deletions
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb
index 389cea472e..7cf7d5f8d9 100644
--- a/lib/chef/chef_fs/chef_fs_data_store.rb
+++ b/lib/chef/chef_fs/chef_fs_data_store.rb
@@ -154,7 +154,7 @@ class Chef
# Generally will be a +ChefFS::FileSystem::ChefRepositoryFileSystemRoot+
# object, created from +ChefFS::Config.local_fs+.
#
- def initialize(chef_fs, chef_config=Chef::Config)
+ def initialize(chef_fs, chef_config = Chef::Config)
@chef_fs = chef_fs
@memory_store = ChefZero::DataStore::MemoryStore.new
@repo_mode = chef_config[:repo_mode]
@@ -260,7 +260,7 @@ class Chef
end
end
- def get(path, request=nil)
+ def get(path, request = nil)
if use_memory_store?(path)
@memory_store.get(path)
@@ -335,11 +335,11 @@ class Chef
if cookbook_type == "cookbook_artifacts"
result["metadata"] = result["metadata"].to_hash
- result["metadata"].delete_if do |key,value|
+ result["metadata"].delete_if do |key, value|
value == [] ||
- (value == {} && !%w{dependencies attributes recipes}.include?(key)) ||
- (value == "" && %w{source_url issues_url}.include?(key)) ||
- (value == false && key == "privacy")
+ (value == {} && !%w{dependencies attributes recipes}.include?(key)) ||
+ (value == "" && %w{source_url issues_url}.include?(key)) ||
+ (value == false && key == "privacy")
end
end
@@ -537,8 +537,8 @@ class Chef
result = with_entry([ path[0] ]) do |entry|
# list /cookbooks/name = filter /cookbooks/name-version down to name
entry.children.map { |child| split_name_version(child.name) }.
- select { |name, version| name == path[1] }.
- map { |name, version| version }
+ select { |name, version| name == path[1] }.
+ map { |name, version| version }
end
if result.empty?
raise ChefZero::DataStore::DataNotFoundError.new(path)
@@ -651,7 +651,7 @@ class Chef
name_version = entry_name.split("-")
name = name_version[0..-2].join("-")
version = name_version[-1]
- [name,version]
+ [name, version]
end
def to_chef_fs_path(path)
@@ -798,7 +798,7 @@ class Chef
end
end
- def get_dir(path, create=false)
+ def get_dir(path, create = false)
result = Chef::ChefFS::FileSystem.resolve_path(chef_fs, path.join("/"))
if result.exists?
result
diff --git a/lib/chef/chef_fs/config.rb b/lib/chef/chef_fs/config.rb
index 19cea3b4ea..5eae0501a1 100644
--- a/lib/chef/chef_fs/config.rb
+++ b/lib/chef/chef_fs/config.rb
@@ -44,7 +44,7 @@ class Chef
"policies" => "policy",
"policy_groups" => "policy_group",
}
- INFLECTIONS.each { |k,v| k.freeze; v.freeze }
+ INFLECTIONS.each { |k, v| k.freeze; v.freeze }
INFLECTIONS.freeze
# ChefFS supports three modes of operation: "static", "everything", and
@@ -74,7 +74,6 @@ class Chef
EVERYTHING_MODE_OBJECT_NAMES = (CHEF_11_OSS_STATIC_OBJECTS + CHEF_11_OSS_DYNAMIC_OBJECTS).freeze
HOSTED_EVERYTHING_MODE_OBJECT_NAMES = (EVERYTHING_MODE_OBJECT_NAMES + RBAC_OBJECT_NAMES + CHEF_12_OBJECTS).freeze
-
#
# Create a new Config object which can produce a chef_fs and local_fs.
#
@@ -243,12 +242,12 @@ class Chef
# Print the given server path, relative to the current directory
def format_path(entry)
server_path = entry.path
- if base_path && server_path[0,base_path.length] == base_path
+ if base_path && server_path[0, base_path.length] == base_path
if server_path == base_path
return "."
- elsif server_path[base_path.length,1] == "/"
+ elsif server_path[base_path.length, 1] == "/"
return server_path[base_path.length + 1, server_path.length - base_path.length - 1]
- elsif base_path == "/" && server_path[0,1] == "/"
+ elsif base_path == "/" && server_path[0, 1] == "/"
return server_path[1, server_path.length - 1]
end
end
diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb
index 41c5dd13e2..b8d0b7cd4f 100644
--- a/lib/chef/chef_fs/data_handler/data_handler_base.rb
+++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb
@@ -28,10 +28,10 @@ class Chef
# Takes a name like blah.json and removes the .json from it.
#
def remove_dot_json(name)
- if name.length < 5 || name[-5,5] != ".json"
+ if name.length < 5 || name[-5, 5] != ".json"
raise "Invalid name #{path}: must end in .json"
end
- name[0,name.length-5]
+ name[0, name.length - 5]
end
#
@@ -154,11 +154,11 @@ class Chef
if object[key].size > 0
result << key
first = true
- object[key].each_pair do |k,v|
+ object[key].each_pair do |k, v|
if first
first = false
else
- result << " "*key.length
+ result << " " * key.length
end
result << " #{k.inspect} => #{v.inspect}\n"
end
diff --git a/lib/chef/chef_fs/file_pattern.rb b/lib/chef/chef_fs/file_pattern.rb
index 74be64cd84..5beec6dfdd 100644
--- a/lib/chef/chef_fs/file_pattern.rb
+++ b/lib/chef/chef_fs/file_pattern.rb
@@ -74,13 +74,13 @@ class Chef
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 = path[1, path.length - 1] if argument_is_absolute
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.
- return false if path_parts.zip(regexp_parts).any? { |part,regexp| !regexp.nil? && !regexp.match(part) }
+ return false if path_parts.zip(regexp_parts).any? { |part, regexp| !regexp.nil? && !regexp.match(part) }
# Otherwise, it's possible we could match: the path matches to this point, and the pattern is longer than the path.
# TODO There is one edge case where the double star comes after some characters like abc**def--we could check whether the next
# bit of path starts with abc in that case.
@@ -111,7 +111,7 @@ 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)
+ 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]
@@ -151,7 +151,7 @@ class Chef
def match?(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 = path[1, path.length - 1] if argument_is_absolute
!!regexp.match(path)
end
@@ -275,15 +275,15 @@ class Chef
exact = nil
regexp << "."
else
- if part[0,1] == '\\' && part.length == 2
+ 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?
- if regexp_escape_characters.include?(part[1,1])
+ exact << part[1, 1] if !exact.nil?
+ if regexp_escape_characters.include?(part[1, 1])
regexp << part
else
- regexp << part[1,1]
+ regexp << part[1, 1]
end
- elsif part[0,1] == "[" && part.length > 1
+ elsif part[0, 1] == "[" && part.length > 1
# [...] happens only on Unix, and is handled here by *not* backslashing (it means the same thing in and out of regex)
exact = nil
regexp << part
diff --git a/lib/chef/chef_fs/file_system.rb b/lib/chef/chef_fs/file_system.rb
index 6e25623a21..5865dd4b7c 100644
--- a/lib/chef/chef_fs/file_system.rb
+++ b/lib/chef/chef_fs/file_system.rb
@@ -95,9 +95,9 @@ class Chef
#
def self.resolve_path(entry, path)
return entry if path.length == 0
- return resolve_path(entry.root, path) if path[0,1] == "/" && entry.root != entry
- if path[0,1] == "/"
- path = path[1,path.length-1]
+ return resolve_path(entry.root, path) if path[0, 1] == "/" && entry.root != entry
+ if path[0, 1] == "/"
+ path = path[1, path.length - 1]
end
result = entry
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 feb126f036..a6a062ab3c 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
@@ -58,7 +58,7 @@ class Chef
:files => { :recursive => true },
:resources => { :ruby_only => true, :recursive => true },
:providers => { :ruby_only => true, :recursive => true },
- :root_files => { },
+ :root_files => {},
}
def add_child(child)
@@ -99,7 +99,7 @@ class Chef
parts = segment_file[:path].split("/")
# Get or create the path to the file
container = self
- parts[0,parts.length-1].each do |part|
+ parts[0, parts.length - 1].each do |part|
old_container = container
container = old_container.children.select { |child| part == child.name }.first
if !container
@@ -108,7 +108,7 @@ class Chef
end
end
# Create the file itself
- container.add_child(CookbookFile.new(parts[parts.length-1], container, segment_file))
+ container.add_child(CookbookFile.new(parts[parts.length - 1], container, segment_file))
end
end
@children = @children.sort_by { |c| c.name }
diff --git a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
index 986a04ff4a..37b7af8b5e 100644
--- a/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb
@@ -37,7 +37,7 @@ class Chef
def write(contents)
desired_invites = minimize_value(Chef::JSONCompat.parse(contents, :create_additions => false))
- actual_invites = _read_json.inject({}) { |h,val| h[val["username"]] = val["id"]; h }
+ actual_invites = _read_json.inject({}) { |h, val| h[val["username"]] = val["id"]; h }
invites = actual_invites.keys
(desired_invites - invites).each do |invite|
begin
diff --git a/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb b/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
index 941c0268cc..d083383a0e 100644
--- a/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb
@@ -10,7 +10,7 @@ class Chef
class PolicyRevisionEntry < RestListEntry
# /policies/foo-1.0.0.json -> /policies/foo/revisions/1.0.0
- def api_path(options={})
+ def api_path(options = {})
"#{parent.api_path}/#{policy_name}/revisions/#{revision_id}"
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
index 6791b0cd29..488e9c0ed0 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb
@@ -60,7 +60,6 @@ class Chef
# the server version directly, and can't ask the server for a list of the endpoints it supports.
#
-
#
# Does GET /<api_path>, assumes the result is of the format:
#
diff --git a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
index 5af91e3768..5b9252ba03 100644
--- a/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb
@@ -38,10 +38,10 @@ class Chef
end
def api_child_name
- if name.length < 5 || name[-5,5] != ".json"
+ if name.length < 5 || name[-5, 5] != ".json"
raise "Invalid name #{path}: must end in .json"
end
- name[0,name.length-5]
+ name[0, name.length - 5]
end
def api_path
diff --git a/lib/chef/chef_fs/file_system/memory/memory_file.rb b/lib/chef/chef_fs/file_system/memory/memory_file.rb
index 644273fa9f..7eabc8fcb1 100644
--- a/lib/chef/chef_fs/file_system/memory/memory_file.rb
+++ b/lib/chef/chef_fs/file_system/memory/memory_file.rb
@@ -9,6 +9,7 @@ class Chef
super(name, parent)
@value = value
end
+
def read
return @value
end
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
index 84f665066e..fa6ce9ba9e 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir.rb
@@ -59,7 +59,7 @@ class Chef
# Use the copy/diff algorithm to copy it down so we don't destroy
# chefignored data. This is terribly un-thread-safe.
- Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, child, nil, {:purge => true})
+ Chef::ChefFS::FileSystem.copy_to(Chef::ChefFS::FilePattern.new("/#{cookbook_path}"), from_fs, child, nil, { :purge => true })
# Write out .uploaded-cookbook-version.json
cookbook_file_path = File.join(file_path, cookbook_name)
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 37bd6fa1ac..5f238888d5 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
@@ -60,7 +60,7 @@ class Chef
# [chef_config] - a hash of options that looks suspiciously like the ones
# stored in Chef::Config, containing at least these keys:
# :versioned_cookbooks:: whether to include versions in cookbook names
- def initialize(child_paths, root_paths=[], chef_config=Chef::Config)
+ def initialize(child_paths, root_paths = [], chef_config = Chef::Config)
super("", nil)
@child_paths = child_paths
@root_paths = root_paths
diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
index f9a66240eb..5dc74d85da 100644
--- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
+++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb
@@ -29,7 +29,7 @@ class Chef
# We need the canonical cookbook name if we are using versioned cookbooks, but we don't
# want to spend a lot of time adding code to the main Chef libraries
canonical_name = canonical_cookbook_name(File.basename(file_path))
- raise "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless canonical_name
+ raise "When versioned_cookbooks mode is on, cookbook #{file_path} must match format <cookbook_name>-x.y.z" unless canonical_name
# KLUDGE: We shouldn't have to use instance_variable_set
loader.instance_variable_set(:@cookbook_name, canonical_name)
loader.load_cookbooks
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 ac6c85db22..bee017f7a8 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
@@ -44,14 +44,14 @@ class Chef
# Except cookbooks and data bag dirs, all things must be json files
begin
Dir.entries(file_path).sort.
- map { |child_name| make_child_entry(child_name) }.
- select { |child| child && can_have_child?(child.name, child.dir?) }
+ map { |child_name| make_child_entry(child_name) }.
+ select { |child| child && can_have_child?(child.name, child.dir?) }
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
end
- def create_child(child_name, file_contents=nil)
+ def create_child(child_name, file_contents = nil)
child = make_child_entry(child_name)
if child.exists?
raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
@@ -93,7 +93,7 @@ class Chef
def read
begin
- File.open(file_path, "rb") {|f| f.read}
+ File.open(file_path, "rb") { |f| f.read }
rescue Errno::ENOENT
raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
end
diff --git a/lib/chef/chef_fs/knife.rb b/lib/chef/chef_fs/knife.rb
index 90d4eddc07..399bf1c434 100644
--- a/lib/chef/chef_fs/knife.rb
+++ b/lib/chef/chef_fs/knife.rb
@@ -111,7 +111,7 @@ class Chef
end
# Use the original path because we can't be sure.
inferred_path = arg
- elsif arg[0,1] == "~"
+ elsif arg[0, 1] == "~"
# Let's be nice and fix it if possible - but warn the user.
ui.warn("A path relative to a user home directory has been provided: #{arg}")
ui.warn("Paths provided need to be rooted at the chef-repo being considered or be relative paths.")
diff --git a/lib/chef/chef_fs/parallelizer.rb b/lib/chef/chef_fs/parallelizer.rb
index 6590431d91..5d05f41e94 100644
--- a/lib/chef/chef_fs/parallelizer.rb
+++ b/lib/chef/chef_fs/parallelizer.rb
@@ -54,7 +54,7 @@ class Chef
def resize(to_threads, wait = true, timeout = nil)
if to_threads < num_threads
- threads_to_stop = @threads[to_threads..num_threads-1]
+ threads_to_stop = @threads[to_threads..num_threads - 1]
@threads = @threads.slice(0, to_threads)
threads_to_stop.each do |thread|
@stop_thread[thread] = true
diff --git a/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb b/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb
index 7321aa0664..6094fab493 100644
--- a/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb
@@ -23,7 +23,7 @@ class Chef
def flatten(value, levels, &block)
if levels != 0 && value.respond_to?(:each) && !value.is_a?(String)
value.each do |child|
- flatten(child, levels.nil? ? levels : levels-1, &block)
+ flatten(child, levels.nil? ? levels : levels - 1, &block)
end
else
block.call(value)
diff --git a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
index 60f283eabe..8df6a76e13 100644
--- a/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
+++ b/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb
@@ -92,7 +92,7 @@ class Chef
end
end
- def first(n=nil)
+ def first(n = nil)
if n
restricted_copy(@input_enumerable.first(n)).to_a
else
diff --git a/lib/chef/chef_fs/path_utils.rb b/lib/chef/chef_fs/path_utils.rb
index 66dbd4f13b..8ec5c3df78 100644
--- a/lib/chef/chef_fs/path_utils.rb
+++ b/lib/chef/chef_fs/path_utils.rb
@@ -64,6 +64,7 @@ class Chef
def self.is_absolute?(path)
!!(path =~ /^#{regexp_path_separator}/)
end
+
# Given a path which may only be partly real (i.e. /x/y/z when only /x exists,
# or /x/y/*/blah when /x/y/z/blah exists), call File.realpath on the biggest
# part that actually exists. The paths operated on here are not Chef-FS paths.
@@ -114,8 +115,8 @@ class Chef
return nil unless PathUtils.os_path_eq?(candidate_fragment, ancestor)
if ancestor.length == path.length
""
- elsif path[ancestor.length,1] =~ /#{PathUtils.regexp_path_separator}/
- path[ancestor.length+1..-1]
+ elsif path[ancestor.length, 1] =~ /#{PathUtils.regexp_path_separator}/
+ path[ancestor.length + 1..-1]
else
nil
end