sequel-instruments 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sequel/instruments.rb +26 -0
  2. metadata +62 -0
@@ -0,0 +1,26 @@
1
+ module Sequel
2
+ module Instruments
3
+ module ::Sequel
4
+ class Database
5
+ def log_yield(sql, args=nil)
6
+ sql = "#{sql}; #{args}" if args
7
+ Slides.log :instrumentation, action: action(sql), sql: sql do
8
+ begin
9
+ yield
10
+ rescue => e
11
+ Slides.log :database_error, exception: e.class.name,
12
+ message: e.message, sql: sql, backtrace: e.backtrace
13
+ raise
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def action(sql)
21
+ sql[/(\w+){1}/].upcase
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequel-instruments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brandur
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: slides
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.1'
30
+ description:
31
+ email: brandur@mutelight.org
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - lib/sequel/instruments.rb
37
+ homepage: https://github.com/brandur/rack-instruments
38
+ licenses:
39
+ - MIT
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.23
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Basic instrumentation for Sequel.
62
+ test_files: []