[Pkg-puppet-devel] [facter] 113/352: (maint) Remove monkey patch

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:36 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit d75e5c62b41bfcb8ab9ecb1f9d99a767612de30f
Author: Kylo Ginsberg <kylo at puppetlabs.com>
Date:   Thu Dec 26 23:32:15 2013 -0800

    (maint) Remove monkey patch
    
    Prior to this patch, running spec tests with ruby 2.x
    would result in deprecation warnings like so:
    
    /Users/kylo/.rbenv/versions/2.1.0/lib/ruby/2.1.0/delegate.rb:343: warning: IO#lines is deprecated; use #each_line instead
    
    This patch removes the monkey patching that led to those
    warnings, and simply changes the code to use each_line rather
    than lines, which is apparently supported in all the ruby versions
    from 1.8.5 to 2.x.
---
 lib/facter/selinux.rb                 |  2 +-
 lib/facter/util/monkey_patches.rb     | 31 --------------------------
 spec/unit/util/monkey_patches_spec.rb | 42 -----------------------------------
 3 files changed, 1 insertion(+), 74 deletions(-)

diff --git a/lib/facter/selinux.rb b/lib/facter/selinux.rb
index 4d8e801..0c54cb9 100644
--- a/lib/facter/selinux.rb
+++ b/lib/facter/selinux.rb
@@ -22,7 +22,7 @@ def selinux_mount_point
     # a hang. Reading from other parts of /proc does not seem to cause this problem.
     # The work around is to read the file in another process.
     # -- andy Fri Aug 31 2012
-    selinux_line = Facter::Util::Resolution.exec('cat /proc/self/mounts').lines.find { |line| line =~ /selinuxfs/ }
+    selinux_line = Facter::Util::Resolution.exec('cat /proc/self/mounts').each_line.find { |line| line =~ /selinuxfs/ }
     if selinux_line
       path = selinux_line.split[1]
     end
diff --git a/lib/facter/util/monkey_patches.rb b/lib/facter/util/monkey_patches.rb
index 0946137..54bbff8 100644
--- a/lib/facter/util/monkey_patches.rb
+++ b/lib/facter/util/monkey_patches.rb
@@ -2,38 +2,7 @@
 # version 1.8.5. This allows us to use RbConfig in place of the older Config in
 # our code and still be compatible with at least Ruby 1.8.1.
 require 'rbconfig'
-require 'enumerator'
 
 unless defined? ::RbConfig
   ::RbConfig = ::Config
 end
-
-module Facter
-  module Util
-    module MonkeyPatches
-      module Lines
-        def lines(separator = $/)
-          if block_given?
-            self.each_line(separator) {|line| yield line }
-            return self
-          else
-            return enum_for(:each_line, separator)
-          end
-        end
-      end
-    end
-  end
-end
-
-public
-class String
-  unless method_defined? :lines
-    include Facter::Util::MonkeyPatches::Lines
-  end
-end
-
-class IO
-  unless method_defined? :lines
-    include Facter::Util::MonkeyPatches::Lines
-  end
-end
diff --git a/spec/unit/util/monkey_patches_spec.rb b/spec/unit/util/monkey_patches_spec.rb
deleted file mode 100644
index 13d3fa6..0000000
--- a/spec/unit/util/monkey_patches_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'spec_helper'
-require 'tempfile'
-
-describe 'Monkey Patches' do
-  let(:subject) { "a b c d e f\ng h i j" }
-
-  context 'String' do
-    it "should respond to lines" do
-       subject.lines.to_a.should == ["a b c d e f\n", "g h i j"]
-    end
-    it "should accept a block" do
-      our_lines = []
-      subject.lines do |line| our_lines << line end
-      our_lines.should == ["a b c d e f\n", "g h i j"]
-    end
-  end
-
-  context 'IO' do
-    it "should respond to lines" do
-      our_lines = nil
-      Tempfile.open("lines") do | file |
-        file.write(subject)
-        file.flush
-        file.rewind
-        our_lines = file.lines.to_a
-      end
-      our_lines.should == ["a b c d e f\n", "g h i j"]
-    end
-    it "should accept a block" do
-      our_lines = []
-      file = Tempfile.new("lines")
-      file.write(subject)
-      file.flush
-      file.rewind
-      file.lines.each do |line| our_lines << line end
-      file.unlink
-      our_lines.should == ["a b c d e f\n", "g h i j"]
-    end
-  end
-
-end
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list