diff options
author | John Kerry <jk185160@ncr.com> | 2016-03-25 15:39:50 -0400 |
---|---|---|
committer | John Kerry <jk185160@ncr.com> | 2016-03-25 15:39:50 -0400 |
commit | 2420f2ed69cd162893ee7430c2c01a03aa6107f0 (patch) | |
tree | fab08904be87e4b81e319562b28e47d5b4aea96e | |
parent | c0d0e1cddcb4ead133428fe6ee30a84a51fd1db1 (diff) | |
download | chef-2420f2ed69cd162893ee7430c2c01a03aa6107f0.tar.gz |
fixing rubocop violations, mostly string format, in the sftp provider and spec files
-rw-r--r-- | lib/chef/provider/remote_file/sftp.rb | 20 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/sftp_spec.rb | 3 |
2 files changed, 10 insertions, 13 deletions
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb index 680e69c675..87aa8d0398 100644 --- a/lib/chef/provider/remote_file/sftp.rb +++ b/lib/chef/provider/remote_file/sftp.rb @@ -16,17 +16,16 @@ # limitations under the License. # -require 'uri' -require 'tempfile' -require 'net/sftp' -require 'chef/provider/remote_file' -require 'chef/file_content_management/tempfile' +require "uri" +require "tempfile" +require "net/sftp" +require "chef/provider/remote_file" +require "chef/file_content_management/tempfile" class Chef class Provider class RemoteFile class SFTP - attr_reader :uri attr_reader :new_resource attr_reader :current_resource @@ -77,10 +76,10 @@ class Chef def validate_userinfo! if uri.userinfo - if !(uri.user) + unless uri.user raise ArgumentError, "no user name provided in the sftp URI" end - if !(uri.password) + unless uri.password raise ArgumentError, "no password provided in the sftp URI" end else @@ -90,14 +89,15 @@ class Chef # Fetches using Net::FTP, returns a Tempfile with the content def get - tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile + tempfile = + Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile sftp.download!(uri.path, tempfile.path) tempfile.close if tempfile tempfile end def parse_path - path = uri.path.sub(%r{\A/}, '%2F') # re-encode the beginning slash because uri library decodes it. + path = uri.path.sub(%r{\A/}, "%2F") # re-encode the beginning slash because uri library decodes it. directories = path.split(%r{/}, -1) directories.each {|d| d.gsub!(/%([0-9A-Fa-f][0-9A-Fa-f])/) { [$1].pack("H2") } diff --git a/spec/unit/provider/remote_file/sftp_spec.rb b/spec/unit/provider/remote_file/sftp_spec.rb index c030ff83c1..673ea015c0 100644 --- a/spec/unit/provider/remote_file/sftp_spec.rb +++ b/spec/unit/provider/remote_file/sftp_spec.rb @@ -37,8 +37,6 @@ describe Chef::Provider::RemoteFile::SFTP do Chef::Resource::RemoteFile.new("remote file sftp backend test (current resource)'") end - - let(:uri) { URI.parse("sftp://conan:cthu1hu@opscode.com/seattle.txt") } let(:sftp) do @@ -100,7 +98,6 @@ describe Chef::Provider::RemoteFile::SFTP do expect { Chef::Provider::RemoteFile::SFTP.new(uri, new_resource, current_resource) }.to raise_error(ArgumentError) end - end describe "when fetching the object" do |