Fix method contract bug in detect_format

Calls to detect_format() passed a file, but the method expected a filename.

````
/Users/turadg/Code/Ruby/treat/lib/treat/entities/entities.rb:
    7    
    8    # Represents a document.
    9:   class Document < Entity; end
   10      
   11    # * Sections and related classes * #




/Users/turadg/Code/Ruby/treat/lib/treat/entities/entity/buildable.rb:
   47      elsif file_or_value.is_a?(Hash)
   48        from_db(file_or_value)
   49:     elsif self == Treat::Entities::Document ||
   50        (fv.index('yml') || fv.index('yaml') ||
   51        fv.index('xml') || fv.index('mongo'))
   ..
  111    def from_url(url)
  112      unless self ==
  113:       Treat::Entities::Document
  114        raise Treat::Exception,
  115        'Cannot create something ' +
  ...
  195          c.<<(c2, false) if c2
  196        else
  197:         c.<<(Treat::Entities::Document.
  198          from_file(f), false)
  199        end
  ...
  224  
  225      unless self ==
  226:       Treat::Entities::Document
  227        raise Treat::Exception,
  228        "Cannot create something else than a " +
  ...
  236      end
  237      options =  {default_format: def_fmt}
  238:     d = Treat::Entities::Document.new
  239      d.set :file, file
  240      d.read(:autoselect, options)
  ...
  250        "point to a readable file."
  251      end
  252:     doc = Treat::Entities::Document.new
  253      doc.set :file, file
  254      format = nil




/Users/turadg/Code/Ruby/treat/lib/treat/workers/extractors/similarity/tf_idf.rb:
   25      
   26      entity.each_document do |doc|
   27:       tdoc = TfIdfSimilarity::Document.new(doc.to_s)
   28        term_counts = Hash.new(0)
   29        doc.each_word do |word| 




/Users/turadg/Code/Ruby/treat/lib/treat/workers/extractors/topic_words/lda.rb:
   25        sections.each do |section|
   26          add_document(
   27:         Lda::TextDocument.new(self, section))
   28        end
   29      end




/Users/turadg/Code/Ruby/treat/lib/treat/workers/formatters/readers/abw.rb:
   22  
   23      xml_h = ABWXmlHandler.new
   24:     REXML::Document.parse_stream(
   25      IO.read(document.file), xml_h)
   26  




/Users/turadg/Code/Ruby/treat/lib/treat/workers/formatters/readers/html.rb:
   45        # Strip comments
   46        html.gsub!(/<!--[^>]*-->/m, '')
   47:       d = Readability::Document.new(html, options)
   48        document.value = "<h1>#{d.title}</h1>\n" + d.content
   49        document.set :format, 'html'




/Users/turadg/Code/Ruby/treat/lib/treat/workers/formatters/readers/odt.rb:
   29      "#{document.file}!" unless f
   30      xml_h = ODTXmlHandler.new
   31:     REXML::Document.parse_stream(f, xml_h)
   32  
   33      document.value = xml_h.plain_text




/Users/turadg/Code/Ruby/treat/lib/treat/workers/retrievers/indexers/ferret.rb:
    2  # a port of the Java Lucene search engine.
    3  # 
    4: # Documentation: 
    5  # http://rubydoc.info/gems/ferret
    6  class Treat::Workers::Retrievers::Indexers::Ferret




/Users/turadg/Code/Ruby/treat/lib/treat/workers/retrievers/searchers/ferret.rb:
    3  # search within documents of a collection.
    4  #
    5: # Documentation: 
    6  # http://rubydoc.info/gems/ferret
    7  class Treat::Workers::Retrievers::Searchers::Ferret




/Users/turadg/Code/Ruby/treat/spec/entities/collection.rb:
   42          f = Treat.paths.spec + 'workers/examples/english/economist'
   43          c = Treat::Entities::Collection.build(f)
   44:         c << Treat::Entities::Document.new
   45          c.size.should eql 4
   46        end




