Changeset 312

Show
Ignore:
Timestamp:
05/05/08 03:19:12 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

Binary documents without extension are not considered supported anymore

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/picolena/templates/app/models/document.rb

    r305 r312  
    1212 
    1313  #Delegating properties to File::method_name(complete_path) 
    14   [:dirname, :basename, :extname, :ext_as_sym, :file?, :size, :ext_as_sym].each{|method_name| 
     14  [:dirname, :basename, :extname, :ext_as_sym, :file?, :plain_text?, :size, :ext_as_sym].each{|method_name| 
    1515    define_method(method_name){File.send(method_name,complete_path)} 
    1616  } 
     
    5959  #  Document.new("presentation.some_weird_extension").supported? => false 
    6060  def supported? 
    61     PlainTextExtractor.supported_extensions.include?(self.ext_as_sym) 
     61    PlainTextExtractor.supported_extensions.include?(self.ext_as_sym) unless ext_as_sym==:no_extension and !plain_text? 
    6262  end 
    6363 
  • trunk/lib/picolena/templates/lib/plain_text_extractors/plain_text.rb

    r311 r312  
    1212      end 
    1313    else 
    14       "binary file!" 
     14      nil 
    1515    end 
    1616  } 
  • trunk/lib/picolena/templates/spec/models/document_spec.rb

    r301 r312  
    7979    Document.new("spec/test_dirs/indexed/others/ghjopdfg.xyz").should_not be_supported 
    8080  end 
     81 
     82  it "should not be considered supported if binary" do 
     83    Document.new("spec/test_dirs/indexed/others/BIN_FILE_WITHOUT_EXTENSION").should_not be_supported 
     84  end 
     85 
     86 
    8187   
    8288  it "should know its language when enough content is available" do 
  • trunk/lib/picolena/templates/spec/models/plain_text_extractor_spec.rb

    r310 r312  
    3030 
    3131  it "should not extract content of binary files" do 
    32     PlainTextExtractor.extract_content_from("spec/test_dirs/indexed/others/BIN_FILE_WITHOUT_EXTENSION").should == "binary file!" 
     32    PlainTextExtractor.extract_content_from("spec/test_dirs/indexed/others/BIN_FILE_WITHOUT_EXTENSION").should be_blank 
    3333  end 
    3434end