Permalink
Browse files

Inlined the String#indent method to avoid collision with ActiveSuppor…

…t 4.0
  • Loading branch information...
1 parent 0b3b4b3 commit 4ebd34c62342e04fb8c4452b20f48d6f8cb66c40 @cjheath committed Jun 14, 2013
Showing with 8 additions and 12 deletions.
  1. +8 −12 lib/treetop/ruby_extensions/string.rb
@@ -22,23 +22,19 @@ def blank?
# The following methods are lifted from Facets 2.0.2
def tabto(n)
if self =~ /^( *)\S/
- indent(n - $1.length)
- else
- self
- end
- end
-
- unless method_defined?(:indent)
- def indent(n)
- if n >= 0
- gsub(/^/, ' ' * n)
+ # Inlined due to collision with ActiveSupport 4.0: indent(n - $1.length)
+ m = n - $1.length
+ if m >= 0
+ gsub(/^/, ' ' * m)
else
- gsub(/^ {0,#{-n}}/, "")
+ gsub(/^ {0,#{-m}}/, "")
end
+ else
+ self
end
end
def treetop_camelize
to_s.gsub(/\/(.?)/){ "::" + $1.upcase }.gsub(/(^|_)(.)/){ $2.upcase }
end
-end
+end

0 comments on commit 4ebd34c

Please sign in to comment.