<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,5 +3,9 @@
 require 'flay'
 
 flay = Flay.new Flay.parse_options
-flay.process(*Flay.expand_dirs_to_files)
+
+ARGV &lt;&lt; '.' if ARGV.empty?
+files = Flay.expand_dirs_to_files(*ARGV)
+
+flay.process(*files)
 flay.report</diff>
      <filename>bin/flay</filename>
    </modified>
    <modified>
      <diff>@@ -13,12 +13,16 @@ abort &quot;update rubygems to &gt;= 1.3.1&quot; unless  Gem.respond_to? :find_files
 class Flay
   VERSION = '1.1.0'
 
-  def self.parse_options
-    options = {
+  def self.default_options
+    {
       :fuzzy   =&gt; false,
       :verbose =&gt; false,
       :mass    =&gt; 16,
     }
+  end
+
+  def self.parse_options
+    options = self.default_options
 
     OptionParser.new do |opts|
       opts.banner  = 'flay [options] files_or_dirs'
@@ -54,10 +58,10 @@ class Flay
     options
   end
 
-  def self.expand_dirs_to_files
+  def self.expand_dirs_to_files *dirs
     extensions = ['rb'] + Flay.load_plugins
 
-    ARGV.map { |p|
+    dirs.flatten.map { |p|
       if File.directory? p then
         Dir[File.join(p, '**', &quot;*.{#{extensions.join(',')}}&quot;)]
       else
@@ -80,14 +84,19 @@ class Flay
     plugins.map { |f| File.basename(f, '.rb').sub(/^flay_/, '') }
   end
 
-  attr_accessor :mass_threshold
+  attr_accessor :mass_threshold, :total, :identical, :masses
   attr_reader :hashes, :option
 
-  def initialize option = {}
-    @option = option
+  def initialize option = nil
+    @option = option || Flay.default_options
     @hashes = Hash.new { |h,k| h[k] = [] }
-    self.mass_threshold = option[:mass]
-    require 'ruby2ruby' if option[:verbose]
+
+    self.identical      = {}
+    self.masses         = {}
+    self.total          = 0
+    self.mass_threshold = @option[:mass]
+
+    require 'ruby2ruby' if @option[:verbose]
   end
 
   def process(*files)
@@ -117,6 +126,15 @@ class Flay
     end
 
     process_fuzzy_similarities if option[:fuzzy]
+
+    self.prune
+
+    self.hashes.each do |hash,nodes|
+      identical[hash] = nodes[1..-1].all? { |n| n == nodes.first }
+      masses[hash] = nodes.first.mass * nodes.size
+      masses[hash] *= (nodes.size) if identical[hash]
+      self.total += masses[hash]
+    end
   end
 
   def process_rb file
@@ -218,19 +236,11 @@ class Flay
   end
 
   def report prune = nil
-    self.prune
-
-    identical = {}
-    masses = {}
-
-    self.hashes.each do |hash,nodes|
-      identical[hash] = nodes[1..-1].all? { |n| n == nodes.first }
-      masses[hash] = nodes.first.mass * nodes.size
-      masses[hash] *= (nodes.size) if identical[hash]
-    end
+    puts &quot;Total score (lower is better) = #{self.total}&quot;
+    puts
 
     count = 0
-    masses.sort_by { |h,m| [-m, hashes[h].first.file] }.each do |hash,mass|
+    masses.sort_by { |h,m| [-m, hashes[h].first.file] }.each do |hash, mass|
       nodes = hashes[hash]
       next unless nodes.first.first == prune if prune
       puts</diff>
      <filename>lib/flay.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c11e05a532b228c6125ac896b888f3a5dee6a5fe</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Davis</name>
    <email>ryand@zenspider.com</email>
  </author>
  <url>http://github.com/seattlerb/flay/commit/c920188dce94b48a6f009bd364f0cc1a7b15496e</url>
  <id>c920188dce94b48a6f009bd364f0cc1a7b15496e</id>
  <committed-date>2009-03-09T16:47:13-07:00</committed-date>
  <authored-date>2009-03-09T16:47:13-07:00</authored-date>
  <message>+ Refactored to make using w/in rake and other CI systems clean and easy.
[git-p4: depot-paths = &quot;//src/flay/dev/&quot;: change = 4714]</message>
  <tree>7681b222ce8993604ac394a559d4af9796207f26</tree>
  <committer>
    <name>Ryan Davis</name>
    <email>ryand@zenspider.com</email>
  </committer>
</commit>