/Users/turadg/Code/Ruby/treat/spec/entities/document.rb:
    1  module Treat::Specs::Entities
    2:   describe Treat::Entities::Document do
    3  
    4      describe "Buildable" do
    .
   11              f = Treat.paths.spec +
   12              'workers/examples/english/mathematicians/leibniz.txt'
   13:             d = Treat::Entities::Document.build(f)
   14:             d.should be_an_instance_of Treat::Entities::Document
   15              d.to_s.index('Gottfried Leibniz').should_not eql nil
   16            end
   ..
   21            "a document with the contents of the file" do
   22              url = 'http://www.rubyinside.com/nethttp-cheat-sheet-2940.html'
   23:             d = Treat::Entities::Document.build(url)
   24              d.format.should eql 'html'
   25:             d.should be_an_instance_of Treat::Entities::Document
   26              d.to_s.index('Rubyist').should_not eql nil
   27            end
   ..
   33            "the downloaded file to be in HTML format" do
   34              url = 'http://www.economist.com/node/21552208'
   35:             d = Treat::Entities::Document.build(url)
   36:             d.should be_an_instance_of Treat::Entities::Document
   37              d.to_s.index('Ronnie Lupe').should_not eql nil
   38            end
   ..
   44            it "raises an exception" do
   45              lambda do
   46:               Treat::Entities::Document.build('nonexistent')
   47              end.should raise_error
   48            end




/Users/turadg/Code/Ruby/treat/spec/entities/entity.rb:
  360                s.serialize(ser, file: f)
  361  
  362:               d = Treat::Entities::Document.build(f)
  363  
  364                d.test_int.should eql 9




24 matches across 12 files








Searching 155 files for "detect_format" (regex, case sensitive)




/Users/turadg/Code/Ruby/treat/lib/treat/entities/entity/buildable.rb:
  214      else
  215        fmt = Treat::Workers::Formatters::
  216:       Readers::Autoselect.detect_format(file,def_fmt)
  217        from_raw_file(file, fmt)
  218      end




/Users/turadg/Code/Ruby/treat/lib/treat/workers/formatters/readers/autoselect.rb:
   13    def self.read(document, options = {})
   14      options = DefaultOptions.merge(options)
   15:     fmt = detect_format(document.file, options[:default_to])
   16      Treat::Workers::Formatters::Readers.
   17      const_get(fmt.cc).read(document,options)
   18    end
   19    
   20:   def self.detect_format(filename, default_to = nil)
   21      
   22      default_to ||= DefaultOptions[:default_to]




3 matches across 2 files








Searching 155 files for "detect_format" (regex, case sensitive)




/Users/turadg/Code/Ruby/treat/lib/treat/entities/entity/buildable.rb:
  214      else
  215        fmt = Treat::Workers::Formatters::
  216:       Readers::Autoselect.detect_format(file,def_fmt)
  217        from_raw_file(file, fmt)
  218      end




/Users/turadg/Code/Ruby/treat/lib/treat/workers/formatters/readers/autoselect.rb:
   13    def self.read(document, options = {})
   14      options = DefaultOptions.merge(options)
   15:     fmt = detect_format(document.file, options[:default_to])
   16      Treat::Workers::Formatters::Readers.
   17      const_get(fmt.cc).read(document,options)
   18    end
   19    
   20:   def self.detect_format(filename, default_to = nil)
   21      
   22      default_to ||= DefaultOptions[:default_to]




3 matches across 2 files








Searching 155 files for "detect_format" (regex, case sensitive)




/Users/turadg/Code/Ruby/treat/lib/treat/entities/entity/buildable.rb:
  214      else
  215        fmt = Treat::Workers::Formatters::
  216:       Readers::Autoselect.detect_format(file,def_fmt)
  217        from_raw_file(file, fmt)
  218      end




/Users/turadg/Code/Ruby/treat/lib/treat/workers/formatters/readers/autoselect.rb:
   13    def self.read(document, options = {})
   14      options = DefaultOptions.merge(options)
   15:     fmt = detect_format(document.file, options[:default_to])
   16      Treat::Workers::Formatters::Readers.
   17      const_get(fmt.cc).read(document,options)
   18    end
   19    
   20:   def self.detect_format(filename, default_to = nil)
   21      
   22      default_to ||= DefaultOptions[:default_to]




3 matches across 2 files
````
This patch changes the parameter to a file as expected.