Skip to content
This repository has been archived by the owner on Mar 21, 2018. It is now read-only.

use functional interface for buff-extensions #270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/ridley/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(registry, options)
options[:server_url],
options[:client_name],
options[:client_key],
options.slice(*Ridley::Connection::VALID_OPTIONS)
Buff::Extensions::Hash.slice(options, *Ridley::Connection::VALID_OPTIONS)
], as: :connection_pool)
end
end
Expand All @@ -16,15 +16,15 @@ class ResourcesSupervisor < ::Celluloid::SupervisionGroup
def initialize(registry, connection_registry, options)
super(registry)
supervise_as :client_resource, Ridley::ClientResource, connection_registry
supervise_as :cookbook_resource, Ridley::CookbookResource, connection_registry,
options[:client_name], options[:client_key], options.slice(*Ridley::Connection::VALID_OPTIONS)
supervise_as :cookbook_resource, Ridley::CookbookResource, connection_registry, options[:client_name],
options[:client_key], Buff::Extensions::Hash.slice(options, *Ridley::Connection::VALID_OPTIONS)
supervise_as :data_bag_resource, Ridley::DataBagResource, connection_registry,
options[:encrypted_data_bag_secret]
supervise_as :environment_resource, Ridley::EnvironmentResource, connection_registry
supervise_as :node_resource, Ridley::NodeResource, connection_registry, options
supervise_as :role_resource, Ridley::RoleResource, connection_registry
supervise_as :sandbox_resource, Ridley::SandboxResource, connection_registry,
options[:client_name], options[:client_key], options.slice(*Ridley::Connection::VALID_OPTIONS)
supervise_as :sandbox_resource, Ridley::SandboxResource, connection_registry, options[:client_name],
options[:client_key], Buff::Extensions::Hash.slice(options, *Ridley::Connection::VALID_OPTIONS)
supervise_as :search_resource, Ridley::SearchResource, connection_registry
supervise_as :user_resource, Ridley::UserResource, connection_registry
end
Expand All @@ -49,7 +49,7 @@ def validate_options(options)
raise ArgumentError, "Missing required option(s): #{missing.join(', ')}"
end

missing_values = options.slice(*REQUIRED_OPTIONS).select { |key, value| !value.present? }
missing_values = Buff::Extensions::Hash.slice(options, *REQUIRED_OPTIONS).select { |key, value| !value.present? }
if missing_values.any?
values = missing_values.keys.collect { |opt| "'#{opt}'" }
raise ArgumentError, "Missing value for required option(s): '#{values.join(', ')}'"
Expand Down
2 changes: 1 addition & 1 deletion lib/ridley/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def initialize(server_url, client_name, client_key, options = {})
b.adapter :net_http_persistent
end

uri_hash = Addressable::URI.parse(server_url).to_hash.slice(:scheme, :host, :port)
uri_hash = Buff::Extensions::Hash.slice(Addressable::URI.parse(server_url).to_hash, :scheme, :host, :port)

unless uri_hash[:port]
uri_hash[:port] = (uri_hash[:scheme] == "https" ? 443 : 80)
Expand Down
2 changes: 1 addition & 1 deletion lib/ridley/resources/cookbook_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def upload(path, options = {})

sandbox.upload(checksums)
sandbox.commit
update(cookbook, options.slice(:force, :freeze))
update(cookbook, Buff::Extensions::Hash.slice(options, :force, :freeze))
ensure
# Destroy the compiled metadata only if it was created
File.delete(compiled_metadata) unless compiled_metadata.nil?
Expand Down