Changeset 18 for lib

Show
Ignore:
Timestamp:
07/09/06 10:31:59 (3 years ago)
Author:
sandal
Message:

minor cleanup + RAA.fetch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/www/raa.rb

    r14 r18  
    1717    # 
    1818    def search(project) 
    19       entries = [] 
    20       mech = WWW::Mechanize.new 
     19      entries = [] ; mech = WWW::Mechanize.new 
    2120      mech.get(HOME_PAGE + "/search.rhtml?search=#{project}") 
    2221      mech.page.links.each{ |link| 
    23          if link.href =~ /^project\/(.*?)\/$/ 
    24             entries.push(RAA::Entry.new($1)) 
    25          end 
    26       } 
    27       entries 
     22        entries << fetch($1) if link.href =~ /^project\/(.*?)\/$/  
     23      } ; entries 
    2824    end 
     25 
     26    def fetch(project); Entry.new(project) end 
    2927 
    3028    module_function :update_entry 
    3129    module_function :search 
    32        
     30    module_function :fetch   
     31 
    3332    # The Entry class represents a project entry on the RAA. 
    3433    # 
     
    7069      end 
    7170 
     71      # Forwards missing method calls to WWW::Mechanize::Form, to allow direct 
     72      # access to fields 
     73      # 
     74      # E.g. 
     75      # 
     76      # my_obj.some_field 
     77      # 
     78      #   and 
     79      # 
     80      # my_obj.some_field = 'my_values' 
     81      # 
    7282      def method_missing(id,*args) 
    73         id = id.to_s.gsub(/=$/, '') 
    74         if @form.field(id) 
    75           return @form.field(id).value if args.empty? 
    76           return @form.field(id).value = args[0] 
    77         end 
    78         super 
     83        id = id.to_s.gsub(/=$/,"") 
     84        return super unless @form.field(id) 
     85        args.empty? ? @form.field(id).value : @form.field(id).value = args[0] 
    7986      end 
    8087    end