Changeset 167

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

Every config constant is now written in Picolena module

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/oo_indexer/lib/picolena/config/basic.rb

    r148 r167  
     1module Picolena 
    12# Specify indexes path. 
    23# Storage should be sufficient in order to store all indexed data. 
     
    3536Ferret::Search::FuzzyQuery.default_min_similarity=0.6 
    3637Analyzer=Ferret::Analysis::StandardAnalyzer.new 
     38end 
  • branches/oo_indexer/lib/picolena/templates/app/controllers/application.rb

    r145 r167  
    2424  # Redirects to :access_denied if the remote IP is not white listed. 
    2525  def should_only_be_available_for_white_list_IPs 
    26     unless request.remote_ip =~ WhiteListIPs 
     26    unless request.remote_ip =~ Picolena::WhiteListIPs 
    2727      redirect_to :controller => 'application', :action=>'access_denied' 
    2828      return false 
  • branches/oo_indexer/lib/picolena/templates/app/controllers/documents_controller.rb

    r145 r167  
    2525      finder=Finder.new(@query,page) 
    2626      finder.execute! 
    27       pager=::Paginator.new(finder.total_hits, ResultsPerPage) do 
     27      pager=::Paginator.new(finder.total_hits, Picolena::ResultsPerPage) do 
    2828        finder.matching_documents 
    2929      end 
  • branches/oo_indexer/lib/picolena/templates/app/models/document.rb

    r153 r167  
    3939  def alias_path 
    4040    original_dir=indexed_directory 
    41     alias_dir=IndexedDirectories[original_dir] 
     41    alias_dir=Picolena::IndexedDirectories[original_dir] 
    4242    dirname.sub(original_dir,alias_dir) 
    4343  end 
     
    101101   
    102102  def indexed_directory 
    103     IndexedDirectories.keys.find{|indexed_dir| 
     103    Picolena::IndexedDirectories.keys.find{|indexed_dir| 
    104104      dirname.starts_with?(indexed_dir) 
    105105    }     
  • branches/oo_indexer/lib/picolena/templates/app/models/finder.rb

    r154 r167  
    88  end 
    99   
    10   def initialize(raw_query,page=1,results_per_page=ResultsPerPage) 
     10  def initialize(raw_query,page=1,results_per_page=Picolena::ResultsPerPage) 
    1111    @query = Query.extract_from(raw_query) 
    1212    @raw_query= raw_query 
  • branches/oo_indexer/lib/picolena/templates/app/models/index_reader.rb

    r154 r167  
    44    # puts "##################################################################Creating Reader!!!!!" 
    55    # Add needed parameters 
    6     params.merge!(:path => IndexSavePath, :analyzer => Analyzer) 
     6    params.merge!(:path => Picolena::IndexSavePath, :analyzer => Picolena::Analyzer) 
    77    # Creates the IndexReader 
    88    super(params) 
     
    5151  
    5252  def filename 
    53     Dir.glob(File.join(IndexSavePath,'*.cfs')).first 
     53    Dir.glob(File.join(Picolena::IndexSavePath,'*.cfs')).first 
    5454  end 
    5555  end 
  • branches/oo_indexer/lib/picolena/templates/app/models/index_writer.rb

    r154 r167  
    66    # Add needed parameters 
    77    params.merge!(:create_if_missing => true, 
    8                   :path              => IndexSavePath, 
    9                   :analyzer          => Analyzer 
     8                  :path              => Picolena::IndexSavePath, 
     9                  :analyzer          => Picolena::Analyzer 
    1010                  # huge performance impact? 
    1111                  # :auto_flush        => true 
     
    1818   
    1919  def self.remove 
    20     Dir.glob(File.join(IndexSavePath,'*')).each{|f| FileUtils.rm(f) if File.file?(f)} 
     20    Dir.glob(File.join(Picolena::IndexSavePath,'*')).each{|f| FileUtils.rm(f) if File.file?(f)} 
    2121  end 
    2222   
  • branches/oo_indexer/lib/picolena/templates/app/models/indexer.rb

    r163 r167  
    2525      reset! unless update 
    2626       
    27       IndexedDirectories.each{|dir, alias_dir| 
     27      Picolena::IndexedDirectories.each{|dir, alias_dir| 
    2828        index_directory_with_multithreads(dir) 
    2929      } 
  • branches/oo_indexer/lib/picolena/templates/app/models/query.rb

    r152 r167  
    2626    # Instantiates a QueryParser once, and keeps it in cache. 
    2727    def parser 
    28       @@parser ||= Ferret::QueryParser.new(:fields => [:content, :file, :basename, :filetype, :date], :or_default => false, :analyzer=>Analyzer)       
     28      @@parser ||= Ferret::QueryParser.new(:fields => [:content, :file, :basename, :filetype, :date], :or_default => false, :analyzer=>Picolena::Analyzer) 
    2929    end 
    3030  end 
  • branches/oo_indexer/lib/picolena/templates/config/initializers/002_load_indexed_dirs.rb

    r141 r167  
     1module Picolena 
    12#Loading directories to be indexed 
    23indexed_dir_config_file='config/custom/indexed_directories.yml' 
     
    78 
    89IndexSavePath=File.join(IndexesSavePath,ENV["RAILS_ENV"] || "development") 
     10end 
  • branches/oo_indexer/lib/picolena/templates/config/initializers/003_load_white_list_IPs.rb

    r141 r167  
     1module Picolena 
    12#Deny all, Allow only IPs described in config/custom/white_list_ip.yml 
    23white_list_ip_config_file='config/custom/white_list_ip.yml' 
     
    78      }.join("|")<<")" 
    89  ) rescue /^(127\.0\.0\.1|0\.0\.0\.0)/ 
     10end 
  • branches/oo_indexer/lib/picolena/templates/config/initializers/005_load_custom_title_and_names_and_links.rb

    r138 r167  
     1module Picolena 
    12custom_localization_yml=File.join(RAILS_ROOT,'config/custom/title_and_names_and_links.yml') 
    23 
     
    45  Globalite.localizations[key_name.to_sym]=custom_translation unless custom_translation.blank? 
    56} 
     7end 
  • branches/oo_indexer/lib/picolena/templates/lib/core_exts.rb

    r162 r167  
    1818class String 
    1919  # Creates a "probably unique" id with the desired length, composed only of lowercase letters. 
    20   def base26_hash(length=HashLength) 
     20  def base26_hash(length=Picolena::HashLength) 
    2121    Digest::MD5.hexdigest(self).to_i(16).to_s(26).tr('0-9a-p', 'a-z')[-length,length] 
    2222  end 
  • branches/oo_indexer/lib/picolena/templates/spec/controllers/documents_controller_spec.rb

    r142 r167  
    55   
    66  before(:all) do 
    7     @backup=WhiteListIPs 
     7    @backup=Picolena::WhiteListIPs 
    88  end 
    99   
    1010  it "should deny access" do 
    1111    # Displays a warning otherwise 
    12     Object.send(:remove_const, :WhiteListIPs) && WhiteListIPs=/Something that won't match/ 
     12    Picolena.send(:remove_const, :WhiteListIPs) && Picolena::WhiteListIPs=/Something that won't match/ 
    1313    get 'index' 
    1414    response.should be_redirect 
    1515    response.should redirect_to(:controller=>'application', :action=>'access_denied') 
    16     Object.send(:remove_const, :WhiteListIPs) && WhiteListIPs=/^0\.0\.0\.0/ 
     16    Picolena.send(:remove_const, :WhiteListIPs) && Picolena::WhiteListIPs=/^0\.0\.0\.0/ 
    1717    get 'index' 
    1818    response.should be_success 
     
    2020 
    2121  after(:all) do 
    22     Object.send(:remove_const, :WhiteListIPs) && WhiteListIPs=@backup 
     22    Picolena.send(:remove_const, :WhiteListIPs) && Picolena::WhiteListIPs=@backup 
    2323  end 
    2424end 
  • branches/oo_indexer/lib/picolena/templates/spec/models/basic_finder_spec.rb

    r153 r167  
    44describe "Finder without index on disk" do 
    55  before(:all) do 
    6     @original_index_path=IndexSavePath.dup 
    7     @original_indexed_dirs=IndexedDirectories.dup 
     6    @original_index_path=Picolena::IndexSavePath.dup 
     7    @original_indexed_dirs=Picolena::IndexedDirectories.dup 
    88    @new_index_path=File.join(Dir::tmpdir,'ferret_tst') 
    9     IndexSavePath.replace(@new_index_path) 
     9    Picolena::IndexSavePath.replace(@new_index_path) 
    1010  end 
    1111   
     
    1515   
    1616  it "should create index" do 
    17     IndexedDirectories.replace({'spec/test_dirs/indexed/just_one_doc'=>'//justonedoc/'}) 
     17    Picolena::IndexedDirectories.replace({'spec/test_dirs/indexed/just_one_doc'=>'//justonedoc/'}) 
    1818    lambda {@finder_with_new_index=Finder.new("test moi")}.should change(IndexReader, :exists?).from(false).to(true) 
    1919    File.exists?(File.join(@new_index_path,'_0.cfs')).should be_true 
     
    2222   
    2323  it "should raise if index is still empty after trying to create it" do 
    24     IndexedDirectories.replace({'spec/test_dirs/empty_folder'=>'//empty_folder/'}) 
     24    Picolena::IndexedDirectories.replace({'spec/test_dirs/empty_folder'=>'//empty_folder/'}) 
    2525    lambda {Finder.new("doesn't matter anyway")}.should raise_error(IndexError, "no document found") 
    2626    File.exists?(File.join(@new_index_path,'_0.cfs')).should be_false 
     
    2828   
    2929  after(:all) do 
    30     IndexedDirectories.replace(@original_indexed_dirs) 
    31     IndexSavePath.replace(@original_index_path) 
     30    Picolena::IndexedDirectories.replace(@original_indexed_dirs) 
     31    Picolena::IndexSavePath.replace(@original_index_path) 
    3232  end 
    3333end 
  • branches/oo_indexer/lib/picolena/templates/spec/models/host_indexing_system_spec.rb

    r136 r167  
    2525   
    2626  it "should not use too small a hash for Document#probably_unique_id" do 
    27     HashLength.should_not < 10 
     27    Picolena::HashLength.should_not < 10 
    2828  end 
    2929end 
  • branches/oo_indexer/lib/picolena/templates/spec/models/index_directories_spec.rb

    r81 r167  
    33describe "IndexedDirectories" do 
    44  it "should be defined" do 
    5     lambda {IndexedDirectories}.should_not raise_error(NameError) 
     5    lambda {Picolena::IndexedDirectories}.should_not raise_error(NameError) 
    66  end 
    77   
    88  it "should not be empty" do 
    9     IndexedDirectories.should_not be_empty 
     9    Picolena::IndexedDirectories.should_not be_empty 
    1010  end 
    1111   
    1212  it "should only contain existing directories" do 
    13     IndexedDirectories.keys.all?{|dir| 
     13    Picolena::IndexedDirectories.keys.all?{|dir| 
    1414      File.should be_directory(dir) 
    1515    }