Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added possibility to give opts via symbols instead of string as key for the opts hash #365

Open
wants to merge 3 commits 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
8 changes: 4 additions & 4 deletions lib/docker/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def commit(options = {})
# Based on the link, the config passed as run, needs to be passed as the
# body of the post so capture it, remove from the options, and pass it via
# the post body
config = options.delete('run')
config = options.delete('run') || options.delete(:run)
hash = Docker::Util.parse_json(connection.post('/commit',
options,
:body => config.to_json))
Expand Down Expand Up @@ -163,7 +163,7 @@ def rename(new_name)
end

def streaming_logs(opts = {}, &block)
stack_size = opts.delete('stack_size') || -1
stack_size = opts.delete('stack_size') || opts.delete(:stack_size) || -1
tty = opts.delete('tty') || opts.delete(:tty) || false
msgs = Docker::MessagesStack.new(stack_size)
excon_params = {response_block: Docker::Util.attach_for(block, msgs, tty)}
Expand Down Expand Up @@ -196,7 +196,7 @@ def kill!(opts = {})
# but rescue from ServerErrors.
[:stop, :restart].each do |method|
define_method(:"#{method}!") do |opts = {}|
timeout = opts.delete('timeout')
timeout = opts.delete('timeout') || opts.delete(:timeout)
query = {}
query['t'] = timeout if timeout
connection.post(path_for(method), query, :body => opts.to_json)
Expand Down Expand Up @@ -271,7 +271,7 @@ def archive_in_stream(output_path, opts = {}, &block)

# Create a new Container.
def self.create(opts = {}, conn = Docker.connection)
name = opts.delete('name')
name = opts.delete('name') || opts.delete(:name)
query = {}
query['name'] = name if name
resp = conn.post('/containers/create', query, :body => opts.to_json)
Expand Down
4 changes: 2 additions & 2 deletions lib/docker/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def tag(opts = {})
# Given a path of a local file and the path it should be inserted, creates
# a new Image that has that file.
def insert_local(opts = {})
local_paths = opts.delete('localPath')
output_path = opts.delete('outputPath')
local_paths = opts.delete('localPath') || opts.delete(:localPath)
output_path = opts.delete('outputPath') || opts.delete(:outputPath)

local_paths = [ local_paths ] unless local_paths.is_a?(Array)

Expand Down