lib/spreadsheet_agent/runner.rb
def process!(&runner_code)
      get_runnable_entries().each do |entry_info|
        entry_page, runnable_entry = entry_info
        if runner_code.nil?
          default_process(runnable_entry)
        elsif @dry_run
          $stderr.print "Would run #{ entry_page.title } #{ runnable_entry.inspect }"
        else
          runner_code.call(runnable_entry, entry_page)
        end
        sleep @sleep_between
      end
    end
def process!(&runner_code)
      get_runnable_entries().each do |entry_info|
        entry_page, runnable_entry = entry_info
        if runner_code.nil?
          default_process(runnable_entry)
        elsif @dry_run
          $stderr.print "Would run #{ entry_page.title } #{ runnable_entry.inspect }"
        else
          runner_code.call(runnable_entry, entry_page)
        end
        sleep @sleep_between
      end
    end
def process! ( & runner_code ) get_runnable_entries ( ) . each do | entry_info | entry_page , runnable_entry = entry_info if runner_code . nil? default_process ( runnable_entry ) elsif @dry_run $stderr . print "Would run #{ entry_page.title } #{ runnable_entry.inspect }" else runner_code . call ( runnable_entry , entry_page ) end sleep @sleep_between end end
Processes configured pages, entries, and goals with a PROC.  The default PROC takes the entry, iterates
 over each goal not skipped by skip_goal, and:
 * determines if an executable #{ @agent_bin }/#{ goal }_agent.rb script exists
 * if so, executes the goal_agent script with commandline arguments constructed from the values in the entry for each field in the query_fields array defined in config.
 If run_in_serial is false, the default PROC runs each agent in the background, in parallel.
 Otherwise, it runs each serially in the foreground.  If dry_run is true, the command is printed to STDERR,
 but is not run.
 A PROC supplied to override the default PROC should take an GoogleDrive::List, and GoogleDrive::Worksheet as arguments.
 This allows the process to query the entry for information using its hash access, and/or update the entry on the
 spreadsheet. In order for changes to the GoogleDrive::List to take effect, the GoogleDrive::Worksheet must be saved in the PROC.
 The process sleeps @sleep_between between each call to the PROC (default or otherwise).  If dry_run is true
 when a PROC is supplied, the page.title and runnable_entry hash inspection are printed to STDERR but the PROC
 is not called.

   # call each goal agent script in agent_bin on each entry in each page
   runner = SpreadsheetAgent::Runer.new
   runner.process!

   # find entries with a threshold > 5 and update the 'threshold_exceeded' field
   runner.skip_entry{|entry| entry['threshold'] <= 5 }.process! do |entry,page|
     entry.update 'threshold_exceeded', "1"
     page.save

  # only process entries on the 'main' page where the threshold has not been exceeded
  runner.only_pages = ['main']
  runner.skip_entry{|entry| entry['threshold'] != 1 }.process!
Processes configured pages entries and goals with a PROC . The default PROC takes the entry iterates over each goal not skipped by skip_goal and : * determines if an executable # { @agent_bin } / # { goal } _agent . rb script exists * if so executes the goal_agent script with commandline arguments constructed from the values in the entry for each field in the query_fields array defined in config . If run_in_serial is false the default PROC runs each agent in the background in parallel . Otherwise it runs each serially in the foreground . If dry_run is true the command is printed to STDERR but is not run . A PROC supplied to override the default PROC should take an GoogleDrive :: List and GoogleDrive :: Worksheet as arguments . This allows the process to query the entry for information using its hash access and / or update the entry on the spreadsheet . In order for changes to the GoogleDrive :: List to take effect the GoogleDrive :: Worksheet must be saved in the PROC . The process sleeps @sleep_between between each call to the PROC ( default or otherwise ) . If dry_run is true when a PROC is supplied the page . title and runnable_entry hash inspection are printed to STDERR but the PROC is not called .