fiveruns-dash-ruby 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -62,7 +62,9 @@ module Fiveruns::Dash
62
62
  # Merge in an existing recipe
63
63
  # call-seq:
64
64
  # add_recipe :ruby
65
- def add_recipe(name, options = {})
65
+ def add_recipe(name, options = {}, &block)
66
+ Fiveruns::Dash.register_recipe(name, options, &block) if block_given?
67
+
66
68
  if Fiveruns::Dash.recipes[name]
67
69
  Fiveruns::Dash.recipes[name].each do |recipe|
68
70
  if !recipes.include?(recipe) && recipe.matches?(options)
@@ -133,17 +133,27 @@ module Fiveruns::Dash
133
133
  values.detect { |value| value[:context] == context }[:value]
134
134
  end
135
135
 
136
- { :value => @operation.call(*args), :context => context }
136
+ { :value => metric_callback(*args), :context => context }
137
137
  end
138
138
 
139
139
  {:values => values}
140
140
  end
141
141
 
142
142
  def value_hash
143
- current_value = ::Fiveruns::Dash.sync { @operation.call }
143
+ current_value = ::Fiveruns::Dash.sync { metric_callback }
144
144
  {:values => parse_value(current_value)}
145
145
  end
146
146
 
147
+ def metric_callback(*args)
148
+ begin
149
+ @operation.call(*args)
150
+ rescue Exception => ex
151
+ Fiveruns::Dash.logger.error("Metric #{recipe ? "#{recipe.name}/" : ''}#{@name} raised #{ex.class.name}: #{ex.message}")
152
+ Fiveruns::Dash.logger.error(ex.backtrace.join("\n"))
153
+ 0
154
+ end
155
+ end
156
+
147
157
  # Verifies value matches one of the following patterns:
148
158
  # * A numeric value (indicates no namespace)
149
159
  # * A hash of [namespace_kind, namespace_name, ...] => value pairs, eg:
data/test/test_helper.rb CHANGED
@@ -46,6 +46,7 @@ class Test::Unit::TestCase
46
46
  @recipes << Fiveruns::Dash::Recipe.new(:foo, :url => 'http://foo.com')
47
47
  @recipes << Fiveruns::Dash::Recipe.new(:foo2, :url => 'http://foo2.com')
48
48
  @metrics << @metric_class.new("NonCustomMetric") { 2 }
49
+ @metrics << @metric_class.new("BadMetric") { raise ArgumentError }
49
50
  @configuration = flexmock(:configuration) do |mock|
50
51
  mock.should_receive(:metrics).and_return(@metrics)
51
52
  mock.should_receive(:recipes).and_return(@recipes)
data/version.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 7
4
- :patch: 5
4
+ :patch: 6
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiveruns-dash-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - FiveRuns Development Team
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-10 00:00:00 -08:00
12
+ date: 2009-02-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency