Permalink
Browse files

+ Explicitly use Ruby18Parser to remove deprecation warnings.

+ Use File.binread (File.read in 1.8) to bypass encoding errors
[git-p4: depot-paths = "//src/flog/dev/": change = 7227]
  • Loading branch information...
1 parent 44d9a95 commit 36444719e5541d7e6809c323835914ace6715079 @zenspider zenspider committed Mar 23, 2012
Showing with 11 additions and 3 deletions.
  1. +1 −1 README.txt
  2. +10 −2 lib/flog.rb
View
@@ -27,7 +27,7 @@ report. The higher the score, the more pain the code is in.
== REQUIREMENTS:
* ruby2ruby (only for -v)
-* ParseTree (soon to switch to ruby_parser)
+* ruby_parser
== INSTALL:
View
@@ -3,6 +3,14 @@
require 'ruby_parser'
require 'optparse'
+class File
+ RUBY19 = "<3".respond_to? :encoding
+
+ class << self
+ alias :binread :read unless RUBY19
+ end
+end
+
class Flog < SexpProcessor
VERSION = '2.5.3'
@@ -235,7 +243,7 @@ def flog(*files_or_dirs)
files.each do |file|
begin
# TODO: replace File.open to deal with "-"
- ruby = file == '-' ? $stdin.read : File.read(file)
+ ruby = file == '-' ? $stdin.read : File.binread(file)
warn "** flogging #{file}" if option[:verbose]
ast = @parser.process(ruby, file)
@@ -300,7 +308,7 @@ def initialize option = {}
@method_stack = []
@method_locations = {}
@mass = {}
- @parser = RubyParser.new
+ @parser = Ruby18Parser.new
self.auto_shift_type = true
self.reset
end

0 comments on commit 3644471

Please sign in to comment.