rorvswild 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rorvswild/version.rb +2 -2
- data/lib/rorvswild.rb +25 -2
- data/rorvswild.gemspec +2 -2
- data/test/ror_vs_wild_test.rb +16 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d51045f4d30998e878c0a5c3db82c8a519c6e41
|
4
|
+
data.tar.gz: 53eb0bc8ffe92a7b53e9500af26b351f112edb65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78f0092c6e641139b0c75cbc4895be8ab0d5011292a309cdb871f3ed7a359a385d1766679e49342d09b93ef9cbca86b41a63b1de79312509dd321c5278f277c8
|
7
|
+
data.tar.gz: c3c9f93f7bd26a1c8cee07946cc9a74a4c1dfa7a2a3f44449b90fee264ca278a7c56c89d7bda27f42213aea1873437042d9dc0ea4fb2a0003fd1d266054c5230
|
data/lib/rorvswild/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
module RorVsWild
|
2
|
+
VERSION = "0.0.8".freeze
|
3
3
|
end
|
data/lib/rorvswild.rb
CHANGED
@@ -18,6 +18,14 @@ module RorVsWild
|
|
18
18
|
default_client ? default_client.measure_job(code) : eval(code)
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.measure_code(code)
|
22
|
+
default_client ? default_client.measure_code(code) : eval(code)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.measure_block(name, &block)
|
26
|
+
default_client ? default_client.measure_block(name , &block) : block.call
|
27
|
+
end
|
28
|
+
|
21
29
|
class Client
|
22
30
|
def self.default_config
|
23
31
|
{
|
@@ -48,6 +56,8 @@ module RorVsWild
|
|
48
56
|
|
49
57
|
client = self
|
50
58
|
ActionController::Base.rescue_from(StandardError) { |exception| client.after_exception(exception, self) }
|
59
|
+
|
60
|
+
Delayed::Worker.lifecycle.around(:invoke_job, &method(:around_delayed_job)) if defined?(Delayed::Worker)
|
51
61
|
end
|
52
62
|
|
53
63
|
def before_http_request(name, start, finish, id, payload)
|
@@ -107,12 +117,25 @@ module RorVsWild
|
|
107
117
|
raise exception
|
108
118
|
end
|
109
119
|
|
120
|
+
def around_delayed_job(job, &block)
|
121
|
+
measure_block(job.name) { block.call(job) }
|
122
|
+
end
|
123
|
+
|
110
124
|
def measure_job(code)
|
125
|
+
warn "WARNING: RorVsWild.measure_job is deprecated. Use RorVsWild.measure_code instead."
|
126
|
+
measure_block(code) { eval(code) }
|
127
|
+
end
|
128
|
+
|
129
|
+
def measure_code(code)
|
130
|
+
measure_block(code) { eval(code) }
|
131
|
+
end
|
132
|
+
|
133
|
+
def measure_block(name, &block)
|
111
134
|
@queries = []
|
112
|
-
@job = {name:
|
135
|
+
@job = {name: name}
|
113
136
|
started_at = Time.now
|
114
137
|
cpu_time_offset = cpu_time
|
115
|
-
|
138
|
+
block.call
|
116
139
|
rescue => exception
|
117
140
|
file, line = exception.backtrace.first.split(":")
|
118
141
|
job[:error] = {
|
data/rorvswild.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'rorvswild/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "rorvswild"
|
8
|
-
spec.version =
|
8
|
+
spec.version = RorVsWild::VERSION
|
9
9
|
spec.authors = ["Alexis Bernard"]
|
10
10
|
spec.email = ["alexis@bernard.io"]
|
11
11
|
spec.summary = "Simple Ruby on Rails application monitoring for hardcore developers with no time to waste."
|
12
|
-
spec.description = "
|
12
|
+
spec.description = "Simple Ruby on Rails application monitoring for hardcore developers with no time to waste."
|
13
13
|
spec.homepage = "http://www.rorvswild.com"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
data/test/ror_vs_wild_test.rb
CHANGED
@@ -10,23 +10,35 @@ require "top_tests"
|
|
10
10
|
class RorVsWildTest < MiniTest::Unit::TestCase
|
11
11
|
include TopTests
|
12
12
|
|
13
|
-
def
|
13
|
+
def test_measure_code
|
14
14
|
client.expects(:post_job)
|
15
|
-
assert_equal(2, client.
|
15
|
+
assert_equal(2, client.measure_code("1 + 1"))
|
16
16
|
assert_equal("1 + 1", client.send(:job)[:name])
|
17
17
|
assert(client.send(:job)[:runtime] > 0)
|
18
18
|
assert_equal(0, client.send(:job)[:cpu_runtime])
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
21
|
+
def test_measure_code_when_raising
|
22
22
|
client.expects(:post_job)
|
23
|
-
assert_raises(RuntimeError) { client.
|
23
|
+
assert_raises(RuntimeError) { client.measure_code("raise 'error'") }
|
24
24
|
assert_equal(("raise 'error'"), client.send(:job)[:name])
|
25
25
|
assert(client.send(:job)[:cpu_runtime])
|
26
26
|
assert(client.send(:job)[:runtime])
|
27
27
|
assert(client.send(:job)[:error])
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_measure_code_when_no_client
|
31
|
+
RorVsWild.register_default_client(nil)
|
32
|
+
RorVsWild::Client.any_instance.expects(:post_job).never
|
33
|
+
assert_equal(2, RorVsWild.measure_code("1+1"))
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_measure_block_when_no_client
|
37
|
+
RorVsWild.register_default_client(nil)
|
38
|
+
RorVsWild::Client.any_instance.expects(:post_job).never
|
39
|
+
assert_equal(2, RorVsWild.measure_block("1+1") { 1+1 })
|
40
|
+
end
|
41
|
+
|
30
42
|
private
|
31
43
|
|
32
44
|
def client
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,7 +24,8 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
-
description:
|
27
|
+
description: Simple Ruby on Rails application monitoring for hardcore developers with
|
28
|
+
no time to waste.
|
28
29
|
email:
|
29
30
|
- alexis@bernard.io
|
30
31
|
executables: []
|