lib/flay.rb in flay-2.3.1 vs lib/flay.rb in flay-2.4.0

- old
+ new

@@ -13,11 +13,11 @@ alias :binread :read unless RUBY19 end end class Flay - VERSION = "2.3.1" # :nodoc: + VERSION = "2.4.0" # :nodoc: ## # Returns the default options. def self.default_options @@ -163,12 +163,10 @@ self.identical = {} self.masses = {} self.total = 0 self.mass_threshold = @option[:mass] - - require 'ruby2ruby' if @option[:diff] end ## # Process any number of files. @@ -486,13 +484,26 @@ end end if option[:diff] then puts - r2r = Ruby2Ruby.new - puts n_way_diff(*nodes.map { |s| r2r.process(s.deep_clone) }) + sources = nodes.map do |s| + msg = "sexp_to_#{File.extname(s.file).sub(/./, '')}" + self.respond_to?(msg) ? self.send(msg, s) : sexp_to_rb(s) + end + puts n_way_diff(*sources) end end + end + + def sexp_to_rb sexp + begin + require 'ruby2ruby' + rescue LoadError + return 'ruby2ruby is required for diff' + end + @r2r ||= Ruby2Ruby.new + @r2r.process sexp.deep_clone end end class String attr_accessor :group # :nodoc: