Skip to content

Commit

Permalink
remove mixing enumerable into string
Browse files Browse the repository at this point in the history
remove ord (standard in string)
  • Loading branch information
kbrock committed Aug 13, 2014
1 parent 8a63772 commit fe3833c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
43 changes: 0 additions & 43 deletions lib/spec/util/extensions/miq-string_spec.rb
Expand Up @@ -9,49 +9,6 @@
Kernel.should_receive(:warn).never
Array('somestring')
end

context 'Enumerable' do
it 'included' do
String.include?(Enumerable).should be_true
end

it '#any? warns' do
Kernel.should_receive(:warn).once
"one\ntwo".any? { |str| str == 'two'}.should be_true
end

context '#to_a' do
it 'defined' do
String.method_defined?(:to_a).should be_true
end

it 'does not respond' do
String.respond_to?(:to_a).should_not be_true
end

it 'warns' do
Kernel.should_receive(:warn).once
"one\ntwo".to_a.should == ["one\n", 'two']
end
end
end

context '#each' do
it 'defined' do
String.method_defined?(:each).should be_true
end

it 'does not respond' do
String.respond_to?(:each).should_not be_true
end

it 'calls each_line and warns' do
str = 'one\ntwo'
str.should_receive(:each_line).once
Kernel.should_receive(:warn).once
str.each { |s| s }
end
end
end

it '#<<(exception)' do
Expand Down
20 changes: 0 additions & 20 deletions lib/util/extensions/miq-string.rb
Expand Up @@ -45,26 +45,6 @@ def +(str)
self.original_plus(str.message)
end

unless method_defined?(:each)
include Enumerable

def respond_to?(symbol, include_private=false)
method = symbol.to_sym
return false if method == :each || method == :to_a
super
end

def each(*args, &block)
if !defined?(Rails) || !Rails.env.production?
msg = "[DEPRECATION] String#each has been removed from ruby 1.9. Please use String#each_line instead. At #{caller[0]}"
$log.warn msg if $log
Kernel.warn msg
end

self.each_line(*args, &block)
end
end

unless method_defined?(:ord)
def ord
raise ArgumentError, "empty string" if self.length == 0
Expand Down

0 comments on commit fe3833c

Please sign in to comment.