Scout Client Updates

by Charles Brian Quinn

This guide highlights the differences between Scout clients, illustrates new features, and more.

While we encourage you to always run the latest client, all plugins should be backwards compatible. To see what version of the client you have, you can use:

$ sudo gem list scout

From Scout 1.x to Scout 2.x

Introducing build_report() and friendly report, alert, and error helpers

In version 1.x of the Scout client, plugins used a run() method to return a `Hash` of the reports, alerts, and errors.

# VERSION 1.x syntax
class TypicalReports < Scout::Plugin
  def run
    begin
      if Date.today == Date.parse("Dec 25 2008")
        { :report => { :holiday => "Christmas" } }
      elsif Date.today == Date.parse("Oct 31 2008")
        { :report => { :holiday => "Halloween" },
          :alert =>  {:subject => "Trick or Treat!"} }
      else
        { }
      end
    rescue
      { :error => {
          :subject => "Could not run the plugin",
          :body    => "Please check the code and try again."
        } }
    end
  end
end

Things are cleaner in version 2.x of the Scout client. Use the build_report() method, and instead of worrying about the return value being a `Hash`, just build up your reports, alerts, and errors. Scout sends them for you.

# VERSION 2.x syntax
class TypicalReports < Scout::Plugin
  def build_report
    begin
      if Date.today == Date.parse("Dec 25 2008")
        report(:holiday => "Christmas")
      elsif Date.today == Date.parse("Oct 31 2008")
        report(:holiday => "Halloween")
        alert(:subject => "Trick or Treat!")
      end
    rescue
      error(:subject => "Could not run the plugin",
            :body    => "Please check the code and try again.")
    end
  end
end

Note, also the use of the helper methods for setting reports, alerts, and errors.

Easier access to memory and options

The new Scout 2.x client has easier helper methods for dealing with the memory and options (Memory is data stored locally on the client between runs. Options are settings passed to the plugin when executing).

In the 1.x version, we used the @memory instance variable:

# Scout 1.x Memory and Options

# access the `disk_space_usage` data currently in the memory:
@memory[:disk_space_usage]

# put the `disk_space_usage` data in the memory for next run:
report[:memory] = {:disk_space_usage = true}

# clear the `disk_space_usage` data from the memory for next run:
report[:memory] = {:disk_space_usage = nil}

# retrieve an option:
@options("applescript_executable")

Now, we use the remember() and memory() helpers to set and retrieve the memory:

# Scout 2.x Memory and Options

# access the `disk_space_usage` data currently in the memory:
memory(:disk_space_usage)

# remember the `disk_space_usage` data in the memory for next run:
remember(:disk_space_usage => 42)

# delete the `disk_space_usage` data from the memory for next run:
memory.delete(:disk_space_usage)

# clear the entire memory:
memory.clear

# retrieve an option:
option(:applescript_executable)

We hope you find these new features easy to use. Have a suggestion, or a plugin development question? Checkout the Scout Forums. We monitor the forums actively during business hours. General Scout Q&A is answered in our Help Area. We also welcome your questions and feedback at support@highgroove.com.

Back to Top
Already have a Scout account?   Where do I login? Highgroove Studios Powered By Rails Machine