summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop.yml2
-rw-r--r--Gemfile2
-rw-r--r--Rakefile4
-rw-r--r--lib/chef_zero/chef_data/cookbook_data.rb8
-rw-r--r--lib/chef_zero/data_store/default_facade.rb2
-rw-r--r--lib/chef_zero/data_store/raw_file_store.rb4
-rw-r--r--lib/chef_zero/endpoints/acl_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/container_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/cookbook_version_endpoint.rb4
-rw-r--r--lib/chef_zero/endpoints/data_bag_item_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/environment_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/file_store_file_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/group_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/node_endpoint.rb6
-rw-r--r--lib/chef_zero/endpoints/node_identifiers_endpoint.rb6
-rw-r--r--lib/chef_zero/endpoints/nodes_endpoint.rb6
-rw-r--r--lib/chef_zero/endpoints/not_found_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/organization_endpoint.rb4
-rw-r--r--lib/chef_zero/endpoints/organization_users_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/organization_validator_key_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/organizations_endpoint.rb6
-rw-r--r--lib/chef_zero/endpoints/rest_object_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/role_endpoint.rb2
-rw-r--r--lib/chef_zero/endpoints/sandbox_endpoint.rb10
-rw-r--r--lib/chef_zero/endpoints/sandboxes_endpoint.rb18
-rw-r--r--lib/chef_zero/endpoints/user_association_request_endpoint.rb2
-rw-r--r--lib/chef_zero/rest_base.rb8
-rw-r--r--lib/chef_zero/rspec.rb2
-rw-r--r--lib/chef_zero/server.rb34
-rw-r--r--spec/server_spec.rb8
-rw-r--r--spec/support/oc_pedant.rb62
31 files changed, 111 insertions, 109 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..5b837e2
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,2 @@
+Style/HashSyntax:
+ Enabled: true
diff --git a/Gemfile b/Gemfile
index 7ac46eb..a086282 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,7 +4,7 @@ gemspec
# gem 'rest-client', :git => 'https://github.com/chef/rest-client.git'
group :pedant do
- gem "oc-chef-pedant", :git => "https://github.com/chef/chef-server.git"
+ gem "oc-chef-pedant", git: "https://github.com/chef/chef-server.git"
end
group :development, :test do
diff --git a/Rakefile b/Rakefile
index 095de4e..25d7db4 100644
--- a/Rakefile
+++ b/Rakefile
@@ -18,7 +18,7 @@ Environment:
e.g. LOG_LEVEL=debug
END
-task :default => :pedant
+task default: :pedant
desc "Run specs"
task :spec do
@@ -26,7 +26,7 @@ task :spec do
end
desc "Run oc-chef-pedant\n\n#{ENV_DOCS}"
-task :pedant => :oc_pedant
+task pedant: :oc_pedant
desc "Run oc-chef-pedant with CHEF_FS set\n\n#{ENV_DOCS}"
task :cheffs do
diff --git a/lib/chef_zero/chef_data/cookbook_data.rb b/lib/chef_zero/chef_data/cookbook_data.rb
index d646676..74bc9e7 100644
--- a/lib/chef_zero/chef_data/cookbook_data.rb
+++ b/lib/chef_zero/chef_data/cookbook_data.rb
@@ -140,10 +140,10 @@ module ChefZero
def load_file(value, name, part = nil)
specific_name = part ? "#{part}/#{name}" : name
[{
- :name => specific_name,
- :path => name,
- :checksum => Digest::MD5.hexdigest(value),
- :specificity => "default",
+ name: specific_name,
+ path: name,
+ checksum: Digest::MD5.hexdigest(value),
+ specificity: "default",
}]
end
diff --git a/lib/chef_zero/data_store/default_facade.rb b/lib/chef_zero/data_store/default_facade.rb
index d906446..6c94dff 100644
--- a/lib/chef_zero/data_store/default_facade.rb
+++ b/lib/chef_zero/data_store/default_facade.rb
@@ -70,7 +70,7 @@ module ChefZero
rescue DataNotFoundError
result = default_creator.get(path)
if result
- FFI_Yajl::Encoder.encode(result, :pretty => true)
+ FFI_Yajl::Encoder.encode(result, pretty: true)
else
raise
end
diff --git a/lib/chef_zero/data_store/raw_file_store.rb b/lib/chef_zero/data_store/raw_file_store.rb
index 2d4b3f5..31bf08a 100644
--- a/lib/chef_zero/data_store/raw_file_store.rb
+++ b/lib/chef_zero/data_store/raw_file_store.rb
@@ -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
@@ -94,7 +94,7 @@ module ChefZero
if options.include?(:create)
mode |= File::CREAT
end
- File.open(path_to(path), mode, :internal_encoding => nil) do |file|
+ File.open(path_to(path), mode, internal_encoding: nil) do |file|
file.write data
end
rescue Errno::ENOENT
diff --git a/lib/chef_zero/endpoints/acl_endpoint.rb b/lib/chef_zero/endpoints/acl_endpoint.rb
index 527ba17..cfa3a97 100644
--- a/lib/chef_zero/endpoints/acl_endpoint.rb
+++ b/lib/chef_zero/endpoints/acl_endpoint.rb
@@ -30,7 +30,7 @@ module ChefZero
path, perm = validate_request(request)
acls = FFI_Yajl::Parser.parse(get_data(request, path))
acls[perm] = FFI_Yajl::Parser.parse(request.body)[perm]
- set_data(request, path, FFI_Yajl::Encoder.encode(acls, :pretty => true))
+ set_data(request, path, FFI_Yajl::Encoder.encode(acls, pretty: true))
json_response(200, { "uri" => "#{build_uri(request.base_uri, request.rest_path)}" })
end
end
diff --git a/lib/chef_zero/endpoints/container_endpoint.rb b/lib/chef_zero/endpoints/container_endpoint.rb
index 098f9a4..95b92ca 100644
--- a/lib/chef_zero/endpoints/container_endpoint.rb
+++ b/lib/chef_zero/endpoints/container_endpoint.rb
@@ -15,7 +15,7 @@ module ChefZero
def populate_defaults(request, response_json)
container = FFI_Yajl::Parser.parse(response_json)
container = ChefData::DataNormalizer.normalize_container(container, request.rest_path[3])
- FFI_Yajl::Encoder.encode(container, :pretty => true)
+ FFI_Yajl::Encoder.encode(container, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb
index 615b03e..97b0ce4 100644
--- a/lib/chef_zero/endpoints/cookbook_version_endpoint.rb
+++ b/lib/chef_zero/endpoints/cookbook_version_endpoint.rb
@@ -31,7 +31,7 @@ module ChefZero
request_body = FFI_Yajl::Parser.parse(request.body)
if !request_body["frozen?"]
request_body["frozen?"] = true
- request.body = FFI_Yajl::Encoder.encode(request_body, :pretty => true)
+ request.body = FFI_Yajl::Encoder.encode(request_body, pretty: true)
end
end
end
@@ -122,7 +122,7 @@ module ChefZero
cookbook["chef_type"] ||= "cookbook_version"
cookbook["json_class"] ||= "Chef::CookbookVersion"
cookbook = ChefData::DataNormalizer.normalize_cookbook(self, request.rest_path[0..1], cookbook, request.rest_path[3], request.rest_path[4], request.base_uri, request.method, false, api_version: request.api_version) if normalize
- FFI_Yajl::Encoder.encode(cookbook, :pretty => true)
+ FFI_Yajl::Encoder.encode(cookbook, pretty: true)
end
def latest_version(versions)
diff --git a/lib/chef_zero/endpoints/data_bag_item_endpoint.rb b/lib/chef_zero/endpoints/data_bag_item_endpoint.rb
index 915e9ad..ec21ab0 100644
--- a/lib/chef_zero/endpoints/data_bag_item_endpoint.rb
+++ b/lib/chef_zero/endpoints/data_bag_item_endpoint.rb
@@ -18,7 +18,7 @@ module ChefZero
def self.populate_defaults(request, response_json, data_bag, data_bag_item)
response = FFI_Yajl::Parser.parse(response_json)
response = ChefData::DataNormalizer.normalize_data_bag_item(response, data_bag, data_bag_item, request.method)
- FFI_Yajl::Encoder.encode(response, :pretty => true)
+ FFI_Yajl::Encoder.encode(response, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/environment_endpoint.rb b/lib/chef_zero/endpoints/environment_endpoint.rb
index 4f07a72..37f0169 100644
--- a/lib/chef_zero/endpoints/environment_endpoint.rb
+++ b/lib/chef_zero/endpoints/environment_endpoint.rb
@@ -26,7 +26,7 @@ module ChefZero
def populate_defaults(request, response_json)
response = FFI_Yajl::Parser.parse(response_json)
response = ChefData::DataNormalizer.normalize_environment(response, request.rest_path[3])
- FFI_Yajl::Encoder.encode(response, :pretty => true)
+ FFI_Yajl::Encoder.encode(response, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/file_store_file_endpoint.rb b/lib/chef_zero/endpoints/file_store_file_endpoint.rb
index 90b51da..290d7d9 100644
--- a/lib/chef_zero/endpoints/file_store_file_endpoint.rb
+++ b/lib/chef_zero/endpoints/file_store_file_endpoint.rb
@@ -14,7 +14,7 @@ module ChefZero
end
def put(request)
- data_store.set(request.rest_path, request.body, :create, :create_dir, :requestor => request.requestor)
+ data_store.set(request.rest_path, request.body, :create, :create_dir, requestor: request.requestor)
json_response(200, {})
end
end
diff --git a/lib/chef_zero/endpoints/group_endpoint.rb b/lib/chef_zero/endpoints/group_endpoint.rb
index 7855e98..b1b4f8f 100644
--- a/lib/chef_zero/endpoints/group_endpoint.rb
+++ b/lib/chef_zero/endpoints/group_endpoint.rb
@@ -13,7 +13,7 @@ module ChefZero
def populate_defaults(request, response_json)
group = FFI_Yajl::Parser.parse(response_json)
group = ChefData::DataNormalizer.normalize_group(group, request.rest_path[3], request.rest_path[1])
- FFI_Yajl::Encoder.encode(group, :pretty => true)
+ FFI_Yajl::Encoder.encode(group, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/node_endpoint.rb b/lib/chef_zero/endpoints/node_endpoint.rb
index 471bc4a..ee07678 100644
--- a/lib/chef_zero/endpoints/node_endpoint.rb
+++ b/lib/chef_zero/endpoints/node_endpoint.rb
@@ -10,11 +10,11 @@ module ChefZero
data = parse_json(request.body)
if data.has_key?("policy_name") && policy_name_invalid?(data["policy_name"])
- return error(400, "Field 'policy_name' invalid", :pretty => false)
+ return error(400, "Field 'policy_name' invalid", pretty: false)
end
if data.has_key?("policy_group") && policy_name_invalid?(data["policy_group"])
- return error(400, "Field 'policy_group' invalid", :pretty => false)
+ return error(400, "Field 'policy_group' invalid", pretty: false)
end
super(request)
@@ -27,7 +27,7 @@ module ChefZero
def populate_defaults(request, response_json)
node = FFI_Yajl::Parser.parse(response_json)
node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
- FFI_Yajl::Encoder.encode(node, :pretty => true)
+ FFI_Yajl::Encoder.encode(node, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/node_identifiers_endpoint.rb b/lib/chef_zero/endpoints/node_identifiers_endpoint.rb
index 68aa01f..b62693a 100644
--- a/lib/chef_zero/endpoints/node_identifiers_endpoint.rb
+++ b/lib/chef_zero/endpoints/node_identifiers_endpoint.rb
@@ -9,9 +9,9 @@ module ChefZero
def get(request)
if get_data(request, request.rest_path[0..3])
result = {
- :id => UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.delete("-"),
- :authz_id => "0" * 32,
- :org_id => UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.delete("-") }
+ id: UUIDTools::UUID.parse_raw(request.rest_path[0..4].to_s).to_s.delete("-"),
+ authz_id: "0" * 32,
+ org_id: UUIDTools::UUID.parse_raw(request.rest_path[0..1].to_s).to_s.delete("-") }
json_response(200, result)
else
raise RestErrorResponse.new(404, "Object not found: #{build_uri(request.base_uri, request.rest_path)}")
diff --git a/lib/chef_zero/endpoints/nodes_endpoint.rb b/lib/chef_zero/endpoints/nodes_endpoint.rb
index 42539e1..8b141f8 100644
--- a/lib/chef_zero/endpoints/nodes_endpoint.rb
+++ b/lib/chef_zero/endpoints/nodes_endpoint.rb
@@ -13,11 +13,11 @@ module ChefZero
data = parse_json(request.body)
if data.has_key?("policy_name") && policy_name_invalid?(data["policy_name"])
- return error(400, "Field 'policy_name' invalid", :pretty => false)
+ return error(400, "Field 'policy_name' invalid", pretty: false)
end
if data.has_key?("policy_group") && policy_name_invalid?(data["policy_group"])
- return error(400, "Field 'policy_group' invalid", :pretty => false)
+ return error(400, "Field 'policy_group' invalid", pretty: false)
end
end
@@ -27,7 +27,7 @@ module ChefZero
def populate_defaults(request, response_json)
node = FFI_Yajl::Parser.parse(response_json)
node = ChefData::DataNormalizer.normalize_node(node, request.rest_path[3])
- FFI_Yajl::Encoder.encode(node, :pretty => true)
+ FFI_Yajl::Encoder.encode(node, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/not_found_endpoint.rb b/lib/chef_zero/endpoints/not_found_endpoint.rb
index 582272b..1c18f8b 100644
--- a/lib/chef_zero/endpoints/not_found_endpoint.rb
+++ b/lib/chef_zero/endpoints/not_found_endpoint.rb
@@ -4,7 +4,7 @@ module ChefZero
module Endpoints
class NotFoundEndpoint
def call(request)
- [404, { "Content-Type" => "application/json" }, FFI_Yajl::Encoder.encode({ "error" => ["Object not found: #{request.env['REQUEST_PATH']}"] }, :pretty => true)]
+ [404, { "Content-Type" => "application/json" }, FFI_Yajl::Encoder.encode({ "error" => ["Object not found: #{request.env['REQUEST_PATH']}"] }, pretty: true)]
end
end
end
diff --git a/lib/chef_zero/endpoints/organization_endpoint.rb b/lib/chef_zero/endpoints/organization_endpoint.rb
index 55bd686..4cf9e12 100644
--- a/lib/chef_zero/endpoints/organization_endpoint.rb
+++ b/lib/chef_zero/endpoints/organization_endpoint.rb
@@ -16,7 +16,7 @@ module ChefZero
new_org.each do |key, value|
org[key] = value
end
- save_org = FFI_Yajl::Encoder.encode(org, :pretty => true)
+ save_org = FFI_Yajl::Encoder.encode(org, pretty: true)
if new_org["name"] != request.rest_path[-1]
# This is a rename
return error(400, "Cannot rename org #{request.rest_path[-1]} to #{new_org['name']}: rename not supported for orgs")
@@ -39,7 +39,7 @@ module ChefZero
def populate_defaults(request, response_json)
org = FFI_Yajl::Parser.parse(response_json)
org = ChefData::DataNormalizer.normalize_organization(org, request.rest_path[1])
- FFI_Yajl::Encoder.encode(org, :pretty => true)
+ FFI_Yajl::Encoder.encode(org, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/organization_users_endpoint.rb b/lib/chef_zero/endpoints/organization_users_endpoint.rb
index 67161b1..fd41c48 100644
--- a/lib/chef_zero/endpoints/organization_users_endpoint.rb
+++ b/lib/chef_zero/endpoints/organization_users_endpoint.rb
@@ -30,7 +30,7 @@ module ChefZero
if !users["users"] || !users["users"].include?(username)
users["users"] ||= []
users["users"] |= [ username ]
- set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, :pretty => true))
+ set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, pretty: true))
end
json_response(201, { "uri" => build_uri(request.base_uri, request.rest_path + [ username ]) })
end
diff --git a/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb b/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb
index ff1ac3b..2251f00 100644
--- a/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb
+++ b/lib/chef_zero/endpoints/organization_validator_key_endpoint.rb
@@ -12,7 +12,7 @@ module ChefZero
validator = FFI_Yajl::Parser.parse(get_data(request, validator_path))
private_key, public_key = server.gen_key_pair
validator["public_key"] = public_key
- set_data(request, validator_path, FFI_Yajl::Encoder.encode(validator, :pretty => true))
+ set_data(request, validator_path, FFI_Yajl::Encoder.encode(validator, pretty: true))
json_response(200, { "private_key" => private_key })
end
end
diff --git a/lib/chef_zero/endpoints/organizations_endpoint.rb b/lib/chef_zero/endpoints/organizations_endpoint.rb
index 268b533..9fe6573 100644
--- a/lib/chef_zero/endpoints/organizations_endpoint.rb
+++ b/lib/chef_zero/endpoints/organizations_endpoint.rb
@@ -25,14 +25,14 @@ module ChefZero
elsif exists_data_dir?(request, request.rest_path + [ name ])
error(409, "Organization already exists")
else
- create_data_dir(request, request.rest_path, name, :requestor => request.requestor)
+ create_data_dir(request, request.rest_path, name, requestor: request.requestor)
org = {
"guid" => UUIDTools::UUID.random_create.to_s.delete("-"),
"assigned_at" => Time.now.to_s,
}.merge(contents)
org_path = request.rest_path + [ name ]
- set_data(request, org_path + [ "org" ], FFI_Yajl::Encoder.encode(org, :pretty => true))
+ set_data(request, org_path + [ "org" ], FFI_Yajl::Encoder.encode(org, pretty: true))
if server.generate_real_keys?
# Create the validator client
@@ -42,7 +42,7 @@ module ChefZero
validator = FFI_Yajl::Encoder.encode({
"validator" => true,
"public_key" => public_key,
- }, :pretty => true)
+ }, pretty: true)
set_data(request, validator_path, validator)
end
diff --git a/lib/chef_zero/endpoints/rest_object_endpoint.rb b/lib/chef_zero/endpoints/rest_object_endpoint.rb
index 887905e..5d6ae40 100644
--- a/lib/chef_zero/endpoints/rest_object_endpoint.rb
+++ b/lib/chef_zero/endpoints/rest_object_endpoint.rb
@@ -52,7 +52,7 @@ module ChefZero
existing_json = FFI_Yajl::Parser.parse(existing_value)
merged_json = existing_json.merge(request_json)
if merged_json.size > request_json.size
- return FFI_Yajl::Encoder.encode(merged_json, :pretty => true)
+ return FFI_Yajl::Encoder.encode(merged_json, pretty: true)
end
end
diff --git a/lib/chef_zero/endpoints/role_endpoint.rb b/lib/chef_zero/endpoints/role_endpoint.rb
index d4bc4cd..4e31cdc 100644
--- a/lib/chef_zero/endpoints/role_endpoint.rb
+++ b/lib/chef_zero/endpoints/role_endpoint.rb
@@ -9,7 +9,7 @@ module ChefZero
def populate_defaults(request, response_json)
role = FFI_Yajl::Parser.parse(response_json)
role = ChefData::DataNormalizer.normalize_role(role, request.rest_path[3])
- FFI_Yajl::Encoder.encode(role, :pretty => true)
+ FFI_Yajl::Encoder.encode(role, pretty: true)
end
end
end
diff --git a/lib/chef_zero/endpoints/sandbox_endpoint.rb b/lib/chef_zero/endpoints/sandbox_endpoint.rb
index a35af2c..d7eb4de 100644
--- a/lib/chef_zero/endpoints/sandbox_endpoint.rb
+++ b/lib/chef_zero/endpoints/sandbox_endpoint.rb
@@ -15,11 +15,11 @@ module ChefZero
end
delete_data(request)
json_response(200, {
- :guid => request.rest_path[3],
- :name => request.rest_path[3],
- :checksums => existing_sandbox["checksums"],
- :create_time => existing_sandbox["create_time"],
- :is_completed => true,
+ guid: request.rest_path[3],
+ name: request.rest_path[3],
+ checksums: existing_sandbox["checksums"],
+ create_time: existing_sandbox["create_time"],
+ is_completed: true,
})
end
end
diff --git a/lib/chef_zero/endpoints/sandboxes_endpoint.rb b/lib/chef_zero/endpoints/sandboxes_endpoint.rb
index 888b72a..62fea76 100644
--- a/lib/chef_zero/endpoints/sandboxes_endpoint.rb
+++ b/lib/chef_zero/endpoints/sandboxes_endpoint.rb
@@ -17,11 +17,11 @@ module ChefZero
result_checksums = {}
needed_checksums.keys.each do |needed_checksum|
if list_data(request, request.rest_path[0..1] + %w{file_store checksums}).include?(needed_checksum)
- result_checksums[needed_checksum] = { :needs_upload => false }
+ result_checksums[needed_checksum] = { needs_upload: false }
else
result_checksums[needed_checksum] = {
- :needs_upload => true,
- :url => build_uri(request.base_uri, request.rest_path[0..1] + ["file_store", "checksums", needed_checksum]),
+ needs_upload: true,
+ url: build_uri(request.base_uri, request.rest_path[0..1] + ["file_store", "checksums", needed_checksum]),
}
sandbox_checksums << needed_checksum
end
@@ -35,14 +35,14 @@ module ChefZero
time_str = "#{time_str[0..21]}:#{time_str[22..23]}"
create_data(request, request.rest_path, id, FFI_Yajl::Encoder.encode({
- :create_time => time_str,
- :checksums => sandbox_checksums,
- }, :pretty => true))
+ create_time: time_str,
+ checksums: sandbox_checksums,
+ }, pretty: true))
json_response(201, {
- :uri => build_uri(request.base_uri, request.rest_path + [id]),
- :checksums => result_checksums,
- :sandbox_id => id,
+ uri: build_uri(request.base_uri, request.rest_path + [id]),
+ checksums: result_checksums,
+ sandbox_id: id,
})
end
end
diff --git a/lib/chef_zero/endpoints/user_association_request_endpoint.rb b/lib/chef_zero/endpoints/user_association_request_endpoint.rb
index 9433202..580ba49 100644
--- a/lib/chef_zero/endpoints/user_association_request_endpoint.rb
+++ b/lib/chef_zero/endpoints/user_association_request_endpoint.rb
@@ -26,7 +26,7 @@ module ChefZero
if !users["users"] || !users["users"].include?(username)
users["users"] ||= []
users["users"] |= [ username ]
- set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, :pretty => true))
+ set_data(request, [ "organizations", orgname, "groups", "users" ], FFI_Yajl::Encoder.encode(users, pretty: true))
end
elsif json["response"] == "reject"
delete_data(request, association_request_path)
diff --git a/lib/chef_zero/rest_base.rb b/lib/chef_zero/rest_base.rb
index b6d4b6a..4cf73ba 100644
--- a/lib/chef_zero/rest_base.rb
+++ b/lib/chef_zero/rest_base.rb
@@ -145,7 +145,7 @@ module ChefZero
def set_data(request, rest_path, data, *options)
rest_path ||= request.rest_path
begin
- data_store.set(rest_path, data, *options, :requestor => request.requestor)
+ data_store.set(rest_path, data, *options, requestor: request.requestor)
rescue DataStore::DataNotFoundError
if options.include?(:data_store_exceptions)
raise
@@ -158,7 +158,7 @@ module ChefZero
def create_data_dir(request, rest_path, name, *options)
rest_path ||= request.rest_path
begin
- data_store.create_dir(rest_path, name, *options, :requestor => request.requestor)
+ data_store.create_dir(rest_path, name, *options, requestor: request.requestor)
rescue DataStore::DataNotFoundError
if options.include?(:data_store_exceptions)
raise
@@ -177,7 +177,7 @@ module ChefZero
def create_data(request, rest_path, name, data, *options)
rest_path ||= request.rest_path
begin
- data_store.create(rest_path, name, data, *options, :requestor => request.requestor)
+ data_store.create(rest_path, name, data, *options, requestor: request.requestor)
rescue DataStore::DataNotFoundError
if options.include?(:data_store_exceptions)
raise
@@ -296,7 +296,7 @@ module ChefZero
end
def to_json(data)
- FFI_Yajl::Encoder.encode(data, :pretty => true)
+ FFI_Yajl::Encoder.encode(data, pretty: true)
end
def get_data_or_else(request, path, or_else_value)
diff --git a/lib/chef_zero/rspec.rb b/lib/chef_zero/rspec.rb
index 765ec92..b6d6dd1 100644
--- a/lib/chef_zero/rspec.rb
+++ b/lib/chef_zero/rspec.rb
@@ -333,7 +333,7 @@ module ChefZero
if data.is_a?(String)
data
else
- FFI_Yajl::Encoder.encode(data, :pretty => true)
+ FFI_Yajl::Encoder.encode(data, pretty: true)
end
end
diff --git a/lib/chef_zero/server.rb b/lib/chef_zero/server.rb
index 61f3962..cadf8c3 100644
--- a/lib/chef_zero/server.rb
+++ b/lib/chef_zero/server.rb
@@ -112,12 +112,12 @@ module ChefZero
class Server
DEFAULT_OPTIONS = {
- :host => ["127.0.0.1"],
- :port => 8889,
- :log_level => :warn,
- :generate_real_keys => true,
- :single_org => "chef",
- :ssl => false,
+ host: ["127.0.0.1"],
+ port: 8889,
+ log_level: :warn,
+ generate_real_keys: true,
+ single_org: "chef",
+ ssl: false,
}.freeze
GLOBAL_ENDPOINTS = [
@@ -281,14 +281,14 @@ module ChefZero
def start_background(wait = 5)
@server = WEBrick::HTTPServer.new(
- :DoNotListen => true,
- :AccessLog => [],
- :Logger => WEBrick::Log.new(StringIO.new, 7),
- :RequestTimeout => 300,
- :SSLEnable => options[:ssl],
- :SSLOptions => ssl_opts,
- :SSLCertName => [ [ "CN", WEBrick::Utils.getservername ] ],
- :StartCallback => proc do
+ DoNotListen: true,
+ AccessLog: [],
+ Logger: WEBrick::Log.new(StringIO.new, 7),
+ RequestTimeout: 300,
+ SSLEnable: options[:ssl],
+ SSLOptions: ssl_opts,
+ SSLCertName: [ [ "CN", WEBrick::Utils.getservername ] ],
+ StartCallback: proc do
@running = true
end
)
@@ -484,7 +484,7 @@ module ChefZero
if contents["policy_groups"]
contents["policy_groups"].each_pair do |group_name, group|
group["policies"].each do |policy_name, policy_revision|
- data_store.set(["organizations", org_name, "policy_groups", group_name, "policies", policy_name], FFI_Yajl::Encoder.encode(policy_revision["revision_id"], :pretty => true), :create, :create_dir)
+ data_store.set(["organizations", org_name, "policy_groups", group_name, "policies", policy_name], FFI_Yajl::Encoder.encode(policy_revision["revision_id"], pretty: true), :create, :create_dir)
end
end
end
@@ -502,7 +502,7 @@ module ChefZero
end
raise "No version specified" if !cookbook_data[:version]
data_store.create_dir(["organizations", org_name, cookbook_type], cookbook_data[:cookbook_name], :recursive)
- data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, :pretty => true), :create)
+ data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, pretty: true), :create)
cookbook_data.values.each do |files|
next unless files.is_a? Array
files.each do |file|
@@ -699,7 +699,7 @@ module ChefZero
end
def dejsonize(value)
- value.is_a?(Hash) ? FFI_Yajl::Encoder.encode(value, :pretty => true) : value
+ value.is_a?(Hash) ? FFI_Yajl::Encoder.encode(value, pretty: true) : value
end
def get_file(directory, path)
diff --git a/spec/server_spec.rb b/spec/server_spec.rb
index 64167e1..2305880 100644
--- a/spec/server_spec.rb
+++ b/spec/server_spec.rb
@@ -5,7 +5,7 @@ require "uri"
describe ChefZero::Server do
context "with a server bound to port 8889" do
before :each do
- @server = ChefZero::Server.new(:port => 8889)
+ @server = ChefZero::Server.new(port: 8889)
@server.start_background
end
after :each do
@@ -13,18 +13,18 @@ describe ChefZero::Server do
end
it "a second server bound to port 8889 throws EADDRINUSE" do
- expect { ChefZero::Server.new(:port => 8889).start }.to raise_error Errno::EADDRINUSE
+ expect { ChefZero::Server.new(port: 8889).start }.to raise_error Errno::EADDRINUSE
end
it "a server bound to range 8889-9999 binds to a port > 8889" do
- server = ChefZero::Server.new(:port => 8889.upto(9999))
+ server = ChefZero::Server.new(port: 8889.upto(9999))
server.start_background
expect(server.port).to be > 8889
expect(URI(server.url).port).to be > 8889
end
it "a server bound to range 8889-8889 throws an exception" do
- expect { ChefZero::Server.new(:port => 8889.upto(8889)).start_background }.to raise_error Errno::EADDRINUSE
+ expect { ChefZero::Server.new(port: 8889.upto(8889)).start_background }.to raise_error Errno::EADDRINUSE
end
it "has a very patient request timeout" do
diff --git a/spec/support/oc_pedant.rb b/spec/support/oc_pedant.rb
index 0635b6f..9a59e4c 100644
--- a/spec/support/oc_pedant.rb
+++ b/spec/support/oc_pedant.rb
@@ -93,49 +93,49 @@ end
keyfile_maybe = ENV["CHEF_FS"] ? { key_file: key } : { key_file: nil }
requestors({
- :clients => {
+ clients: {
# The the admin user, for the purposes of getting things rolling
- :admin => {
- :name => "pedant_admin_client",
- :create_me => true,
- :create_knife => true,
- :admin => true,
+ admin: {
+ name: "pedant_admin_client",
+ create_me: true,
+ create_knife: true,
+ admin: true,
},
- :non_admin => {
- :name => "pedant_client",
- :create_me => true,
- :create_knife => true,
+ non_admin: {
+ name: "pedant_client",
+ create_me: true,
+ create_knife: true,
},
- :bad => {
- :name => "bad_client",
- :create_me => true,
- :create_knife => true,
- :bogus => true,
+ bad: {
+ name: "bad_client",
+ create_me: true,
+ create_knife: true,
+ bogus: true,
},
},
- :users => {
+ users: {
# An administrator in the testing organization
- :admin => {
- :name => cheffs_or_else_user("pedant_admin_user"),
- :create_me => !ENV["CHEF_FS"],
- :associate => !ENV["CHEF_FS"],
- :create_knife => true,
+ admin: {
+ name: cheffs_or_else_user("pedant_admin_user"),
+ create_me: !ENV["CHEF_FS"],
+ associate: !ENV["CHEF_FS"],
+ create_knife: true,
}.merge(keyfile_maybe),
- :non_admin => {
- :name => cheffs_or_else_user("pedant_user"),
- :create_me => !ENV["CHEF_FS"],
- :associate => !ENV["CHEF_FS"],
- :create_knife => true,
+ non_admin: {
+ name: cheffs_or_else_user("pedant_user"),
+ create_me: !ENV["CHEF_FS"],
+ associate: !ENV["CHEF_FS"],
+ create_knife: true,
}.merge(keyfile_maybe),
# A user that is not a member of the testing organization
- :bad => {
- :name => cheffs_or_else_user("pedant-nobody"),
- :create_me => !ENV["CHEF_FS"],
- :create_knife => true,
- :associate => false,
+ bad: {
+ name: cheffs_or_else_user("pedant-nobody"),
+ create_me: !ENV["CHEF_FS"],
+ create_knife: true,
+ associate: false,
}.merge(keyfile_maybe),
},
})