summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-11-26 12:41:42 -0800
committerdanielsdeleo <dan@getchef.com>2014-11-26 12:41:42 -0800
commita0c294d8d1b6b0323d3c01265e824deb8a5d972d (patch)
tree1b1f02d5732b1400dbc9854d5de1796ff89b145d
parent45167319996c4fc7e65351a459ae2ee8a5960b31 (diff)
downloadchef-a0c294d8d1b6b0323d3c01265e824deb8a5d972d.tar.gz
Remove 1.8 and 1.9 specific monkey patches
-rw-r--r--lib/chef.rb7
-rw-r--r--lib/chef/application/knife.rb1
-rw-r--r--lib/chef/cookbook_version.rb1
-rw-r--r--lib/chef/http.rb1
-rw-r--r--lib/chef/monkey_patches/file.rb26
-rw-r--r--lib/chef/monkey_patches/fileutils.rb65
-rw-r--r--lib/chef/monkey_patches/numeric.rb15
-rw-r--r--lib/chef/monkey_patches/object.rb9
-rw-r--r--lib/chef/monkey_patches/pathname.rb32
-rw-r--r--lib/chef/monkey_patches/regexp.rb34
-rw-r--r--lib/chef/monkey_patches/string.rb49
-rw-r--r--lib/chef/monkey_patches/tempfile.rb64
-rw-r--r--lib/chef/monkey_patches/uri.rb70
-rw-r--r--lib/chef/provider/deploy.rb1
-rw-r--r--spec/unit/monkey_patches/string_spec.rb37
15 files changed, 0 insertions, 412 deletions
diff --git a/lib/chef.rb b/lib/chef.rb
index 0d5fb3de2c..7f54b91f14 100644
--- a/lib/chef.rb
+++ b/lib/chef.rb
@@ -32,10 +32,3 @@ require 'chef/run_status'
require 'chef/handler'
require 'chef/handler/json_file'
-require 'chef/monkey_patches/tempfile'
-require 'chef/monkey_patches/string'
-require 'chef/monkey_patches/numeric'
-require 'chef/monkey_patches/object'
-require 'chef/monkey_patches/file'
-require 'chef/monkey_patches/uri'
-
diff --git a/lib/chef/application/knife.rb b/lib/chef/application/knife.rb
index ca5a9c9900..1a19a45598 100644
--- a/lib/chef/application/knife.rb
+++ b/lib/chef/application/knife.rb
@@ -20,7 +20,6 @@ require 'chef/application'
require 'mixlib/log'
require 'ohai/config'
require 'chef/monkey_patches/net_http.rb'
-require 'chef/monkey_patches/uri.rb'
class Chef::Application::Knife < Chef::Application
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 505b403e65..3bf19296c9 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -24,7 +24,6 @@ require 'chef/cookbook/file_vendor'
require 'chef/cookbook/metadata'
require 'chef/version_class'
require 'pathname'
-require 'chef/monkey_patches/pathname'
require 'chef/digester'
class Chef
diff --git a/lib/chef/http.rb b/lib/chef/http.rb
index ee951bd675..8d00a38dc1 100644
--- a/lib/chef/http.rb
+++ b/lib/chef/http.rb
@@ -25,7 +25,6 @@ require 'tempfile'
require 'net/https'
require 'uri'
require 'chef/http/basic_client'
-require 'chef/monkey_patches/string'
require 'chef/monkey_patches/net_http'
require 'chef/config'
require 'chef/platform/query_helpers'
diff --git a/lib/chef/monkey_patches/file.rb b/lib/chef/monkey_patches/file.rb
deleted file mode 100644
index acc0ca73fe..0000000000
--- a/lib/chef/monkey_patches/file.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Author:: Daniel DeLeo (<dan@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.
-#
-
-if !File.respond_to?(:realpath)
- require 'pathname'
- class File
- def self.realpath(path)
- Pathname.new(path).realpath.to_s
- end
- end
-end
diff --git a/lib/chef/monkey_patches/fileutils.rb b/lib/chef/monkey_patches/fileutils.rb
deleted file mode 100644
index f18bead144..0000000000
--- a/lib/chef/monkey_patches/fileutils.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Author:: Stephen Delano (<stephen@opscode.com>)
-# Copyright:: Copyright (c) 2012 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.
-#
-
-# == FileUtils::Entry_ (Patch)
-# On Ruby 1.9.3 and earlier, FileUtils.cp_r(foo, bar, :preserve => true) fails
-# when attempting to copy a directory containing symlinks. This has been
-# patched in the trunk of Ruby, and this is a monkey patch of the offending
-# code.
-
-unless RUBY_VERSION =~ /^2/
- require 'fileutils'
-
- class FileUtils::Entry_
- def copy_metadata(path)
- st = lstat()
- if !st.symlink?
- File.utime st.atime, st.mtime, path
- end
- begin
- if st.symlink?
- begin
- File.lchown st.uid, st.gid, path
- rescue NotImplementedError
- end
- else
- File.chown st.uid, st.gid, path
- end
- rescue Errno::EPERM
- # clear setuid/setgid
- if st.symlink?
- begin
- File.lchmod st.mode & 01777, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode & 01777, path
- end
- else
- if st.symlink?
- begin
- File.lchmod st.mode, path
- rescue NotImplementedError
- end
- else
- File.chmod st.mode, path
- end
- end
- end
- end
-end
diff --git a/lib/chef/monkey_patches/numeric.rb b/lib/chef/monkey_patches/numeric.rb
deleted file mode 100644
index f4612fdbf3..0000000000
--- a/lib/chef/monkey_patches/numeric.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-unless 0.respond_to?(:fdiv)
- class Numeric
- def fdiv(other)
- to_f / other
- end
- end
-end
-
-# String elements referenced with [] <= 1.8.6 return a Fixnum. Cheat to allow
-# for the simpler "test"[2].ord construct
-class Numeric
- def ord
- return self
- end
-end
diff --git a/lib/chef/monkey_patches/object.rb b/lib/chef/monkey_patches/object.rb
deleted file mode 100644
index 017a4b7938..0000000000
--- a/lib/chef/monkey_patches/object.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Object
- unless new.respond_to?(:tap)
- def tap
- yield self
- return self
- end
- end
-end
-
diff --git a/lib/chef/monkey_patches/pathname.rb b/lib/chef/monkey_patches/pathname.rb
deleted file mode 100644
index c0255ae7ea..0000000000
--- a/lib/chef/monkey_patches/pathname.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-require 'pathname'
-
-if RUBY_VERSION.to_f < 1.9
- class Pathname
- @@old_each_filename = instance_method(:each_filename)
-
- def each_filename(&block)
- if block_given?
- EachFilenameEnumerable.new(self).each(&block)
- else
- EachFilenameEnumerable.new(self)
- end
- end
-
- def old_each_filename(&block)
- @@old_each_filename.bind(self).call(&block)
- end
-
- class EachFilenameEnumerable
- include Enumerable
- attr_reader :pathname
-
- def initialize(pathname)
- @pathname = pathname
- end
-
- def each(&block)
- @pathname.old_each_filename(&block)
- end
- end
- end
-end
diff --git a/lib/chef/monkey_patches/regexp.rb b/lib/chef/monkey_patches/regexp.rb
deleted file mode 100644
index 8a7ee77cb5..0000000000
--- a/lib/chef/monkey_patches/regexp.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2009 Marc-Andre Lafortune
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-class Regexp
- # Standard in Ruby 1.8.7+. See official documentation[http://www.ruby-doc.org/core-1.8.7/classes/Regexp.html]
- class << self
- unless (union(%w(a b)) rescue false)
- alias :union_without_array_argument :union
-
- def union(*arg)
- return union_without_array_argument(*arg) unless arg.size == 1
- union_without_array_argument(*arg.first)
- end
- end
- end
-end
diff --git a/lib/chef/monkey_patches/string.rb b/lib/chef/monkey_patches/string.rb
deleted file mode 100644
index f91e27ddc5..0000000000
--- a/lib/chef/monkey_patches/string.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 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.
-#
-
-# == String (Patch)
-# On ruby 1.9, Strings are aware of multibyte characters, so +size+ and +length+
-# give the actual number of characters. In Chef::REST, we need the bytesize
-# so we can correctly set the Content-Length headers, but ruby 1.8.6 and lower
-# don't define String#bytesize. Monkey patching time!
-
-begin
- require 'enumerator'
-rescue LoadError
-end
-
-class String
- unless method_defined?(:bytesize)
- alias :bytesize :size
- end
-
- unless method_defined?(:lines)
- def lines
- enum_for(:each)
- end
- end
-end
-
-# <= 1.8.6 needs some ord!
-class String
- unless method_defined?(:ord)
- def ord
- self.unpack('C').first
- end
- end
-end
diff --git a/lib/chef/monkey_patches/tempfile.rb b/lib/chef/monkey_patches/tempfile.rb
deleted file mode 100644
index b9179f182b..0000000000
--- a/lib/chef/monkey_patches/tempfile.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 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.
-#
-
-# == Tempfile (Patch)
-# Tempfile has a horrible bug where it causes an IOError: closed stream in its
-# finalizer, leading to intermittent application crashes with confusing stack
-# traces. Here we monkey patch the fix into place. You can track the bug on
-# ruby's redmine: http://redmine.ruby-lang.org/issues/show/3119
-#
-# The patch is slightly different for Ruby 1.8 and Ruby 1.9, both patches are
-# included here.
-class Tempfile # :nodoc:
- # Tempfile has changes between 1.8.x and 1.9.x
- # so we monkey patch separately
- if RUBY_VERSION =~ /^1\.8/
- def unlink
- # keep this order for thread safeness
- begin
- File.unlink(@tmpname) if File.exist?(@tmpname)
- @@cleanlist.delete(@tmpname)
- @tmpname = nil
- ObjectSpace.undefine_finalizer(self)
- rescue Errno::EACCES
- # may not be able to unlink on Windows; just ignore
- end
- end
- alias delete unlink
-
-
- # There is a patch for this, to be merged into 1.9 at some point.
- # When that happens, we'll want to also check the RUBY_PATCHLEVEL
- elsif RUBY_VERSION =~ /^1\.9/
- def unlink
- # keep this order for thread safeness
- return unless @tmpname
- begin
- if File.exist?(@tmpname)
- File.unlink(@tmpname)
- end
- # remove tmpname from remover
- @data[0] = @data[2] = nil
- @tmpname = nil
- rescue Errno::EACCES
- # may not be able to unlink on Windows; just ignore
- end
- end
- alias delete unlink
- end
-end
diff --git a/lib/chef/monkey_patches/uri.rb b/lib/chef/monkey_patches/uri.rb
deleted file mode 100644
index 158285e395..0000000000
--- a/lib/chef/monkey_patches/uri.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
-# You can redistribute it and/or modify it under either the terms of the
-# 2-clause BSDL (see the file BSDL), or the conditions below:
-#
-# 1. You may make and give away verbatim copies of the source form of the
-# software without restriction, provided that you duplicate all of the
-# original copyright notices and associated disclaimers.
-#
-# 2. You may modify your copy of the software in any way, provided that
-# you do at least ONE of the following:
-#
-# a) place your modifications in the Public Domain or otherwise
-# make them Freely Available, such as by posting said
-# modifications to Usenet or an equivalent medium, or by allowing
-# the author to include your modifications in the software.
-#
-# b) use the modified software only within your corporation or
-# organization.
-#
-# c) give non-standard binaries non-standard names, with
-# instructions on where to get the original software distribution.
-#
-# d) make other distribution arrangements with the author.
-#
-# 3. You may distribute the software in object code or binary form,
-# provided that you do at least ONE of the following:
-#
-# a) distribute the binaries and library files of the software,
-# together with instructions (in the manual page or equivalent)
-# on where to get the original distribution.
-#
-# b) accompany the distribution with the machine-readable source of
-# the software.
-#
-# c) give non-standard binaries non-standard names, with
-# instructions on where to get the original software distribution.
-#
-# d) make other distribution arrangements with the author.
-#
-# 4. You may modify and include the part of the software into any other
-# software (possibly commercial). But some files in the distribution
-# are not written by the author, so that they are not under these terms.
-#
-# For the list of those files and their copying conditions, see the
-# file LEGAL.
-#
-# 5. The scripts and library files supplied as input to or produced as
-# output from the software do not automatically fall under the
-# copyright of the software, but belong to whomever generated them,
-# and may be sold commercially, and may be aggregated with this
-# software.
-#
-# 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE.
-
-require 'uri'
-
-unless URI::Generic.instance_methods.map {|m| m.to_s}.include?("hostname")
-
- class URI::Generic
- # Copied from the MRI source for Ruby 1.9.3
- # File lib/uri/generic.rb, line 659
- def hostname
- v = self.host
- /\A\[(.*)\]\z/ =~ v ? $1 : v
- end
- end
-end
diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb
index 26c677643b..19e7c01ab1 100644
--- a/lib/chef/provider/deploy.rb
+++ b/lib/chef/provider/deploy.rb
@@ -18,7 +18,6 @@
require "chef/mixin/command"
require "chef/mixin/from_file"
-require "chef/monkey_patches/fileutils"
require "chef/provider/git"
require "chef/provider/subversion"
require "chef/dsl/recipe"
diff --git a/spec/unit/monkey_patches/string_spec.rb b/spec/unit/monkey_patches/string_spec.rb
deleted file mode 100644
index 74e3753229..0000000000
--- a/spec/unit/monkey_patches/string_spec.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Author:: Devin Ben-Hur <dbenhur@whitepages.com>
-# Copyright:: Copyright (c) 2008, 2011 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.
-#
-
-require 'spec_helper'
-require 'chef/monkey_patches/string'
-
-describe String do
-
- describe "#ord" do
- it "converts each ASCII-8BIT character to corresponding positive Fixnum" do
- (0..0xff).each do |num|
- ch = num.chr
- ch.force_encoding('ASCII-8BIT') if ch.respond_to? :force_encoding
-
- expect(ch.ord).to be_a_kind_of(Fixnum)
- expect(ch.ord).to eq(num)
- end
- end
-
- end
-
-end