lib/flay.rb in flay-1.4.3 vs lib/flay.rb in flay-2.0.0.b1

- old
+ new

@@ -3,12 +3,20 @@ require 'optparse' require 'rubygems' require 'sexp_processor' require 'ruby_parser' +class File + RUBY19 = "<3".respond_to? :encoding + + class << self + alias :binread :read unless RUBY19 + end +end + class Flay - VERSION = '1.4.3' + VERSION = '2.0.0.b1' def self.default_options { :diff => false, :mass => 16, @@ -160,11 +168,11 @@ self.total += masses[hash] end end def process_rb file - RubyParser.new.process(File.read(file), file) + RubyParser.new.process(File.binread(file), file) end def process_sexp pt pt.deep_each do |node| next unless node.any? { |sub| Sexp === sub } @@ -300,24 +308,7 @@ hashes = [] self.deep_each do |node| hashes << node.structural_hash end hashes - end - - # REFACTOR: move to sexp.rb - def deep_each(&block) - self.each_sexp do |sexp| - block[sexp] - sexp.deep_each(&block) - end - end - - # REFACTOR: move to sexp.rb - def each_sexp - self.each do |sexp| - next unless Sexp === sexp - - yield sexp - end end end