sequel_caller_location 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9d845d6dcf0e1c5ede539c4667c39995b9641d09
4
+ data.tar.gz: baad2437df4715cd35d5dde81c0df0d104fa513f
5
+ SHA512:
6
+ metadata.gz: c0c683e308e0514d86df3be78d6b6a0974370fc58bf6b1601c9cee59b3dee83a5d6e100879697565fff22329162545bbafb0ec68e2fcad66a6af2c156560a2ec
7
+ data.tar.gz: a5a9bb6953de4275ca461e41243fee8afbd5d532ac12874d76d569c1d85a94b9ddc97ba8c3a62cf7e1bce93ddd1fc4fcf6a8617883811aaacd399f169ba8e1be
@@ -0,0 +1,5 @@
1
+ coverage
2
+ *.gem
3
+ doc/
4
+ .yardoc
5
+ .tags
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,20 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-10-11 19:36:45 -0700 using RuboCop version 0.43.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 7
10
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
11
+ # URISchemes: http, https
12
+ Metrics/LineLength:
13
+ Max: 152
14
+
15
+ # Offense count: 2
16
+ Style/Documentation:
17
+ Exclude:
18
+ - 'spec/**/*'
19
+ - 'test/**/*'
20
+ - 'lib/sequel/extensions/comments.rb'
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.3.1
5
+ sudo: false
6
+ script: bundle exec rspec
7
+ notifications:
8
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sequel_comments (0.1.1)
5
+ sequel (~> 4.39, >= 4.39.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.3.0)
11
+ diff-lcs (1.2.5)
12
+ docile (1.1.5)
13
+ json (2.0.2)
14
+ parser (2.3.1.4)
15
+ ast (~> 2.2)
16
+ powerpack (0.1.1)
17
+ rainbow (2.1.0)
18
+ rspec (3.5.0)
19
+ rspec-core (~> 3.5.0)
20
+ rspec-expectations (~> 3.5.0)
21
+ rspec-mocks (~> 3.5.0)
22
+ rspec-core (3.5.3)
23
+ rspec-support (~> 3.5.0)
24
+ rspec-expectations (3.5.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.5.0)
27
+ rspec-mocks (3.5.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.5.0)
30
+ rspec-support (3.5.0)
31
+ rubocop (0.43.0)
32
+ parser (>= 2.3.1.1, < 3.0)
33
+ powerpack (~> 0.1)
34
+ rainbow (>= 1.99.1, < 3.0)
35
+ ruby-progressbar (~> 1.7)
36
+ unicode-display_width (~> 1.0, >= 1.0.1)
37
+ ruby-progressbar (1.8.1)
38
+ sequel (4.39.0)
39
+ simplecov (0.12.0)
40
+ docile (~> 1.1.0)
41
+ json (>= 1.8, < 3)
42
+ simplecov-html (~> 0.10.0)
43
+ simplecov-html (0.10.0)
44
+ unicode-display_width (1.1.1)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ rspec (~> 3.5, >= 3.5.0)
51
+ rubocop (~> 0.43, >= 0.43.0)
52
+ sequel_comments!
53
+ simplecov (~> 0.12.0)
54
+
55
+ BUNDLED WITH
56
+ 1.12.5
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Timothée Peignier <timothee.peignier@tryphon.org>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ # Sequel Caller Location
2
+
3
+ Set the caller location as comments to your SQL.
4
+
5
+ ## Installation
6
+
7
+ Install it directly using gem:
8
+
9
+ ```
10
+ gem install sequel_caller_location
11
+ ```
12
+
13
+ Or adding it to your ``Gemfile``:
14
+
15
+ ```
16
+ gem "sequel_caller_location"
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ## Configure
22
+
23
+ A straightforward example, this will let sequel_caller_location add the caller location
24
+ automatically:
25
+
26
+ ```ruby
27
+ DB.extension(:caller_location)
28
+ ```
@@ -0,0 +1,24 @@
1
+ # frozen-string-literal: true
2
+ require 'sequel'
3
+
4
+ module Sequel
5
+ module CallerLocation
6
+ %w(select insert update delete).each do |type|
7
+ define_method(:"#{type}_sql") do |*a|
8
+ sql = super(*a)
9
+ if (backtrace = caller_locations(1).find { |c| c.path !~ /gems/ })
10
+ sql += format_sql_comment(backtrace)
11
+ end
12
+ sql
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def format_sql_comment(comment)
19
+ " -- #{comment.to_s.gsub(/\s+/, ' ')}\n"
20
+ end
21
+ end
22
+
23
+ Dataset.register_extension(:caller_location, CallerLocation)
24
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ['Timothée Peignier']
5
+ gem.email = ['timothee.peignier@tryphon.org']
6
+ gem.description = 'Add caller location as SQL comments'
7
+ gem.summary = 'Add caller location as SQL comments.'
8
+ gem.homepage = 'http://rubygems.org/gems/sequel_caller_location'
9
+ gem.license = 'MIT'
10
+
11
+ gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = 'sequel_caller_location'
15
+ gem.require_paths = ['lib']
16
+ gem.version = '0.1.1'
17
+
18
+ gem.add_runtime_dependency 'sequel', '~> 4.39', '>= 4.39.0'
19
+
20
+ gem.add_development_dependency 'rspec', '~> 3.5', '>= 3.5.0'
21
+ gem.add_development_dependency 'simplecov', '~> 0.12.0'
22
+ gem.add_development_dependency 'rubocop', '~> 0.43', '>= 0.43.0'
23
+ end
@@ -0,0 +1,13 @@
1
+ # frozen-string-literal: true
2
+ require 'spec_helper'
3
+
4
+ describe Sequel::CallerLocation do
5
+ let(:ds) { Sequel.mock[:t].extension(:caller_location) }
6
+
7
+ it 'add caller location comment' do
8
+ expect(ds.select_sql).to eq("SELECT * FROM t -- #{caller_locations(0, 1).first}\n")
9
+ expect(ds.insert_sql(a: 1)).to eq("INSERT INTO t (a) VALUES (1) -- #{caller_locations(0, 1).first}\n")
10
+ expect(ds.delete_sql).to eq("DELETE FROM t -- #{caller_locations(0, 1).first}\n")
11
+ expect(ds.update_sql(a: 1)).to eq("UPDATE t SET a = 1 -- #{caller_locations(0, 1).first}\n")
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen-string-literal: true
2
+ require 'bundler'
3
+ Bundler.require
4
+
5
+ require 'simplecov'
6
+ SimpleCov.start do
7
+ add_filter('spec/')
8
+ end
9
+
10
+ require 'sequel'
11
+ require 'sequel/extensions/caller_location'
12
+
13
+ RSpec.configure do |config|
14
+ config.order = 'random'
15
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequel_caller_location
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Timothée Peignier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sequel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.39'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.39.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.39'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.39.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.5'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.5.0
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.5'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.5.0
53
+ - !ruby/object:Gem::Dependency
54
+ name: simplecov
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 0.12.0
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 0.12.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: rubocop
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.43'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.43.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.43'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.43.0
87
+ description: Add caller location as SQL comments
88
+ email:
89
+ - timothee.peignier@tryphon.org
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".gitignore"
95
+ - ".rubocop.yml"
96
+ - ".rubocop_todo.yml"
97
+ - ".travis.yml"
98
+ - Gemfile
99
+ - Gemfile.lock
100
+ - LICENSE
101
+ - README.md
102
+ - lib/sequel/extensions/caller_location.rb
103
+ - sequel_caller_location.gemspec
104
+ - spec/caller_location_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: http://rubygems.org/gems/sequel_caller_location
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.5.1
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Add caller location as SQL comments.
130
+ test_files:
131
+ - spec/caller_location_spec.rb
132
+ - spec/spec_helper.rb