activerecord-originator 0.1.0 → 0.2.1

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: fa3749b460f4bf88f4ae707b69db1e2c32f41d7bfac6780ebafbc4e96375a730
4
- data.tar.gz: b130e6f429f7cd6acc167715a08797f9816f16d06fa990fc1ddda22c4d17700b
3
+ metadata.gz: 293717934922e2684e5351b8f2c1abe48bb72f13706a3c3453496e92b501dd18
4
+ data.tar.gz: 0c445a63206b42a5742727875d51bb95385e48d086d637966b784397d9acc6ba
5
5
  SHA512:
6
- metadata.gz: 30ce59ca0d48a39793d27a959db9a93dff186006ac83bb4fe220469cde766ac7627c9fe1e0b9f429ecb16e339481f95dbbc39ad7d656d82b1875ef88281f4216
7
- data.tar.gz: c502f0bf40254b8d92484e4a9fa5e5bdc20eb28a096e4a265fb94616dcca7f3ce4dc6f37e9c2e9a740666f4aeac31e68886fcd50ceb16797c43abd46506480fd
6
+ metadata.gz: 6aada6e56b8c43b7f0fe9c6520ffedbb6c9cb099e817815cbc48a67b7473903cbb8cf9cb0fe899354d7de1f5808ee81d315b8b7e5b976989270dc0e3b97ddbce
7
+ data.tar.gz: 896311b48db01c18309b3d7d22c41b4dda6385c81cba5ff47fb3e568f6a569d82ff2d6fced94fe6a6996a688eef271a784008500e3ff183f020246b9783497c4
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # CHANGELOG
2
+
3
+ ## v0.2.1 - 2024-03-20
4
+
5
+ This release does not affect the behavior of the library. It changes only RBS files.
6
+
7
+ * Avoid exposing Rails.backtrace_cleaner type [#19](https://github.com/pocke/activerecord-originator/pull/19)
8
+
9
+ ## v0.2.0 - 2024-03-16
10
+
11
+ * Avoid modifying unnecessary nodes for performance. [#15](https://github.com/pocke/activerecord-originator/pull/15)
12
+
13
+ ## v0.1.0 - 2024-03-13
14
+
15
+ * The first release!
data/Rakefile CHANGED
@@ -14,3 +14,28 @@ task :steep do
14
14
  end
15
15
 
16
16
  task default: %i[rubocop steep spec]
17
+
18
+ namespace :benchmark do
19
+ task :to_sql do
20
+ puts "# Benchmarking #to_sql mehtod"
21
+ puts
22
+ puts "## Wihtout AR::Originator"
23
+ sh 'ruby', 'benchmark/to_sql.rb'
24
+
25
+ puts
26
+ puts "## With AR::Originator"
27
+ sh 'ruby', '-r', 'activerecord/originator', 'benchmark/to_sql.rb'
28
+ end
29
+
30
+ task :select_query do
31
+ puts "# Benchmarking SELECT Query"
32
+ puts
33
+ puts "## Wihtout AR::Originator"
34
+ sh 'ruby', 'benchmark/select_query.rb'
35
+
36
+ puts
37
+ puts "## With AR::Originator"
38
+ sh 'ruby', '-r', 'activerecord/originator', 'benchmark/select_query.rb'
39
+ end
40
+ end
41
+ task benchmark: %i[benchmark:to_sql benchmark:select_query]
@@ -3,13 +3,7 @@
3
3
  module ActiveRecord
4
4
  module Originator
5
5
  module ArelVisitorExtension
6
- def accept(object, collector)
7
- super(object, CollectorProxy.new(collector))
8
- end
9
-
10
- private
11
-
12
- %i[
6
+ TARGET_NODE_CLASSESS = %i[
13
7
  Ascending
14
8
  Descending
15
9
  Equality
@@ -21,7 +15,15 @@ module ActiveRecord
21
15
  LessThan
22
16
  LessThanOrEqual
23
17
  GreaterThanOrEqual
24
- ].each do |klass_name|
18
+ ]
19
+
20
+ def accept(object, collector)
21
+ super(object, CollectorProxy.new(collector))
22
+ end
23
+
24
+ private
25
+
26
+ TARGET_NODE_CLASSESS.each do |klass_name|
25
27
  define_method(:"visit_Arel_Nodes_#{klass_name}") do |o, collector|
26
28
  __skip__ = begin
27
29
  comment = originator_comment(o)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveRecord
4
4
  module Originator
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -10,7 +10,13 @@ require_relative "originator/arel_node_extension"
10
10
  require_relative "originator/arel_visitor_extension"
11
11
  require_relative "originator/collector_proxy"
12
12
 
13
- Arel::Nodes::Node.descendants.each do |klass|
13
+ ActiveRecord::Originator::ArelVisitorExtension::TARGET_NODE_CLASSESS.each do |name|
14
+ begin
15
+ klass = Arel::Nodes.const_get(name)
16
+ rescue NameError
17
+ # Some classes are not defined in old arel
18
+ next
19
+ end
14
20
  klass.prepend ActiveRecord::Originator::ArelNodeExtension
15
21
  end
16
22
  Arel::Visitors::ToSql.prepend ActiveRecord::Originator::ArelVisitorExtension
@@ -6,7 +6,7 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: 372c833bb52be1bc34aef5e2793ab47c35c0dba9
9
+ revision: be76a75932e8ed6ee91a95ba936cf88b674bf044
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: activerecord
@@ -14,7 +14,7 @@ gems:
14
14
  source:
15
15
  type: git
16
16
  name: ruby/gem_rbs_collection
17
- revision: 372c833bb52be1bc34aef5e2793ab47c35c0dba9
17
+ revision: be76a75932e8ed6ee91a95ba936cf88b674bf044
18
18
  remote: https://github.com/ruby/gem_rbs_collection.git
19
19
  repo_dir: gems
20
20
  - name: activesupport
@@ -22,7 +22,7 @@ gems:
22
22
  source:
23
23
  type: git
24
24
  name: ruby/gem_rbs_collection
25
- revision: 372c833bb52be1bc34aef5e2793ab47c35c0dba9
25
+ revision: be76a75932e8ed6ee91a95ba936cf88b674bf044
26
26
  remote: https://github.com/ruby/gem_rbs_collection.git
27
27
  repo_dir: gems
28
28
  - name: base64
@@ -38,7 +38,7 @@ gems:
38
38
  source:
39
39
  type: git
40
40
  name: ruby/gem_rbs_collection
41
- revision: 372c833bb52be1bc34aef5e2793ab47c35c0dba9
41
+ revision: be76a75932e8ed6ee91a95ba936cf88b674bf044
42
42
  remote: https://github.com/ruby/gem_rbs_collection.git
43
43
  repo_dir: gems
44
44
  - name: connection_pool
@@ -46,7 +46,7 @@ gems:
46
46
  source:
47
47
  type: git
48
48
  name: ruby/gem_rbs_collection
49
- revision: 372c833bb52be1bc34aef5e2793ab47c35c0dba9
49
+ revision: be76a75932e8ed6ee91a95ba936cf88b674bf044
50
50
  remote: https://github.com/ruby/gem_rbs_collection.git
51
51
  repo_dir: gems
52
52
  - name: date
@@ -62,7 +62,7 @@ gems:
62
62
  source:
63
63
  type: git
64
64
  name: ruby/gem_rbs_collection
65
- revision: 372c833bb52be1bc34aef5e2793ab47c35c0dba9
65
+ revision: be76a75932e8ed6ee91a95ba936cf88b674bf044
66
66
  remote: https://github.com/ruby/gem_rbs_collection.git
67
67
  repo_dir: gems
68
68
  - name: logger
data/rbs_collection.yaml CHANGED
@@ -6,8 +6,3 @@ sources:
6
6
  repo_dir: gems
7
7
 
8
8
  path: .gem_rbs_collection
9
-
10
- gems:
11
- - name: activerecord-originator
12
- ignore: true
13
- - name: activerecord
@@ -0,0 +1,3 @@
1
+ module Rails
2
+ def self.backtrace_cleaner: () -> untyped
3
+ end
@@ -1,6 +1,7 @@
1
1
  module ActiveRecord
2
2
  module Originator
3
3
  module ArelVisitorExtension : _ArelVisitor
4
+ TARGET_NODE_CLASSESS: Array[Symbol]
4
5
  def accept: (untyped object, _Collector collector) -> untyped
5
6
 
6
7
  private
@@ -1,7 +1,3 @@
1
- module Rails
2
- def self.backtrace_cleaner: () -> untyped
3
- end
4
-
5
1
  module ActiveRecord::Originator
6
2
  interface _ArelVisitor
7
3
  def accept: (untyped, untyped) -> untyped
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-originator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -48,6 +48,7 @@ extra_rdoc_files: []
48
48
  files:
49
49
  - ".rspec"
50
50
  - ".rubocop.yml"
51
+ - CHANGELOG.md
51
52
  - LICENSE
52
53
  - README.md
53
54
  - Rakefile
@@ -60,12 +61,13 @@ files:
60
61
  - lib/activerecord/originator/version.rb
61
62
  - rbs_collection.lock.yaml
62
63
  - rbs_collection.yaml
64
+ - sig/_polyfill/rails.rbs
63
65
  - sig/activerecord/originator.rbs
64
66
  - sig/activerecord/originator/arel_node_extension.rbs
65
67
  - sig/activerecord/originator/arel_visitor_extension.rbs
66
68
  - sig/activerecord/originator/collector_proxy.rbs
67
69
  - sig/activerecord/originator/version.rbs
68
- - sig/polyfill.rbs
70
+ - sig/interfaces.rbs
69
71
  homepage: https://github.com/pocke/activerecord-originator
70
72
  licenses:
71
73
  - MIT