scout 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ == 2.0.6
2
+
3
+ * Adding plugin dependency support via the new needs() class method
4
+ * Improved Scout error backtraces (patch from dougbarth)
5
+
1
6
  == 2.0.5
2
7
 
3
8
  * Another Version bump to update gem servers
data/Rakefile CHANGED
@@ -86,10 +86,12 @@ task :publish_scout => [:package] do
86
86
  puts "Publishing on Scout Server"
87
87
  sh "scp -r pkg/*.gem " +
88
88
  "deploy@gems.scoutapp.com:/var/www/gems/gems"
89
- ssh = Net::SSH.start('gems.scoutapp.com','deploy')
90
- ssh_shell = ssh.shell.sync
91
- ssh_out = ssh_shell.send_command "/usr/bin/gem generate_index -d /var/www/gems"
92
- puts "Published, and updated gem server." if ssh_out.stdout.empty? && !ssh_out.stderr
89
+ ssh_out = ""
90
+ Net::SSH.start('gems.scoutapp.com','deploy') do |session|
91
+ ssh_out = session.exec!("/usr/bin/gem generate_index -d /var/www/gems").to_s.chomp
92
+ end
93
+ puts ssh_out
94
+ puts "Published, and updated gem server."
93
95
  end
94
96
 
95
97
  desc "Publishes Gem to Rubyforge"
@@ -141,17 +143,18 @@ task :publish_beta_scout => [:package] do
141
143
  puts "Publishing on Scout Server"
142
144
  sh "scp -r pkg/*.gem " +
143
145
  "deploy@gems.scoutapp.com:/var/www/beta-gems/gems"
144
- ssh = Net::SSH.start('gems.scoutapp.com','deploy')
145
- ssh_shell = ssh.shell.sync
146
- ssh_out = ssh_shell.send_command "/usr/bin/gem generate_index -d /var/www/beta-gems"
147
- puts "Published, and updated gem server." if ssh_out.stdout.empty? && !ssh_out.stderr
146
+ ssh_out = ""
147
+ Net::SSH.start('gems.scoutapp.com','deploy') do |session|
148
+ ssh_out = session.exec!("/usr/bin/gem generate_index -d /var/www/gems").to_s.chomp
149
+ end
150
+ puts ssh_out
151
+ puts "Published, and updated gem server."
148
152
 
149
153
  sh "scp -r doc/html/* " +
150
154
  "deploy@gems.scoutapp.com:/var/www/beta-gems/docs"
151
155
 
152
156
  end
153
157
 
154
-
155
158
  desc "Add new files to Subersion"
156
159
  task :svn_add do
157
160
  system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
data/lib/scout.rb CHANGED
@@ -5,5 +5,5 @@ require "scout/plugin"
5
5
  require "scout/server"
6
6
 
7
7
  module Scout
8
- VERSION = "2.0.5".freeze
8
+ VERSION = "2.0.6".freeze
9
9
  end
data/lib/scout/plugin.rb CHANGED
@@ -12,6 +12,26 @@ module Scout
12
12
  def load(last_run, memory, options)
13
13
  new(last_run, memory, options)
14
14
  end
15
+
16
+ #
17
+ # You can use this method to indicate one or more libraries your plugin
18
+ # requires:
19
+ #
20
+ # class MyNeedyPlugin < Scout::Plugin
21
+ # needs "faster_csv", "elif"
22
+ # # ...
23
+ # end
24
+ #
25
+ # Your build_report() method will not be called if all libraries cannot
26
+ # be loaded. RubyGems will be loaded if needed to find the libraries.
27
+ #
28
+ def needs(*libraries)
29
+ if libraries.empty?
30
+ @needs ||= [ ]
31
+ else
32
+ needs.push(*libraries.flatten)
33
+ end
34
+ end
15
35
  end
16
36
 
17
37
  # Creates a new Scout Plugin to run.
@@ -114,8 +134,31 @@ module Scout
114
134
  # automatically be returned as the end result of the run.
115
135
  #
116
136
  def run
117
- build_report
137
+ build_report if self.class.needs.all? { |l| library_available?(l) }
118
138
  data_for_server
119
139
  end
140
+
141
+ private
142
+
143
+ #
144
+ # Returns true is a library can be loaded. A bare require is made as the
145
+ # first attempt. If that fails, RubyGems is loaded and another attempt is
146
+ # made. If the library cannot be loaded either way, an error() is generated
147
+ # and build_report() will not be called.
148
+ #
149
+ def library_available?(library)
150
+ begin
151
+ require library
152
+ rescue LoadError
153
+ begin
154
+ require "rubygems"
155
+ require library
156
+ rescue LoadError
157
+ error("Failed to load library", "Could not load #{library}")
158
+ return false
159
+ end
160
+ end
161
+ true
162
+ end
120
163
  end
121
164
  end
data/lib/scout/server.rb CHANGED
@@ -116,7 +116,7 @@ module Scout
116
116
  return
117
117
  rescue Exception
118
118
  raise if $!.is_a? SystemExit
119
- error "Plugin failed to run: #{$!.backtrace}"
119
+ error "Plugin failed to run: #{$!.class}: #{$!}\n#{$!.backtrace.join("\n")}"
120
120
  end
121
121
  info "Plugin completed its run."
122
122
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Highgroove Studios
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-31 00:00:00 -04:00
12
+ date: 2008-08-28 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency