sequel_caller_location 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/build.yml +18 -0
- data/.github/workflows/publish.yml +24 -0
- data/.rubocop.yml +4 -7
- data/Gemfile +7 -0
- data/lib/sequel/extensions/caller_location.rb +32 -9
- data/sequel_caller_location.gemspec +7 -8
- data/spec/sequel/caller_location_spec.rb +20 -1
- data/spec/spec_helper.rb +1 -1
- metadata +11 -85
- data/.travis.yml +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 664ed2c560cae2dd6dcec7eb5375894c582ecec65c47e9b2d7430128d1a0748d
|
|
4
|
+
data.tar.gz: 53d362a1bb2704d8a03bf03923f7eac7540c49868773583404252dc970143867
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbe86a4254db07e89fb81c2600680a927793a9352c8770b79b639c5c03fd9de1c34a0f59d98396512e35deaddbdf363ce5cdc56a482060d9eb5169ceffc44bcb
|
|
7
|
+
data.tar.gz: cf5394da20edc9ea12cf3e60d43afd239667d6688cec172f07c8bfea37befa56b1d566e10c5aa51379af2538eaef484c6e23128d5c5f8d4ab72d2c68a4faea1f
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v7
|
|
10
|
+
- name: Set up Ruby
|
|
11
|
+
uses: ruby/setup-ruby@v1
|
|
12
|
+
with:
|
|
13
|
+
ruby-version: '3.4'
|
|
14
|
+
bundler-cache: true
|
|
15
|
+
- name: Run linter
|
|
16
|
+
run: bundle exec rubocop --parallel
|
|
17
|
+
- name: Run tests
|
|
18
|
+
run: bundle exec rspec
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: [published]
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
name: Publish
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- uses: actions/checkout@v7
|
|
11
|
+
- name: Set up Ruby
|
|
12
|
+
uses: ruby/setup-ruby@v1
|
|
13
|
+
with:
|
|
14
|
+
ruby-version: '3.4'
|
|
15
|
+
- name: Publish to RubyGems
|
|
16
|
+
run: |
|
|
17
|
+
mkdir -p $HOME/.gem
|
|
18
|
+
touch $HOME/.gem/credentials
|
|
19
|
+
chmod 0600 $HOME/.gem/credentials
|
|
20
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
21
|
+
gem build *.gemspec
|
|
22
|
+
gem push *.gem
|
|
23
|
+
env:
|
|
24
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
data/.rubocop.yml
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
plugins:
|
|
2
2
|
- rubocop-rspec
|
|
3
3
|
|
|
4
|
+
AllCops:
|
|
5
|
+
NewCops: enable
|
|
6
|
+
|
|
4
7
|
# Offense count: 2
|
|
5
8
|
Style/Documentation:
|
|
6
9
|
Exclude:
|
|
7
10
|
- 'spec/**/*'
|
|
8
11
|
- 'test/**/*'
|
|
9
12
|
- 'lib/sequel/extensions/caller_location.rb'
|
|
10
|
-
|
|
11
|
-
# Offense count: 5
|
|
12
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
13
|
-
# URISchemes: http, https
|
|
14
|
-
Metrics/LineLength:
|
|
15
|
-
Max: 106
|
data/Gemfile
CHANGED
|
@@ -1,21 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'sequel'
|
|
4
4
|
|
|
5
5
|
module Sequel
|
|
6
6
|
module CallerLocation
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
def insert_sql(*values)
|
|
8
|
+
sql = super
|
|
9
|
+
backtrace = caller_locations(1).find { |c| c.path !~ /gems/ }
|
|
10
|
+
append_location(sql, backtrace)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def update_sql(*values)
|
|
14
|
+
sql = super
|
|
15
|
+
backtrace = caller_locations(1).find { |c| c.path !~ /gems/ }
|
|
16
|
+
append_location(sql, backtrace)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def select_sql(*values)
|
|
20
|
+
sql = super
|
|
21
|
+
backtrace = caller_locations(1).find { |c| c.path !~ /gems/ }
|
|
22
|
+
|
|
23
|
+
@cache.delete(:_select_sql)
|
|
24
|
+
append_location(sql, backtrace)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def delete_sql(*values)
|
|
28
|
+
sql = super
|
|
29
|
+
backtrace = caller_locations(1).find { |c| c.path !~ /gems/ }
|
|
30
|
+
@cache.delete(:_delete_sql)
|
|
31
|
+
append_location(sql, backtrace)
|
|
15
32
|
end
|
|
16
33
|
|
|
17
34
|
private
|
|
18
35
|
|
|
36
|
+
def append_location(sql, backtrace)
|
|
37
|
+
return sql unless backtrace
|
|
38
|
+
|
|
39
|
+
sql + format_sql_comment(backtrace)
|
|
40
|
+
end
|
|
41
|
+
|
|
19
42
|
def format_sql_comment(comment)
|
|
20
43
|
" -- #{comment.to_s.gsub(/\s+/, ' ')}\n"
|
|
21
44
|
end
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
Gem::Specification.new do |gem|
|
|
2
4
|
gem.authors = ['Timothée Peignier']
|
|
3
5
|
gem.email = ['timothee.peignier@tryphon.org']
|
|
4
6
|
gem.description = 'Add caller location as SQL comments'
|
|
5
7
|
gem.summary = 'Add caller location as SQL comments.'
|
|
6
|
-
gem.homepage = '
|
|
8
|
+
gem.homepage = 'https://rubygems.org/gems/sequel_caller_location'
|
|
7
9
|
gem.license = 'MIT'
|
|
10
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
|
8
11
|
|
|
9
12
|
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
|
10
13
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
11
|
-
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
12
14
|
gem.name = 'sequel_caller_location'
|
|
13
15
|
gem.require_paths = ['lib']
|
|
14
|
-
gem.version = '0.
|
|
16
|
+
gem.version = '0.4.0'
|
|
15
17
|
|
|
16
|
-
gem.
|
|
18
|
+
gem.required_ruby_version = '>= 2.4'
|
|
17
19
|
|
|
18
|
-
gem.
|
|
19
|
-
gem.add_development_dependency 'rubocop', '~> 0.52', '>= 0.52.0'
|
|
20
|
-
gem.add_development_dependency 'rubocop-rspec', '~> 1.22.0', '>= 1.22.0'
|
|
21
|
-
gem.add_development_dependency 'simplecov', '~> 0.15.0'
|
|
20
|
+
gem.add_dependency 'sequel', '>= 4.39.0'
|
|
22
21
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
@@ -9,6 +9,11 @@ describe Sequel::CallerLocation do
|
|
|
9
9
|
expect(ds.select_sql).to eq("SELECT * FROM t -- #{caller_locations(0, 1).first}\n")
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
it 'add caller location to select statement only once' do
|
|
13
|
+
ds.select_sql
|
|
14
|
+
expect(ds.select_sql).to eq("SELECT * FROM t -- #{caller_locations(0, 1).first}\n")
|
|
15
|
+
end
|
|
16
|
+
|
|
12
17
|
it 'add caller location to insert statement' do
|
|
13
18
|
expect(ds.insert_sql(a: 1)).to eq("INSERT INTO t (a) VALUES (1) -- #{caller_locations(0, 1).first}\n")
|
|
14
19
|
end
|
|
@@ -17,7 +22,21 @@ describe Sequel::CallerLocation do
|
|
|
17
22
|
expect(ds.delete_sql).to eq("DELETE FROM t -- #{caller_locations(0, 1).first}\n")
|
|
18
23
|
end
|
|
19
24
|
|
|
25
|
+
it 'add caller location to delete statement only once' do
|
|
26
|
+
ds.delete_sql
|
|
27
|
+
expect(ds.delete_sql).to eq("DELETE FROM t -- #{caller_locations(0, 1).first}\n")
|
|
28
|
+
end
|
|
29
|
+
|
|
20
30
|
it 'add caller location to update statement' do
|
|
21
31
|
expect(ds.update_sql(a: 1)).to eq("UPDATE t SET a = 1 -- #{caller_locations(0, 1).first}\n")
|
|
22
32
|
end
|
|
33
|
+
|
|
34
|
+
it 'does not mutate frozen SQL' do
|
|
35
|
+
sql = String.new('SELECT * FROM t').freeze
|
|
36
|
+
location = caller_locations(0, 1).first
|
|
37
|
+
|
|
38
|
+
result = ds.send(:append_location, sql, location)
|
|
39
|
+
|
|
40
|
+
expect(result).to eq("SELECT * FROM t -- #{location}\n")
|
|
41
|
+
end
|
|
23
42
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sequel_caller_location
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Timothée Peignier
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sequel
|
|
@@ -24,80 +24,6 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: 4.39.0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: rspec
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - "~>"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: '3.5'
|
|
34
|
-
- - ">="
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: 3.5.0
|
|
37
|
-
type: :development
|
|
38
|
-
prerelease: false
|
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
40
|
-
requirements:
|
|
41
|
-
- - "~>"
|
|
42
|
-
- !ruby/object:Gem::Version
|
|
43
|
-
version: '3.5'
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 3.5.0
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: rubocop
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0.52'
|
|
54
|
-
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: 0.52.0
|
|
57
|
-
type: :development
|
|
58
|
-
prerelease: false
|
|
59
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
-
requirements:
|
|
61
|
-
- - "~>"
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
63
|
-
version: '0.52'
|
|
64
|
-
- - ">="
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: 0.52.0
|
|
67
|
-
- !ruby/object:Gem::Dependency
|
|
68
|
-
name: rubocop-rspec
|
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
|
70
|
-
requirements:
|
|
71
|
-
- - "~>"
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
version: 1.22.0
|
|
74
|
-
- - ">="
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: 1.22.0
|
|
77
|
-
type: :development
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
-
requirements:
|
|
81
|
-
- - "~>"
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: 1.22.0
|
|
84
|
-
- - ">="
|
|
85
|
-
- !ruby/object:Gem::Version
|
|
86
|
-
version: 1.22.0
|
|
87
|
-
- !ruby/object:Gem::Dependency
|
|
88
|
-
name: simplecov
|
|
89
|
-
requirement: !ruby/object:Gem::Requirement
|
|
90
|
-
requirements:
|
|
91
|
-
- - "~>"
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: 0.15.0
|
|
94
|
-
type: :development
|
|
95
|
-
prerelease: false
|
|
96
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
97
|
-
requirements:
|
|
98
|
-
- - "~>"
|
|
99
|
-
- !ruby/object:Gem::Version
|
|
100
|
-
version: 0.15.0
|
|
101
27
|
description: Add caller location as SQL comments
|
|
102
28
|
email:
|
|
103
29
|
- timothee.peignier@tryphon.org
|
|
@@ -105,9 +31,11 @@ executables: []
|
|
|
105
31
|
extensions: []
|
|
106
32
|
extra_rdoc_files: []
|
|
107
33
|
files:
|
|
34
|
+
- ".github/dependabot.yml"
|
|
35
|
+
- ".github/workflows/build.yml"
|
|
36
|
+
- ".github/workflows/publish.yml"
|
|
108
37
|
- ".gitignore"
|
|
109
38
|
- ".rubocop.yml"
|
|
110
|
-
- ".travis.yml"
|
|
111
39
|
- Gemfile
|
|
112
40
|
- LICENSE
|
|
113
41
|
- README.md
|
|
@@ -115,10 +43,11 @@ files:
|
|
|
115
43
|
- sequel_caller_location.gemspec
|
|
116
44
|
- spec/sequel/caller_location_spec.rb
|
|
117
45
|
- spec/spec_helper.rb
|
|
118
|
-
homepage:
|
|
46
|
+
homepage: https://rubygems.org/gems/sequel_caller_location
|
|
119
47
|
licenses:
|
|
120
48
|
- MIT
|
|
121
|
-
metadata:
|
|
49
|
+
metadata:
|
|
50
|
+
rubygems_mfa_required: 'true'
|
|
122
51
|
post_install_message:
|
|
123
52
|
rdoc_options: []
|
|
124
53
|
require_paths:
|
|
@@ -127,18 +56,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
127
56
|
requirements:
|
|
128
57
|
- - ">="
|
|
129
58
|
- !ruby/object:Gem::Version
|
|
130
|
-
version: '
|
|
59
|
+
version: '2.4'
|
|
131
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
61
|
requirements:
|
|
133
62
|
- - ">="
|
|
134
63
|
- !ruby/object:Gem::Version
|
|
135
64
|
version: '0'
|
|
136
65
|
requirements: []
|
|
137
|
-
|
|
138
|
-
rubygems_version: 2.7.4
|
|
66
|
+
rubygems_version: 3.0.3.1
|
|
139
67
|
signing_key:
|
|
140
68
|
specification_version: 4
|
|
141
69
|
summary: Add caller location as SQL comments.
|
|
142
|
-
test_files:
|
|
143
|
-
- spec/sequel/caller_location_spec.rb
|
|
144
|
-
- spec/spec_helper.rb
|
|
70
|
+
test_files: []
|