summaryrefslogtreecommitdiff
path: root/lib/chef_zero/data_store
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef_zero/data_store')
-rw-r--r--lib/chef_zero/data_store/data_already_exists_error.rb2
-rw-r--r--lib/chef_zero/data_store/data_not_found_error.rb4
-rw-r--r--lib/chef_zero/data_store/default_facade.rb10
-rw-r--r--lib/chef_zero/data_store/interface_v1.rb2
-rw-r--r--lib/chef_zero/data_store/interface_v2.rb2
-rw-r--r--lib/chef_zero/data_store/memory_store.rb8
-rw-r--r--lib/chef_zero/data_store/memory_store_v2.rb16
-rw-r--r--lib/chef_zero/data_store/raw_file_store.rb20
-rw-r--r--lib/chef_zero/data_store/v1_to_v2_adapter.rb18
-rw-r--r--lib/chef_zero/data_store/v2_to_v1_adapter.rb10
10 files changed, 46 insertions, 46 deletions
diff --git a/lib/chef_zero/data_store/data_already_exists_error.rb b/lib/chef_zero/data_store/data_already_exists_error.rb
index 54116d0..60f5b57 100644
--- a/lib/chef_zero/data_store/data_already_exists_error.rb
+++ b/lib/chef_zero/data_store/data_already_exists_error.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'chef_zero/data_store/data_error'
+require "chef_zero/data_store/data_error"
module ChefZero
module DataStore
diff --git a/lib/chef_zero/data_store/data_not_found_error.rb b/lib/chef_zero/data_store/data_not_found_error.rb
index a73d767..508b460 100644
--- a/lib/chef_zero/data_store/data_not_found_error.rb
+++ b/lib/chef_zero/data_store/data_not_found_error.rb
@@ -16,7 +16,7 @@
# limitations under the License.
#
-require 'chef_zero/data_store/data_error'
+require "chef_zero/data_store/data_error"
module ChefZero
module DataStore
@@ -26,4 +26,4 @@ module ChefZero
end
end
end
-end \ No newline at end of file
+end
diff --git a/lib/chef_zero/data_store/default_facade.rb b/lib/chef_zero/data_store/default_facade.rb
index c941322..5e932d5 100644
--- a/lib/chef_zero/data_store/default_facade.rb
+++ b/lib/chef_zero/data_store/default_facade.rb
@@ -1,5 +1,5 @@
-require 'chef_zero/data_store/interface_v2'
-require 'chef_zero/chef_data/default_creator'
+require "chef_zero/data_store/interface_v2"
+require "chef_zero/chef_data/default_creator"
module ChefZero
module DataStore
@@ -65,7 +65,7 @@ module ChefZero
default_creator.created(path + [ name ], options_hash[:requestor], options.include?(:create_dir))
end
- def get(path, request=nil)
+ def get(path, request = nil)
begin
real_store.get(path, request)
rescue DataNotFoundError
@@ -83,8 +83,8 @@ module ChefZero
real_store.set(path, data, *options)
rescue DataNotFoundError
if options.include?(:create_dir) ||
- options.include?(:create) && default_creator.exists?(path[0..-2]) ||
- default_creator.exists?(path)
+ options.include?(:create) && default_creator.exists?(path[0..-2]) ||
+ default_creator.exists?(path)
real_store.set(path, data, :create, :create_dir, *options)
else
raise
diff --git a/lib/chef_zero/data_store/interface_v1.rb b/lib/chef_zero/data_store/interface_v1.rb
index 8630a35..0a406f5 100644
--- a/lib/chef_zero/data_store/interface_v1.rb
+++ b/lib/chef_zero/data_store/interface_v1.rb
@@ -24,7 +24,7 @@ module ChefZero
end
# Get a file.
- def get(path, request=nil)
+ def get(path, request = nil)
raise "get not implemented by class #{self.class}"
end
diff --git a/lib/chef_zero/data_store/interface_v2.rb b/lib/chef_zero/data_store/interface_v2.rb
index fa1ba41..8c02e2e 100644
--- a/lib/chef_zero/data_store/interface_v2.rb
+++ b/lib/chef_zero/data_store/interface_v2.rb
@@ -1,4 +1,4 @@
-require 'chef_zero/data_store/interface_v1'
+require "chef_zero/data_store/interface_v1"
module ChefZero
module DataStore
diff --git a/lib/chef_zero/data_store/memory_store.rb b/lib/chef_zero/data_store/memory_store.rb
index bfbe9d6..fa2a9cf 100644
--- a/lib/chef_zero/data_store/memory_store.rb
+++ b/lib/chef_zero/data_store/memory_store.rb
@@ -16,16 +16,16 @@
# limitations under the License.
#
-require 'chef_zero/data_store/v2_to_v1_adapter'
-require 'chef_zero/data_store/memory_store_v2'
-require 'chef_zero/data_store/default_facade'
+require "chef_zero/data_store/v2_to_v1_adapter"
+require "chef_zero/data_store/memory_store_v2"
+require "chef_zero/data_store/default_facade"
module ChefZero
module DataStore
class MemoryStore < ChefZero::DataStore::V2ToV1Adapter
def initialize
super
- @real_store = ChefZero::DataStore::DefaultFacade.new(ChefZero::DataStore::MemoryStoreV2.new, 'chef', true)
+ @real_store = ChefZero::DataStore::DefaultFacade.new(ChefZero::DataStore::MemoryStoreV2.new, "chef", true)
clear
end
end
diff --git a/lib/chef_zero/data_store/memory_store_v2.rb b/lib/chef_zero/data_store/memory_store_v2.rb
index d330972..c2f2d8e 100644
--- a/lib/chef_zero/data_store/memory_store_v2.rb
+++ b/lib/chef_zero/data_store/memory_store_v2.rb
@@ -16,9 +16,9 @@
# limitations under the License.
#
-require 'chef_zero/data_store/data_already_exists_error'
-require 'chef_zero/data_store/data_not_found_error'
-require 'chef_zero/data_store/interface_v2'
+require "chef_zero/data_store/data_already_exists_error"
+require "chef_zero/data_store/data_not_found_error"
+require "chef_zero/data_store/interface_v2"
module ChefZero
module DataStore
@@ -58,7 +58,7 @@ module ChefZero
parent[name] = data
end
- def get(path, request=nil)
+ def get(path, request = nil)
value = _get(path)
if value.is_a?(Hash)
raise "get() called on directory #{path.join('/')}"
@@ -81,7 +81,7 @@ module ChefZero
end
def delete(path)
- parent = _get(path[0,path.length-1])
+ parent = _get(path[0, path.length - 1])
if !parent.has_key?(path[-1])
raise DataNotFoundError.new(path)
end
@@ -92,7 +92,7 @@ module ChefZero
end
def delete_dir(path, *options)
- parent = _get(path[0,path.length-1])
+ parent = _get(path[0, path.length - 1])
if !parent.has_key?(path[-1])
raise DataNotFoundError.new(path)
end
@@ -136,14 +136,14 @@ module ChefZero
private
- def _get(path, create_dir=false)
+ def _get(path, create_dir = false)
value = @data
path.each_with_index do |path_part, index|
if !value.has_key?(path_part)
if create_dir
value[path_part] = {}
else
- raise DataNotFoundError.new(path[0,index+1])
+ raise DataNotFoundError.new(path[0, index + 1])
end
end
value = value[path_part]
diff --git a/lib/chef_zero/data_store/raw_file_store.rb b/lib/chef_zero/data_store/raw_file_store.rb
index dce6374..120fc1b 100644
--- a/lib/chef_zero/data_store/raw_file_store.rb
+++ b/lib/chef_zero/data_store/raw_file_store.rb
@@ -16,10 +16,10 @@
# limitations under the License.
#
-require 'chef_zero/data_store/data_already_exists_error'
-require 'chef_zero/data_store/data_not_found_error'
-require 'chef_zero/data_store/interface_v2'
-require 'fileutils'
+require "chef_zero/data_store/data_already_exists_error"
+require "chef_zero/data_store/data_not_found_error"
+require "chef_zero/data_store/interface_v2"
+require "fileutils"
module ChefZero
module DataStore
@@ -32,7 +32,7 @@ module ChefZero
attr_reader :root
attr_reader :destructible
- def path_to(path, name=nil)
+ def path_to(path, name = nil)
if name
File.join(root, *path, name)
else
@@ -43,7 +43,7 @@ module ChefZero
def clear
if destructible
Dir.entries(root).each do |entry|
- next if entry == '.' || entry == '..'
+ next if entry == "." || entry == ".."
FileUtils.rm_rf(Path.join(root, entry))
end
end
@@ -69,7 +69,7 @@ module ChefZero
FileUtils.mkdir_p(path_to(path))
end
begin
- File.open(path_to(path, name), File::WRONLY|File::CREAT|File::EXCL|File::BINARY, :internal_encoding => nil) do |file|
+ File.open(path_to(path, name), File::WRONLY | File::CREAT | File::EXCL | File::BINARY, :internal_encoding => nil) do |file|
file.write data
end
rescue Errno::ENOENT
@@ -79,7 +79,7 @@ module ChefZero
end
end
- def get(path, request=nil)
+ def get(path, request = nil)
begin
return IO.read(path_to(path))
rescue Errno::ENOENT
@@ -92,7 +92,7 @@ module ChefZero
FileUtils.mkdir_p(path_to(path[0..-2]))
end
begin
- mode = File::WRONLY|File::TRUNC|File::BINARY
+ mode = File::WRONLY | File::TRUNC | File::BINARY
if options.include?(:create)
mode |= File::CREAT
end
@@ -129,7 +129,7 @@ module ChefZero
def list(path)
begin
- Dir.entries(path_to(path)).select { |entry| entry != '.' && entry != '..' }.to_a
+ Dir.entries(path_to(path)).select { |entry| entry != "." && entry != ".." }.to_a
rescue Errno::ENOENT
raise DataNotFoundError.new(path)
end
diff --git a/lib/chef_zero/data_store/v1_to_v2_adapter.rb b/lib/chef_zero/data_store/v1_to_v2_adapter.rb
index d9ea6e1..dba35b3 100644
--- a/lib/chef_zero/data_store/v1_to_v2_adapter.rb
+++ b/lib/chef_zero/data_store/v1_to_v2_adapter.rb
@@ -1,4 +1,4 @@
-require 'chef_zero/data_store/interface_v2'
+require "chef_zero/data_store/interface_v2"
module ChefZero
module DataStore
@@ -35,13 +35,13 @@ module ChefZero
end
end
- def get(path, request=nil)
+ def get(path, request = nil)
raise DataNotFoundError.new(path) if skip_organizations?(path)
fix_exceptions do
# Make it so build_uri will include /organizations/ORG inside the V1 data store
if request && request.rest_base_prefix.size == 0
old_base_uri = request.base_uri
- request.base_uri = File.join(request.base_uri, 'organizations', single_org)
+ request.base_uri = File.join(request.base_uri, "organizations", single_org)
end
begin
real_store.get(path[2..-1], request)
@@ -75,8 +75,8 @@ module ChefZero
def list(path)
raise DataNotFoundError.new(path) if skip_organizations?(path)
if path == []
- [ 'organizations' ]
- elsif path == [ 'organizations' ]
+ [ "organizations" ]
+ elsif path == [ "organizations" ]
[ single_org ]
else
fix_exceptions do
@@ -96,7 +96,7 @@ module ChefZero
return false if skip_organizations?(path)
if path == []
true
- elsif path == [ 'organizations' ] || path == [ 'users' ]
+ elsif path == [ "organizations" ] || path == [ "users" ]
true
else
return false if skip_organizations?(path)
@@ -112,11 +112,11 @@ module ChefZero
begin
yield
rescue DataAlreadyExistsError => e
- err = DataAlreadyExistsError.new([ 'organizations', single_org ] + e.path, e)
+ err = DataAlreadyExistsError.new([ "organizations", single_org ] + e.path, e)
err.set_backtrace(e.backtrace)
raise err
rescue DataNotFoundError => e
- err = DataNotFoundError.new([ 'organizations', single_org ] + e.path, e)
+ err = DataNotFoundError.new([ "organizations", single_org ] + e.path, e)
err.set_backtrace(e.backtrace)
raise e
end
@@ -125,7 +125,7 @@ module ChefZero
def skip_organizations?(path, name = nil)
if path == []
false
- elsif path[0] == 'organizations'
+ elsif path[0] == "organizations"
if path.size == 1
false
elsif path.size >= 2 && path[1] != single_org
diff --git a/lib/chef_zero/data_store/v2_to_v1_adapter.rb b/lib/chef_zero/data_store/v2_to_v1_adapter.rb
index d663657..f2cbce0 100644
--- a/lib/chef_zero/data_store/v2_to_v1_adapter.rb
+++ b/lib/chef_zero/data_store/v2_to_v1_adapter.rb
@@ -16,13 +16,13 @@
# limitations under the License.
#
-require 'chef_zero/data_store/interface_v1'
+require "chef_zero/data_store/interface_v1"
module ChefZero
module DataStore
class V2ToV1Adapter < ChefZero::DataStore::InterfaceV1
def initialize
- @single_org = 'chef'
+ @single_org = "chef"
end
attr_reader :real_store
@@ -30,7 +30,7 @@ module ChefZero
def clear
real_store.clear
- real_store.create_dir([ 'organizations' ], single_org, :recursive)
+ real_store.create_dir([ "organizations" ], single_org, :recursive)
end
def create_dir(path, name, *options)
@@ -45,7 +45,7 @@ module ChefZero
end
end
- def get(path, request=nil)
+ def get(path, request = nil)
fix_exceptions do
real_store.get(fix_path(path), request)
end
@@ -100,7 +100,7 @@ module ChefZero
end
def fix_path(path)
- [ 'organizations', single_org ] + path
+ [ "organizations", single_org ] + path
end
end
end