Changeset 225

Show
Ignore:
Timestamp:
04/23/08 06:35:51 (7 months ago)
Author:
eric.dumin..@gmail.com
Message:

Singleton fake DRB Server

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/fake_drb_server/Manifest.txt

    r190 r225  
    2222lib/picolena/templates/app/helpers/documents_helper.rb 
    2323lib/picolena/templates/app/models/document.rb 
     24lib/picolena/templates/app/models/fake_drb_server.rb 
    2425lib/picolena/templates/app/models/finder.rb 
    2526lib/picolena/templates/app/models/index_reader.rb 
     
    4546lib/picolena/templates/config/initializers/005_load_custom_title_and_names_and_links.rb 
    4647lib/picolena/templates/config/initializers/006_load_icons.rb 
     48lib/picolena/templates/config/initializers/007_load_drb_server.rb 
    4749lib/picolena/templates/config/routes.rb 
    4850lib/picolena/templates/lang/ui/de.yml 
     
    118120lib/picolena/templates/spec/models/basic_finder_spec.rb 
    119121lib/picolena/templates/spec/models/document_spec.rb 
     122lib/picolena/templates/spec/models/fake_drb_server_spec.rb 
    120123lib/picolena/templates/spec/models/finder_spec.rb 
    121124lib/picolena/templates/spec/models/host_indexing_system_spec.rb 
  • branches/fake_drb_server/lib/picolena/templates/app/models/fake_drb_server.rb

    r224 r225  
     1# Multi-threaded indexing can be brittle with Ferret. 
     2# To prevent lock errors or read/write on closed index, 
     3# FakeDRBServer is used as a centralized supervisor for 
     4# Index reading and writing. 
     5require 'singleton' 
    16class FakeDRBServer 
     7  include Singleton 
     8   
     9  cattr_reader :todo_list 
     10  @@todo_list=[] 
     11   
     12  def add_to_index(filename) 
     13    FakeDRBServer.todo_list<<{:to_index=>filename} 
     14  end 
    215end 
  • branches/fake_drb_server/lib/picolena/templates/config/initializers/002_load_indexed_dirs.rb

    r167 r225  
    11module Picolena 
    2 #Loading directories to be indexed 
    3 indexed_dir_config_file='config/custom/indexed_directories.yml' 
    4 IndexedDirectories={} 
    5 YAML.load_file(indexed_dir_config_file)[RAILS_ENV].each_pair{|abs_or_rel_path, alias_path| 
    6   IndexedDirectories[Pathname(abs_or_rel_path).realpath.to_s]=alias_path 
    7 
    8  
    9 IndexSavePath=File.join(IndexesSavePath,ENV["RAILS_ENV"] || "development") 
     2  #Loading directories to be indexed 
     3  indexed_dir_config_file='config/custom/indexed_directories.yml' 
     4  IndexedDirectories={} 
     5  YAML.load_file(indexed_dir_config_file)[RAILS_ENV].each_pair{|abs_or_rel_path, alias_path| 
     6    IndexedDirectories[Pathname(abs_or_rel_path).realpath.to_s]=alias_path 
     7 
     8   
     9  IndexSavePath=File.join(IndexesSavePath,ENV["RAILS_ENV"] || "development") 
    1010end 
  • branches/fake_drb_server/lib/picolena/templates/config/initializers/003_load_white_list_IPs.rb

    r167 r225  
    11module Picolena 
    2 #Deny all, Allow only IPs described in config/custom/white_list_ip.yml 
    3 white_list_ip_config_file='config/custom/white_list_ip.yml' 
    4 WhiteListIPs=Regexp.new( 
    5     "^("<< 
    6       YAML.load_file(white_list_ip_config_file)["Allow"].collect{|ip| 
    7         ip.downcase.include?("all") ? /.*/ : Regexp.escape(ip) 
    8       }.join("|")<<")" 
    9   ) rescue /^(127\.0\.0\.1|0\.0\.0\.0)/ 
     2  #Deny all, Allow only IPs described in config/custom/white_list_ip.yml 
     3  white_list_ip_config_file='config/custom/white_list_ip.yml' 
     4  WhiteListIPs=Regexp.new( 
     5      "^("<< 
     6        YAML.load_file(white_list_ip_config_file)["Allow"].collect{|ip| 
     7          ip.downcase.include?("all") ? /.*/ : Regexp.escape(ip) 
     8        }.join("|")<<")" 
     9    ) rescue /^(127\.0\.0\.1|0\.0\.0\.0)/ 
    1010end 
  • branches/fake_drb_server/lib/picolena/templates/config/initializers/005_load_custom_title_and_names_and_links.rb

    r167 r225  
    11module Picolena 
    2 custom_localization_yml=File.join(RAILS_ROOT,'config/custom/title_and_names_and_links.yml') 
    3  
    4 YAML.load_file(custom_localization_yml).each{|key_name, custom_translation| 
    5   Globalite.localizations[key_name.to_sym]=custom_translation unless custom_translation.blank? 
    6 
     2  custom_localization_yml=File.join(RAILS_ROOT,'config/custom/title_and_names_and_links.yml') 
     3   
     4  YAML.load_file(custom_localization_yml).each{|key_name, custom_translation| 
     5    Globalite.localizations[key_name.to_sym]=custom_translation unless custom_translation.blank? 
     6 
    77end 
  • branches/fake_drb_server/lib/picolena/templates/spec/models/fake_drb_server_spec.rb

    r224 r225  
    22 
    33describe FakeDRBServer do 
    4   before(:each) do 
    5     @fake_drb_server = FakeDRBServer.new 
    6   end 
    7  
    8   it "should be valid" do 
    9     @fake_drb_server.should be_valid 
     4  it "should be unique" do 
     5    one_and_only = FakeDRBServer.instance 
     6    lambda {FakeDRBServer.new}.should raise_error(NoMethodError, "private method `new' called for FakeDRBServer:Class") 
     7    one_and_only.object_id.should == FakeDRBServer.instance.object_id 
     8    one_and_only.should == Picolena::DRBServer 
    109  end 
    1110end