diff options
author | sersut <serdar@opscode.com> | 2013-06-03 13:29:08 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2013-06-03 13:30:09 -0700 |
commit | c1aba2676136a81da712f7772d020ed253b89392 (patch) | |
tree | 25cadebd7653eced1c641ddb360bce5769ffe3e9 | |
parent | 7fee9a0121fc56228a0214390b521a11894ef601 (diff) | |
download | chef-c1aba2676136a81da712f7772d020ed253b89392.tar.gz |
Remove unused class RemoteFile::Result.
-rw-r--r-- | lib/chef/provider/remote_file/content.rb | 3 | ||||
-rw-r--r-- | lib/chef/provider/remote_file/ftp.rb | 5 | ||||
-rw-r--r-- | lib/chef/provider/remote_file/http.rb | 4 | ||||
-rw-r--r-- | lib/chef/provider/remote_file/local_file.rb | 3 | ||||
-rw-r--r-- | lib/chef/provider/remote_file/result.rb | 39 | ||||
-rw-r--r-- | lib/chef/providers.rb | 1 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/content_spec.rb | 24 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/ftp_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/http_spec.rb | 27 | ||||
-rw-r--r-- | spec/unit/provider/remote_file/local_file_spec.rb | 4 |
10 files changed, 21 insertions, 93 deletions
diff --git a/lib/chef/provider/remote_file/content.rb b/lib/chef/provider/remote_file/content.rb index d75ee735a1..7f9e2332a8 100644 --- a/lib/chef/provider/remote_file/content.rb +++ b/lib/chef/provider/remote_file/content.rb @@ -62,8 +62,7 @@ class Chef # Given a source uri, return a Tempfile, or a File that acts like a Tempfile (close! method) def grab_file_from_uri(uri) - result = Chef::Provider::RemoteFile::Fetcher.for_resource(uri, @new_resource, @current_resource).fetch - result.raw_file + Chef::Provider::RemoteFile::Fetcher.for_resource(uri, @new_resource, @current_resource).fetch end def current_resource_matches_target_checksum? diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb index 865667a31c..d75fb7a52c 100644 --- a/lib/chef/provider/remote_file/ftp.rb +++ b/lib/chef/provider/remote_file/ftp.rb @@ -20,7 +20,6 @@ require 'uri' require 'tempfile' require 'net/ftp' require 'chef/provider/remote_file' -require 'chef/provider/remote_file/result' require 'chef/file_content_management/tempfile' class Chef @@ -85,10 +84,8 @@ class Chef def fetch with_connection do - tempfile = get - @result = Chef::Provider::RemoteFile::Result.new(tempfile, nil, nil) + get end - @result end def ftp diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb index 855041f91e..6ffd83f438 100644 --- a/lib/chef/provider/remote_file/http.rb +++ b/lib/chef/provider/remote_file/http.rb @@ -20,7 +20,6 @@ require 'chef/rest' require 'chef/digester' require 'chef/provider/remote_file' -require 'chef/provider/remote_file/result' require 'chef/provider/remote_file/cache_control_data' class Chef @@ -69,7 +68,8 @@ class Chef raise e end end - return Chef::Provider::RemoteFile::Result.new(tempfile, cache_control_data.etag, cache_control_data.mtime) + + tempfile end private diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb index 233076ceb6..87f498e053 100644 --- a/lib/chef/provider/remote_file/local_file.rb +++ b/lib/chef/provider/remote_file/local_file.rb @@ -19,7 +19,6 @@ require 'uri' require 'tempfile' require 'chef/provider/remote_file' -require 'chef/provider/remote_file/result' class Chef class Provider @@ -39,7 +38,7 @@ class Chef tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile Chef::Log.debug("#{new_resource} staging #{uri.path} to #{tempfile.path}") FileUtils.cp(uri.path, tempfile.path) - Chef::Provider::RemoteFile::Result.new(tempfile, nil, nil) + tempfile end end diff --git a/lib/chef/provider/remote_file/result.rb b/lib/chef/provider/remote_file/result.rb deleted file mode 100644 index dccb8e2222..0000000000 --- a/lib/chef/provider/remote_file/result.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# Author:: Jesse Campbell (<hikeit@gmail.com>) -# Author:: Lamont Granquist (<lamont@opscode.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - - -class Chef - class Provider - class RemoteFile - class Result - - attr_accessor :raw_file - attr_accessor :etag - attr_accessor :mtime - - def initialize(raw_file, etag, mtime) - @raw_file = raw_file - @etag = etag - @mtime = mtime - end - end - end - end -end - diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb index 8fc66fc9a8..145de8173e 100644 --- a/lib/chef/providers.rb +++ b/lib/chef/providers.rb @@ -106,7 +106,6 @@ require 'chef/provider/remote_file/ftp' require 'chef/provider/remote_file/http' require 'chef/provider/remote_file/local_file' require 'chef/provider/remote_file/fetcher' -require 'chef/provider/remote_file/result' require "chef/provider/lwrp_base" require 'chef/provider/registry_key' diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb index ed02fa9a32..36ecfe1c8d 100644 --- a/spec/unit/provider/remote_file/content_spec.rb +++ b/spec/unit/provider/remote_file/content_spec.rb @@ -84,32 +84,20 @@ describe Chef::Provider::RemoteFile::Content do describe "when the fetcher returns nil for the tempfile" do before do - @result = mock("Chef::Provider::RemoteFile::Result", :raw_file => nil, :etag => nil, :mtime => nil) - http_fetcher = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @result) + http_fetcher = mock("Chef::Provider::RemoteFile::HTTP", :fetch => nil) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) end it "should return nil for the tempfile" do content.tempfile.should be_nil end - - it "should not set the etags on the new resource" do - new_resource.should_not_receive(:etag).with(@result.etag) - content.tempfile - end - - it "should not set the mtime on the new resource" do - new_resource.should_not_receive(:mtime).with(@result.mtime) - content.tempfile - end end - describe "when the fetcher returns a result with a valid tempfile" do + describe "when the fetcher returns a valid tempfile" do let(:mtime) { Time.now } let(:tempfile) { mock("Tempfile") } - let(:result) { Chef::Provider::RemoteFile::Result.new(tempfile, "etag", mtime) } - let(:http_fetcher) { mock("Chef::Provider::RemoteFile::HTTP", :fetch => result) } + let(:http_fetcher) { mock("Chef::Provider::RemoteFile::HTTP", :fetch => tempfile) } before do Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri, new_resource, current_resource).and_return(http_fetcher) @@ -189,8 +177,7 @@ describe Chef::Provider::RemoteFile::Content do before do @tempfile = mock("Tempfile") mtime = Time.now - @result = mock("Chef::Provider::RemoteFile::Result", :raw_file => @tempfile, :etag => "etag", :mtime => mtime) - http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @result) + http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri1, new_resource, current_resource).and_return(http_fetcher_works) end @@ -225,8 +212,7 @@ describe Chef::Provider::RemoteFile::Content do URI.should_not_receive(:parse).with(new_resource.source[1]) @tempfile = mock("Tempfile") mtime = Time.now - @result = mock("Chef::Provider::RemoteFile::Result", :raw_file => @tempfile, :etag => "etag", :mtime => mtime) - http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @result) + http_fetcher_works = mock("Chef::Provider::RemoteFile::HTTP", :fetch => @tempfile) Chef::Provider::RemoteFile::Fetcher.should_receive(:for_resource).with(@uri0, new_resource, current_resource).and_return(http_fetcher_works) end diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index 2d2e9d34cb..4022fb25d3 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -193,7 +193,7 @@ describe Chef::Provider::RemoteFile::FTP do it "should return a tempfile in the result" do result = fetcher.fetch - result.raw_file.should equal(tempfile) + result.should equal(tempfile) end end @@ -215,7 +215,7 @@ describe Chef::Provider::RemoteFile::FTP do ENV.should_receive(:[]=).with("SOCKS_SERVER", "socks5://bill:ted@socks.example.com:5000").ordered ENV.should_receive(:[]=).with("SOCKS_SERVER", current_socks_server).ordered result = fetcher.fetch - result.raw_file.should equal(tempfile) + result.should equal(tempfile) end end diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb index 43e3361f5e..6ae19327eb 100644 --- a/spec/unit/provider/remote_file/http_spec.rb +++ b/spec/unit/provider/remote_file/http_spec.rb @@ -200,7 +200,7 @@ describe Chef::Provider::RemoteFile::HTTP do e = Net::HTTPRetriableError.new("304", r) rest.stub!(:streaming_request).and_raise(e) result = fetcher.fetch - result.raw_file.should be_nil + result.should be_nil end end @@ -214,10 +214,9 @@ describe Chef::Provider::RemoteFile::HTTP do Chef::Digester.should_receive(:checksum_for_file).with(tempfile_path).and_return(fetched_content_checksum) end - it "should return a result" do + it "should return a tempfile" do result = fetcher.fetch - result.should be_a_kind_of(Chef::Provider::RemoteFile::Result) - result.raw_file.should == tempfile + result.should == tempfile cache_control_data.etag.should be_nil cache_control_data.mtime.should be_nil cache_control_data.checksum.should == fetched_content_checksum @@ -226,9 +225,7 @@ describe Chef::Provider::RemoteFile::HTTP do context "and the response does not contain an etag" do let(:last_response) { {"etag" => nil} } it "does not include an etag in the result" do - result = fetcher.fetch - result.should be_a_kind_of(Chef::Provider::RemoteFile::Result) - result.etag.should be_nil + fetcher.fetch cache_control_data.etag.should be_nil cache_control_data.mtime.should be_nil cache_control_data.checksum.should == fetched_content_checksum @@ -239,9 +236,7 @@ describe Chef::Provider::RemoteFile::HTTP do let(:last_response) { {"etag" => "abc123"} } it "includes the etag value in the response" do - result = fetcher.fetch - result.raw_file.should == tempfile - result.etag.should == "abc123" + fetcher.fetch cache_control_data.etag.should == "abc123" cache_control_data.mtime.should be_nil cache_control_data.checksum.should == fetched_content_checksum @@ -254,9 +249,7 @@ describe Chef::Provider::RemoteFile::HTTP do it "does not set an mtime in the result" do # RFC 2616 suggests that servers that do not set a Date header do not # have a reliable clock, so no use in making them deal with dates. - result = fetcher.fetch - result.should be_a_kind_of(Chef::Provider::RemoteFile::Result) - result.mtime.should be_nil + fetcher.fetch cache_control_data.etag.should be_nil cache_control_data.mtime.should be_nil cache_control_data.checksum.should == fetched_content_checksum @@ -270,9 +263,7 @@ describe Chef::Provider::RemoteFile::HTTP do end it "sets the mtime to the Last-Modified time in the response" do - result = fetcher.fetch - result.should be_a_kind_of(Chef::Provider::RemoteFile::Result) - result.mtime.should == last_response["last_modified"] + fetcher.fetch cache_control_data.etag.should be_nil cache_control_data.mtime.should == last_response["last_modified"] end @@ -284,9 +275,7 @@ describe Chef::Provider::RemoteFile::HTTP do end it "sets the mtime to the Date in the response" do - result = fetcher.fetch - result.should be_a_kind_of(Chef::Provider::RemoteFile::Result) - result.mtime.should == last_response["date"] + fetcher.fetch cache_control_data.etag.should be_nil cache_control_data.mtime.should == last_response["date"] cache_control_data.checksum.should == fetched_content_checksum diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb index 625b6e88ee..6b318f972a 100644 --- a/spec/unit/provider/remote_file/local_file_spec.rb +++ b/spec/unit/provider/remote_file/local_file_spec.rb @@ -52,9 +52,7 @@ describe Chef::Provider::RemoteFile::LocalFile do ::FileUtils.should_receive(:cp).with(uri.path, tempfile.path) result = fetcher.fetch - result.raw_file.should == tempfile - result.etag.should be_nil - result.mtime.should be_nil + result.should == tempfile end end |