bulletmark_repairer 0.1.1 → 0.1.2

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: 5a5858e9552c2cf6259b9102c1f0980607baab37030962e55b56e83b5fd61d36
4
- data.tar.gz: ebcd21ae7ab79f0113e53862fff5ef5700d24385d1eea98eb3bb731e533aff9d
3
+ metadata.gz: 533eed3a74c78c89236e5c1355f588814c6a4017cf79af12f0a0e23fe030fcde
4
+ data.tar.gz: bf8a718e822ba241ab3299f675db3809870d955257bc5279644285373a619141
5
5
  SHA512:
6
- metadata.gz: 5251a08f17df69a9d8df9c6770d823b90a4bf99949f5ce241ee78f124365e63cd655fe68b9eb6d10b6a7bc048ac4d7de87f010593fc2c492a80abadf164d1d54
7
- data.tar.gz: b5f4c055095c3372ffffa0b9ae87b64c56d024b27fd177ddb99854063215cabae75692fb3d603bdaac77f01c97753a4b8e6aac7e90fc0af8905b142e3c48064d
6
+ metadata.gz: a33cc9ba73a76ebca97b8293677d8498761a07c2a6680e5182a65b2d8f7cb6237196506aedee63ed4f798168beb4161072ee5e62cbcee9506c4040e4584a508f
7
+ data.tar.gz: 2fb1af553ee13ca638023120306f6284b4d04ae567171616cee658ee5277f1bb33a589d769d7625ad0d6b445d06664a068dc49db479e8ac91934d36aef3553d6
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
+ ## [0.1.2] - 2023-10-16
2
+
3
+ - Reduce dependencies [#1](https://github.com/makicamel/bulletmark_repairer/pull/1) [@tricknotes]()
4
+ - Stop using class instance variables for thread safe [024f6c5](https://github.com/makicamel/bulletmark_repairer/commit/024f6c53f82b182a998c1e43de48d8c6c9ce5bf3)
5
+
1
6
  ## [0.1.1] - 2023-10-11
2
7
 
3
- - Support Ruby 3.0 dbdf27c6c9a7259ad9474153d2394da5bac45b43
8
+ - Support Ruby 3.0 [dbdf27c](https://github.com/makicamel/bulletmark_repairer/commit/dbdf27c6c9a7259ad9474153d2394da5bac45b43)
4
9
 
5
10
  ## [0.1.0] - 2023-10-10
6
11
 
data/Gemfile CHANGED
@@ -8,7 +8,6 @@ gemspec
8
8
  gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'factory_bot_rails'
11
- gem 'rails'
12
11
  gem 'rspec', '~> 3.0'
13
12
  gem 'rspec-rails', '~> 3.0'
14
13
  gem 'sqlite3'
data/README.md CHANGED
@@ -7,7 +7,7 @@ BulletmarkRepairer is an auto corrector for N+1 queries detected at runtime on R
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'bulletmark_repairer', group :development, :test
10
+ gem 'bulletmark_repairer', group: %w(development test)
11
11
  ```
12
12
 
13
13
  ## Usage
@@ -1,18 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulletmarkRepairer
4
- def self.associations
5
- @associations ||= ApplicationAssociations.new
6
- end
7
-
8
- def self.key(target_klass_name, base_klass_name, candidates)
9
- associations.key(target_klass_name, base_klass_name, candidates)
10
- end
11
-
12
- def self.reset_associations
13
- @associations = nil
14
- end
15
-
16
4
  class ApplicationAssociations
17
5
  def key(target_klass_name, base_klass_name, candidates)
18
6
  key = target_klass_name.underscore
@@ -10,13 +10,19 @@ module BulletmarkRepairer
10
10
  if associations[marker.index]
11
11
  associations[marker.index].add(marker)
12
12
  else
13
- associations[marker.index] = Associations.new(marker)
13
+ associations[marker.index] = Associations.new(marker, @application_associations)
14
14
  end
15
15
  end
16
16
 
17
17
  def associations
18
18
  @associations ||= {}
19
19
  end
20
+
21
+ private
22
+
23
+ def initialize
24
+ @application_associations = BulletmarkRepairer::ApplicationAssociations.new
25
+ end
20
26
  end
21
27
 
22
28
  class Associations
@@ -38,9 +44,10 @@ module BulletmarkRepairer
38
44
 
39
45
  private
40
46
 
41
- def initialize(marker)
47
+ def initialize(marker, application_associations)
42
48
  @marker = marker
43
49
  @associations = { base: marker.associations }
50
+ @application_associations = application_associations
44
51
  end
45
52
 
46
53
  # @return [Hash, nil]
@@ -66,12 +73,12 @@ module BulletmarkRepairer
66
73
  def formed_key(marker:, associations:)
67
74
  case associations
68
75
  when Hash
69
- BulletmarkRepairer.key(marker.base_class, @marker.base_class, associations.keys) ||
70
- BulletmarkRepairer.key(marker.base_class, @marker.base_class, associations.values.flatten)
76
+ @application_associations.key(marker.base_class, @marker.base_class, associations.keys) ||
77
+ @application_associations.key(marker.base_class, @marker.base_class, associations.values.flatten)
71
78
  when Array
72
- BulletmarkRepairer.key(marker.base_class, @marker.base_class, associations)
79
+ @application_associations.key(marker.base_class, @marker.base_class, associations)
73
80
  else # Symbol, String
74
- BulletmarkRepairer.key(marker.base_class, @marker.base_class, [associations])
81
+ @application_associations.key(marker.base_class, @marker.base_class, [associations])
75
82
  end
76
83
  end
77
84
 
@@ -5,7 +5,7 @@ require 'securerandom'
5
5
  require 'parser/runner/ruby_rewrite'
6
6
 
7
7
  module BulletmarkRepairer
8
- class Pathcer
8
+ class Patcher
9
9
  def self.execute(notifications:, controller:, action:)
10
10
  new(notifications: notifications, controller: controller, action: action).execute
11
11
  end
@@ -7,12 +7,11 @@ module BulletmarkRepairer
7
7
  end
8
8
 
9
9
  def call(env)
10
- BulletmarkRepairer.reset_associations
11
10
  @app.call(env)
12
11
  ensure
13
12
  begin
14
13
  if Thread.current[:bullet_notification_collector].notifications_present?
15
- BulletmarkRepairer::Pathcer.execute(
14
+ BulletmarkRepairer::Patcher.execute(
16
15
  notifications: Thread.current[:bullet_notification_collector],
17
16
  controller: env['action_dispatch.request.parameters']['controller'],
18
17
  action: env['action_dispatch.request.parameters']['action']
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BulletmarkRepairer
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'bulletmark_repairer/version'
4
4
  require 'bulletmark_repairer/railtie' if ENV['REPAIR']
5
- require 'bulletmark_repairer/bulletmark_repairer'
5
+ require 'bulletmark_repairer/application_associations'
6
6
  require 'bulletmark_repairer/associations_builder'
7
7
  require 'bulletmark_repairer/configuration'
8
8
  require 'bulletmark_repairer/corrector_builder'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulletmark_repairer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - makicamel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bullet
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rails
56
+ name: railties
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -68,8 +82,8 @@ files:
68
82
  - README.md
69
83
  - Rakefile
70
84
  - lib/bulletmark_repairer.rb
85
+ - lib/bulletmark_repairer/application_associations.rb
71
86
  - lib/bulletmark_repairer/associations_builder.rb
72
- - lib/bulletmark_repairer/bulletmark_repairer.rb
73
87
  - lib/bulletmark_repairer/configuration.rb
74
88
  - lib/bulletmark_repairer/controller_corrector.rb
75
89
  - lib/bulletmark_repairer/corrector.rb