kametori 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/kametori/version.rb +1 -1
  2. data/lib/kametori.rb +33 -1
  3. metadata +1 -1
@@ -1,3 +1,3 @@
1
1
  module Kametori
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/kametori.rb CHANGED
@@ -1,5 +1,37 @@
1
1
  require "kametori/version"
2
2
 
3
3
  module Kametori
4
- # Your code goes here...
4
+ # exception classes
5
+ class Error < RuntimeError
6
+ end
7
+ class Timeout < RuntimeError
8
+
9
+ end
10
+
11
+ class << self
12
+ def limits=(limits)
13
+ raise Error if !limits.is_a? Array
14
+ @limits = limits
15
+ end
16
+
17
+ def limits
18
+ @limits
19
+ end
20
+
21
+ def benchmark_scenario(scenario, options={})
22
+ under_test = @limits.find{ |limit| limit[:tag] == scenario.tag}
23
+ return nil if under_test.nil?
24
+ before = Time.now
25
+ yield if block_given?
26
+ after = Time.now
27
+ elapsed = after - before
28
+ if options[:raise]
29
+ if ( elapsed > under_test[:limit])
30
+ raise Timeout
31
+ end
32
+ end
33
+ elapsed
34
+ end
35
+
36
+ end
5
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kametori
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: