Permalink
Browse files

Monkeypatch to support 1.8.7

  • Loading branch information...
1 parent db3766a commit 736e706acee7e6e74bea38ed2233e829b020e05f @txus committed Jan 6, 2011
Showing with 9 additions and 4 deletions.
  1. +5 −0 lib/core_ext/array.rb
  2. +2 −0 lib/micetrap.rb
  3. +1 −2 lib/micetrap/logger.rb
  4. +1 −2 spec/micetrap/logger_spec.rb
View
@@ -0,0 +1,5 @@
+if RUBY_VERSION =~ /1\.8/
+ class Array
+ alias :sample :choice
+ end
+end
View
@@ -1,3 +1,5 @@
+require 'core_ext/array'
+
require 'micetrap/services/exceptions'
require 'micetrap/services/base'
View
@@ -17,8 +17,7 @@ def file
end
def log_probe(line, remote_host, remote_port)
- content = line.strip.length > 0 ? line
- : '(empty line)'
+ content = line.strip.length > 0 ? line : '(empty line)'
logged = "\n#{Time.now} Recorded a probe coming from #{remote_host}:#{remote_port} containing the following: #{content}"
File.open(@filename, 'a') do |f|
f.write logged
@@ -6,8 +6,7 @@ module Micetrap
describe "#initialize" do
it 'initializes the filename' do
- Time.stub_chain('now.strftime')
- .and_return "2011-01-03__20-30"
+ Time.stub_chain('now.strftime').and_return "2011-01-03__20-30"
logger = Logger.new :ftp
logger.filename.should == "micetrap_ftp_2011-01-03__20-30.log"
end

0 comments on commit 736e706

Please sign in to comment.