diff --git a/.simplecov b/.simplecov index cfbf20b7..1982cd3d 100644 --- a/.simplecov +++ b/.simplecov @@ -1,3 +1,5 @@ +# frozen_string_literal: true + SimpleCov.start do add_group 'Library', 'lib' add_group 'Specs', 'spec' diff --git a/Gemfile b/Gemfile index d65e2a66..f7200f13 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + source 'http://rubygems.org' gemspec diff --git a/Rakefile b/Rakefile index 63645126..6c3318ff 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/setup' ENV['PATH'] = "/opt/docker/:#{ENV['PATH']}" if ENV['CI'] == 'true' diff --git a/docker-api.gemspec b/docker-api.gemspec index fd62c154..1a131c76 100644 --- a/docker-api.gemspec +++ b/docker-api.gemspec @@ -1,4 +1,6 @@ # -*- encoding: utf-8 -*- +# frozen_string_literal: true + require File.expand_path('../lib/docker/version', __FILE__) Gem::Specification.new do |gem| diff --git a/lib/docker-api.rb b/lib/docker-api.rb index 72917388..9e99242f 100644 --- a/lib/docker-api.rb +++ b/lib/docker-api.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'docker' diff --git a/lib/docker.rb b/lib/docker.rb index e0a554b3..973e0d5e 100644 --- a/lib/docker.rb +++ b/lib/docker.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'cgi' require 'multi_json' require 'excon' diff --git a/lib/docker/base.rb b/lib/docker/base.rb index d439ea8d..cdb4366b 100644 --- a/lib/docker/base.rb +++ b/lib/docker/base.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class is a base class for Docker Container and Image. # It is implementing accessor methods for the models attributes. module Docker::Base diff --git a/lib/docker/connection.rb b/lib/docker/connection.rb index 7537f90e..d678d243 100644 --- a/lib/docker/connection.rb +++ b/lib/docker/connection.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a Connection to a Docker server. The Connection is # immutable in that once the url and options is set they cannot be changed. class Docker::Connection diff --git a/lib/docker/container.rb b/lib/docker/container.rb index a203b3fd..3c0cc044 100644 --- a/lib/docker/container.rb +++ b/lib/docker/container.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a Docker Container. It's important to note that nothing # is cached so that the information is always up to date. class Docker::Container diff --git a/lib/docker/error.rb b/lib/docker/error.rb index ec494799..f0316b58 100644 --- a/lib/docker/error.rb +++ b/lib/docker/error.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This module holds the Errors for the gem. module Docker::Error diff --git a/lib/docker/event.rb b/lib/docker/event.rb index 2bfc3ee9..4945bca4 100644 --- a/lib/docker/event.rb +++ b/lib/docker/event.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a Docker Event. class Docker::Event include Docker::Error diff --git a/lib/docker/exec.rb b/lib/docker/exec.rb index eb6d6c68..00394bc9 100644 --- a/lib/docker/exec.rb +++ b/lib/docker/exec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a Docker Exec Instance. class Docker::Exec include Docker::Base diff --git a/lib/docker/image.rb b/lib/docker/image.rb index 0d327d4c..eb5dbc6e 100644 --- a/lib/docker/image.rb +++ b/lib/docker/image.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a Docker Image. class Docker::Image include Docker::Base @@ -28,7 +30,7 @@ def push(creds = nil, options = {}, &block) repo, tag = Docker::Util.parse_repo_tag(repo_tag) raise ArgumentError, "Image does not have a name to push." if repo.nil? - body = "" + body = +"" credentials = creds || Docker.creds || {} headers = Docker::Util.build_auth_header(credentials) opts = {:tag => tag}.merge(options) @@ -119,7 +121,7 @@ class << self def create(opts = {}, creds = nil, conn = Docker.connection, &block) credentials = creds.nil? ? Docker.creds : MultiJson.dump(creds) headers = credentials && Docker::Util.build_auth_header(credentials) || {} - body = '' + body = +'' conn.post( '/images/create', opts, @@ -168,7 +170,7 @@ def save(names, filename = nil, conn = Docker.connection) end nil else - string = '' + string = +'' save_stream(names, {}, conn, &response_block_for_save(string)) string end @@ -196,7 +198,7 @@ def save_stream(names, opts = {}, conn = Docker.connection, &block) def load(tar, opts = {}, conn = Docker.connection, creds = nil, &block) headers = build_headers(creds) io = tar.is_a?(String) ? File.open(tar, 'rb') : tar - body = "" + body = +"" conn.post( '/images/load', opts, @@ -267,7 +269,7 @@ def import_stream(options = {}, connection = Docker.connection, &block) # Given a Dockerfile as a string, builds an Image. def build(commands, opts = {}, connection = Docker.connection, &block) - body = "" + body = +"" connection.post( '/build', opts, :body => Docker::Util.create_tar('Dockerfile' => commands), @@ -288,7 +290,7 @@ def build_from_tar(tar, opts = {}, connection = Docker.connection, headers = build_headers(creds) # The response_block passed to Excon will build up this body variable. - body = "" + body = +"" connection.post( '/build', opts, :headers => headers, diff --git a/lib/docker/messages.rb b/lib/docker/messages.rb index dd9a2b75..f72b4bd0 100644 --- a/lib/docker/messages.rb +++ b/lib/docker/messages.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents all the messages either received by chunks from attach class Docker::Messages diff --git a/lib/docker/messages_stack.rb b/lib/docker/messages_stack.rb index 2ab85165..a5a0fb73 100644 --- a/lib/docker/messages_stack.rb +++ b/lib/docker/messages_stack.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a messages stack class Docker::MessagesStack diff --git a/lib/docker/network.rb b/lib/docker/network.rb index e30cd912..b9acec86 100644 --- a/lib/docker/network.rb +++ b/lib/docker/network.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class represents a Docker Network. class Docker::Network include Docker::Base diff --git a/lib/docker/rake_task.rb b/lib/docker/rake_task.rb index 30e8836c..b93a4f8c 100644 --- a/lib/docker/rake_task.rb +++ b/lib/docker/rake_task.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # This class allows image-based tasks to be created. class Docker::ImageTask < Rake::Task def self.scope_name(_scope, task_name) diff --git a/lib/docker/util.rb b/lib/docker/util.rb index 58c3eed2..c8549232 100644 --- a/lib/docker/util.rb +++ b/lib/docker/util.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'set' # This module holds shared logic that doesn't really belong anywhere else in the diff --git a/lib/docker/version.rb b/lib/docker/version.rb index 15ac493b..fe72bb83 100644 --- a/lib/docker/version.rb +++ b/lib/docker/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Docker # The version of the docker-api gem. VERSION = '2.3.0' diff --git a/lib/docker/volume.rb b/lib/docker/volume.rb index 97ef28bd..686f57c8 100644 --- a/lib/docker/volume.rb +++ b/lib/docker/volume.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # class represents a Docker Volume class Docker::Volume include Docker::Base diff --git a/lib/excon/middlewares/hijack.rb b/lib/excon/middlewares/hijack.rb index df82cdf5..aff1720c 100644 --- a/lib/excon/middlewares/hijack.rb +++ b/lib/excon/middlewares/hijack.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Excon module Middleware # Hijack is an Excon middleware which parses response headers and then diff --git a/spec/cov_spec.rb b/spec/cov_spec.rb index 12afb4c9..734e8989 100644 --- a/spec/cov_spec.rb +++ b/spec/cov_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.not_covered! diff --git a/spec/docker/connection_spec.rb b/spec/docker/connection_spec.rb index 6cb725a9..86291298 100644 --- a/spec/docker/connection_spec.rb +++ b/spec/docker/connection_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 12 diff --git a/spec/docker/container_spec.rb b/spec/docker/container_spec.rb index 4d77e43d..d5c8a34f 100644 --- a/spec/docker/container_spec.rb +++ b/spec/docker/container_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 39 diff --git a/spec/docker/event_spec.rb b/spec/docker/event_spec.rb index 07f03317..0ba6effe 100644 --- a/spec/docker/event_spec.rb +++ b/spec/docker/event_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 5 diff --git a/spec/docker/exec_spec.rb b/spec/docker/exec_spec.rb index b422b133..8e19bda8 100644 --- a/spec/docker/exec_spec.rb +++ b/spec/docker/exec_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 5 diff --git a/spec/docker/image_spec.rb b/spec/docker/image_spec.rb index 66c50337..36b023f5 100644 --- a/spec/docker/image_spec.rb +++ b/spec/docker/image_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 16 @@ -464,7 +466,7 @@ end context 'with a block capturing create output' do - let(:create_output) { "" } + let(:create_output) { +"" } let(:block) { Proc.new { |chunk| create_output << chunk } } before do @@ -537,7 +539,7 @@ let(:non_streamed) do Docker.connection.get('/images/get', 'names' => image) end - let(:streamed) { '' } + let(:streamed) { +'' } let(:tar_files) do proc do |string| Gem::Package::TarReader @@ -723,7 +725,7 @@ end context 'with a block capturing build output' do - let(:build_output) { "" } + let(:build_output) { +"" } let(:block) { Proc.new { |chunk| build_output << chunk } } let!(:image) { subject.build("FROM debian:stable\n", &block) } @@ -775,7 +777,7 @@ end context 'with a block capturing build output' do - let(:build_output) { "" } + let(:build_output) { +"" } let(:block) { Proc.new { |chunk| build_output << chunk } } it 'calls the block and passes build output' do @@ -784,7 +786,7 @@ end context 'uses a cached version the second time' do - let(:build_output_two) { "" } + let(:build_output_two) { +"" } let(:block_two) { Proc.new { |chunk| build_output_two << chunk } } let(:image_two) { subject.build_from_dir(dir, opts, &block_two) } diff --git a/spec/docker/messages_spec.rb b/spec/docker/messages_spec.rb index 5867485d..b1398ce8 100644 --- a/spec/docker/messages_spec.rb +++ b/spec/docker/messages_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 4 diff --git a/spec/docker/messages_stack.rb b/spec/docker/messages_stack.rb index dab89e62..48934c05 100644 --- a/spec/docker/messages_stack.rb +++ b/spec/docker/messages_stack.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! diff --git a/spec/docker/network_spec.rb b/spec/docker/network_spec.rb index a47c5d43..b5947091 100644 --- a/spec/docker/network_spec.rb +++ b/spec/docker/network_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' unless ::Docker.podman? diff --git a/spec/docker/util_spec.rb b/spec/docker/util_spec.rb index 0824c170..5fcbfb6b 100644 --- a/spec/docker/util_spec.rb +++ b/spec/docker/util_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' require 'tempfile' require 'fileutils' diff --git a/spec/docker/volume_spec.rb b/spec/docker/volume_spec.rb index 56f3c673..37be216f 100644 --- a/spec/docker/volume_spec.rb +++ b/spec/docker/volume_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 1 diff --git a/spec/docker_spec.rb b/spec/docker_spec.rb index d956e916..b6656d13 100644 --- a/spec/docker_spec.rb +++ b/spec/docker_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'spec_helper' SingleCov.covered! uncovered: 8 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5fe4e69b..8be80cab 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/setup' $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))