activerecord-cause 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +34 -0
- data/Gemfile +2 -0
- data/README.md +1 -1
- data/activerecord-cause.gemspec +2 -3
- data/gemfiles/{activerecord-507.gemfile → activerecord-700.gemfile} +2 -1
- data/gemfiles/{activerecord-514.gemfile → activerecord-710.gemfile} +2 -1
- data/gemfiles/{activerecord-502.gemfile → activerecord-720.gemfile} +2 -1
- data/gemfiles/{activerecord-503.gemfile → activerecord-800.gemfile} +2 -1
- data/lib/activerecord/cause/version.rb +1 -1
- data/lib/activerecord/cause.rb +24 -2
- metadata +14 -31
- data/.travis.yml +0 -12
- data/gemfiles/activerecord-515.gemfile +0 -5
- data/gemfiles/activerecord-520.gemfile +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3644ee413d6fc3bc2a552d3bb429a754eae6aa05798b69453844e550413590ff
|
4
|
+
data.tar.gz: dc0cb699195301b5304d74367a1bcfaedc5b673982a3964caff979b3435eeac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6ed5245ede4d8e16209956b618ba1b4688841801f36a2a9da6c38cf2486f82122e5c3e4b8eb94bef6c695bb90728e01d462af9300db22689310279312baace
|
7
|
+
data.tar.gz: c7aba3271158b879e5e087b33de61c2d9bb294c34afd23925d1f33cf6630fec0cc654121f6f7261b3d31a483368030e16790379e821670afaaaffb8f8dd0fa73
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: RSpec
|
2
|
+
|
3
|
+
on:
|
4
|
+
schedule:
|
5
|
+
- cron: "0 9 * * 1"
|
6
|
+
push:
|
7
|
+
branches: [ master ]
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby-version: ['3.1', '3.2', '3.3']
|
17
|
+
gemfile: ["Gemfile", "gemfiles/activerecord-700.gemfile", "gemfiles/activerecord-710.gemfile", "gemfiles/activerecord-720.gemfile", "gemfiles/activerecord-800.gemfile"]
|
18
|
+
exclude:
|
19
|
+
- ruby-version: '3.1'
|
20
|
+
gemfile: "gemfiles/activerecord-800.gemfile"
|
21
|
+
env:
|
22
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v4
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
uses: ruby/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby-version }}
|
32
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
33
|
+
- name: Run tests
|
34
|
+
run: bundle exec rake
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Activerecord::Cause
|
2
|
-
[![
|
2
|
+
[![RSpec](https://github.com/joker1007/activerecord-cause/actions/workflows/rspec.yml/badge.svg)](https://github.com/joker1007/activerecord-cause/actions/workflows/rspec.yml)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/activerecord-cause.svg)](http://badge.fury.io/rb/activerecord-cause)
|
4
4
|
|
5
5
|
This gem logs where ActiveRecord actually loads record
|
data/activerecord-cause.gemspec
CHANGED
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "activerecord", ">=
|
21
|
+
spec.add_runtime_dependency "activerecord", ">= 6"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", ">= 1.6"
|
24
|
-
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "sqlite3"
|
27
26
|
end
|
data/lib/activerecord/cause.rb
CHANGED
@@ -45,7 +45,7 @@ module ActiveRecord
|
|
45
45
|
|
46
46
|
name = name_with_color(payload[:name])
|
47
47
|
sql = sql_with_color(payload[:sql])
|
48
|
-
cause =
|
48
|
+
cause = generate_cause(loc.to_s, true)
|
49
49
|
|
50
50
|
output =
|
51
51
|
if ActiveRecord::Cause.log_with_sql
|
@@ -85,6 +85,10 @@ module ActiveRecord
|
|
85
85
|
def sql_with_color(payload_sql)
|
86
86
|
raise NotImplementedError
|
87
87
|
end
|
88
|
+
|
89
|
+
def generate_cause(text, mode_option)
|
90
|
+
color(text, nil, mode_option)
|
91
|
+
end
|
88
92
|
end
|
89
93
|
|
90
94
|
class LogSubscriberAR4 < ActiveRecord::Cause::LogSubscriber
|
@@ -160,13 +164,31 @@ module ActiveRecord
|
|
160
164
|
" " + payload[:binds].zip(casted_params).map { |attr, value| render_bind(attr, value) }.inspect
|
161
165
|
end
|
162
166
|
end
|
167
|
+
|
168
|
+
class LogSubscriberAR711 < LogSubscriberAR515
|
169
|
+
def sql(event)
|
170
|
+
super
|
171
|
+
end
|
172
|
+
|
173
|
+
private
|
174
|
+
|
175
|
+
def sql_with_color(sql)
|
176
|
+
color(sql, sql_color(sql), bold: true)
|
177
|
+
end
|
178
|
+
|
179
|
+
def generate_cause(text, mode_option)
|
180
|
+
color(text, nil, bold: mode_option)
|
181
|
+
end
|
182
|
+
end
|
163
183
|
end
|
164
184
|
end
|
165
185
|
|
166
186
|
require "activerecord/cause/railtie" if defined?(Rails)
|
167
187
|
|
168
188
|
ActiveSupport.on_load(:active_record) do
|
169
|
-
if ActiveRecord.version >= Gem::Version.new("
|
189
|
+
if ActiveRecord.version >= Gem::Version.new("7.1.1")
|
190
|
+
ActiveRecord::Cause::LogSubscriberAR711.attach_to :active_record
|
191
|
+
elsif ActiveRecord.version >= Gem::Version.new("5.1.0")
|
170
192
|
if ActiveRecord.version >= Gem::Version.new("5.1.5")
|
171
193
|
ActiveRecord::Cause::LogSubscriberAR515.attach_to :active_record
|
172
194
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-cause
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -40,20 +40,6 @@ dependencies:
|
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -67,7 +53,7 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: rspec
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
@@ -87,21 +73,19 @@ executables: []
|
|
87
73
|
extensions: []
|
88
74
|
extra_rdoc_files: []
|
89
75
|
files:
|
76
|
+
- ".github/workflows/rspec.yml"
|
90
77
|
- ".gitignore"
|
91
78
|
- ".rspec"
|
92
|
-
- ".travis.yml"
|
93
79
|
- Gemfile
|
94
80
|
- README.md
|
95
81
|
- Rakefile
|
96
82
|
- activerecord-cause.gemspec
|
97
83
|
- bin/console
|
98
84
|
- bin/setup
|
99
|
-
- gemfiles/activerecord-
|
100
|
-
- gemfiles/activerecord-
|
101
|
-
- gemfiles/activerecord-
|
102
|
-
- gemfiles/activerecord-
|
103
|
-
- gemfiles/activerecord-515.gemfile
|
104
|
-
- gemfiles/activerecord-520.gemfile
|
85
|
+
- gemfiles/activerecord-700.gemfile
|
86
|
+
- gemfiles/activerecord-710.gemfile
|
87
|
+
- gemfiles/activerecord-720.gemfile
|
88
|
+
- gemfiles/activerecord-800.gemfile
|
105
89
|
- lib/activerecord-cause.rb
|
106
90
|
- lib/activerecord/cause.rb
|
107
91
|
- lib/activerecord/cause/railtie.rb
|
@@ -109,7 +93,7 @@ files:
|
|
109
93
|
homepage: https://github.com/joker1007/activerecord-cause
|
110
94
|
licenses: []
|
111
95
|
metadata: {}
|
112
|
-
post_install_message:
|
96
|
+
post_install_message:
|
113
97
|
rdoc_options: []
|
114
98
|
require_paths:
|
115
99
|
- lib
|
@@ -124,9 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
108
|
- !ruby/object:Gem::Version
|
125
109
|
version: '0'
|
126
110
|
requirements: []
|
127
|
-
|
128
|
-
|
129
|
-
signing_key:
|
111
|
+
rubygems_version: 3.5.11
|
112
|
+
signing_key:
|
130
113
|
specification_version: 4
|
131
114
|
summary: This gem logs where ActiveRecord actually loads record
|
132
115
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
sudo: false
|
3
|
-
rvm:
|
4
|
-
- 2.5.1
|
5
|
-
- 2.4.1
|
6
|
-
gemfile:
|
7
|
-
- gemfiles/activerecord-502.gemfile
|
8
|
-
- gemfiles/activerecord-503.gemfile
|
9
|
-
- gemfiles/activerecord-507.gemfile
|
10
|
-
- gemfiles/activerecord-514.gemfile
|
11
|
-
- gemfiles/activerecord-515.gemfile
|
12
|
-
- gemfiles/activerecord-520.gemfile
|