activerecord-cause 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54ca7b1399c8230ab12deef17b2639e5d6b0e06aa564bead2daeb246ee720880
4
- data.tar.gz: 71cde8d2f692c8f27a82de10434bb05369eb09a6073ba1f330100f5467f57cae
3
+ metadata.gz: 3644ee413d6fc3bc2a552d3bb429a754eae6aa05798b69453844e550413590ff
4
+ data.tar.gz: dc0cb699195301b5304d74367a1bcfaedc5b673982a3964caff979b3435eeac9
5
5
  SHA512:
6
- metadata.gz: d7f68258e9ec31b850ba51b6975f61e28b8c5bab019219efc199e3cb55b05113ba253722f44c2d124df94471a15483e97de5a7118b395c881cf56a01ffdf0948
7
- data.tar.gz: b7816dded9c23a9c1e4779333c90f57190b3824212ebd276cc43325520cb6e8db3a9232dddd3da92aa7da60a3ca193d48153b7c9a1ab7a174ba9ab192618b061
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
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in activerecord-cause.gemspec
4
4
  gemspec
5
+
6
+ gem "sqlite3"
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Activerecord::Cause
2
- [![Build Status](https://travis-ci.org/joker1007/activerecord-cause.svg?branch=master)](https://travis-ci.org/joker1007/activerecord-cause)
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
@@ -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", ">= 4"
21
+ spec.add_runtime_dependency "activerecord", ">= 6"
22
22
 
23
23
  spec.add_development_dependency "bundler", ">= 1.6"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec"
26
- spec.add_development_dependency "sqlite3"
27
26
  end
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 5.0.3"
3
+ gem "activerecord", "~> 7.0.0"
4
+ gem "sqlite3", "~> 1.4"
4
5
 
5
6
  gemspec :path => "../"
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 5.1.0", "< 5.1.5"
3
+ gem "activerecord", "~> 7.1.0"
4
+ gem "sqlite3"
4
5
 
5
6
  gemspec :path => "../"
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 4.2.0"
3
+ gem "activerecord", "~> 7.2.0"
4
+ gem "sqlite3"
4
5
 
5
6
  gemspec :path => "../"
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 5.0.0", "< 5.0.3"
3
+ gem "activerecord", "~> 8.0.0"
4
+ gem "sqlite3"
4
5
 
5
6
  gemspec :path => "../"
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Cause
3
- VERSION = "0.6.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -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 = color(loc.to_s, nil, true)
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,18 +164,44 @@ 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("5.1.5")
170
- ActiveRecord::Cause::LogSubscriberAR515.attach_to :active_record
171
- elsif ActiveRecord.version >= Gem::Version.new("5.0.3")
172
- ActiveRecord::Cause::LogSubscriberAR503.attach_to :active_record
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")
192
+ if ActiveRecord.version >= Gem::Version.new("5.1.5")
193
+ ActiveRecord::Cause::LogSubscriberAR515.attach_to :active_record
194
+ else
195
+ ActiveRecord::Cause::LogSubscriberAR503.attach_to :active_record
196
+ end
173
197
  elsif ActiveRecord.version >= Gem::Version.new("5.0.0")
174
- ActiveRecord::Cause::LogSubscriberAR502.attach_to :active_record
198
+ if ActiveRecord.version >= Gem::Version.new("5.0.7")
199
+ ActiveRecord::Cause::LogSubscriberAR515.attach_to :active_record
200
+ elsif ActiveRecord.version >= Gem::Version.new("5.0.3")
201
+ ActiveRecord::Cause::LogSubscriberAR503.attach_to :active_record
202
+ elsif ActiveRecord.version >= Gem::Version.new("5.0.0")
203
+ ActiveRecord::Cause::LogSubscriberAR502.attach_to :active_record
204
+ end
175
205
  else
176
206
  ActiveRecord::Cause::LogSubscriberAR4.attach_to :active_record
177
207
  end
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.6.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: 2018-03-20 00:00:00.000000000 Z
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: '4'
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: '4'
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: sqlite3
56
+ name: rspec
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -87,20 +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-42.gemfile
100
- - gemfiles/activerecord-502.gemfile
101
- - gemfiles/activerecord-503.gemfile
102
- - gemfiles/activerecord-514.gemfile
103
- - gemfiles/activerecord-515.gemfile
85
+ - gemfiles/activerecord-700.gemfile
86
+ - gemfiles/activerecord-710.gemfile
87
+ - gemfiles/activerecord-720.gemfile
88
+ - gemfiles/activerecord-800.gemfile
104
89
  - lib/activerecord-cause.rb
105
90
  - lib/activerecord/cause.rb
106
91
  - lib/activerecord/cause/railtie.rb
@@ -108,7 +93,7 @@ files:
108
93
  homepage: https://github.com/joker1007/activerecord-cause
109
94
  licenses: []
110
95
  metadata: {}
111
- post_install_message:
96
+ post_install_message:
112
97
  rdoc_options: []
113
98
  require_paths:
114
99
  - lib
@@ -123,9 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
108
  - !ruby/object:Gem::Version
124
109
  version: '0'
125
110
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.7.6
128
- signing_key:
111
+ rubygems_version: 3.5.11
112
+ signing_key:
129
113
  specification_version: 4
130
114
  summary: This gem logs where ActiveRecord actually loads record
131
115
  test_files: []
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 2.4.1
5
- - 2.3.3
6
- gemfile:
7
- - gemfiles/activerecord-42.gemfile
8
- - gemfiles/activerecord-502.gemfile
9
- - gemfiles/activerecord-503.gemfile
10
- - gemfiles/activerecord-514.gemfile
11
- - gemfiles/activerecord-515.gemfile
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "activerecord", "~> 5.1.5"
4
-
5
- gemspec :path => "../"