solidus_support 0.13.0 → 0.14.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: b29adfe3ba04b222f4644fb12d8e26d4b77f1f438d75ed4fe72873b2c29b1301
4
- data.tar.gz: b5e87fb3449a317d500bc0a87d8e45f0efafbac61c825363dc2bf0dcf8374ed9
3
+ metadata.gz: f806b6a51765583aba92e5da3dc943006b383572af0aaf02d1aba0ecce33ed5a
4
+ data.tar.gz: 46bb34278a3de81f7af8e2d90c4a3852430f204248904e37df898fbff4bac874
5
5
  SHA512:
6
- metadata.gz: b0303b76dab3ad82ff50fe85cc4508c5750241a06a2d179a2feacf005c402017c1f15488e3eb1082147449d96ea040e5a3fd2df09bd74c675d9ceef7c87906f6
7
- data.tar.gz: '068a4e6077b32e4e3a78577912fbcfbad23fede909822cb9c6a26d5d1f5346bc753d07ed38dd17cadf1e4787431b1032fc2551ea023c44a0974d75f7d7890680'
6
+ metadata.gz: a2ffa3274fb6a3bb433a50de1051083567c11b79d770281cd7001b2aca0b184c8ffb6c3f08c2f67c82c34fee941260e3f270e0b7ef7a689e7bb7d090fb40edbb
7
+ data.tar.gz: a8d1e98aa2fbc7657c0d2c78a84597c6950ca7618b26dd5b1c57a3dd24ea34fdbf80020bc6bbb7e0b5a70d7eb88a42782ebcc38e60dd3ee68d78102f968f8e98
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![CircleCI](https://dl.circleci.com/status-badge/img/gh/solidusio/solidus_support/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/solidusio/solidus_support/tree/main)
2
+
1
3
  # SolidusSupport
2
4
 
3
5
  This gem contains common runtime functionality for Solidus extensions.
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/deprecation"
4
+ require "flickwerk"
4
5
 
5
6
  module SolidusSupport
6
7
  module EngineExtensions
@@ -9,6 +10,7 @@ module SolidusSupport
9
10
 
10
11
  def self.included(engine)
11
12
  engine.extend ClassMethods
13
+ engine.include Flickwerk
12
14
 
13
15
  engine.class_eval do
14
16
  solidus_decorators_root.glob('*') do |decorators_folder|
@@ -35,16 +37,16 @@ module SolidusSupport
35
37
  # This allows to add event subscribers to extensions without explicitly subscribing them,
36
38
  # similarly to what happens in Solidus core.
37
39
  def load_solidus_subscribers_from(path)
38
- if SolidusSupport::LegacyEventCompat.using_legacy?
39
- path.glob("**/*_subscriber.rb") do |subscriber_path|
40
- require_dependency(subscriber_path)
41
- end
40
+ return unless SolidusSupport::LegacyEventCompat.using_legacy?
42
41
 
43
- if Spree::Event.respond_to?(:activate_all_subscribers)
44
- Spree::Event.activate_all_subscribers
45
- else
46
- Spree::Event.subscribers.each(&:subscribe!)
47
- end
42
+ path.glob("**/*_subscriber.rb") do |subscriber_path|
43
+ require_dependency(subscriber_path)
44
+ end
45
+
46
+ if Spree::Event.respond_to?(:activate_all_subscribers)
47
+ Spree::Event.activate_all_subscribers
48
+ else
49
+ Spree::Event.subscribers.each(&:subscribe!)
48
50
  end
49
51
  end
50
52
 
@@ -102,7 +104,7 @@ module SolidusSupport
102
104
  # by those gems, we work around those gems by adding our paths before
103
105
  # `initialize_cache`, which is the Rails initializer called before
104
106
  # `set_load_path`.
105
- initializer "#{name}_#{engine}_paths", before: :initialize_cache do
107
+ initializer "#{engine_name}_#{engine}_paths", before: :initialize_cache do
106
108
  if SolidusSupport.send(:"#{engine}_available?")
107
109
  paths['app/controllers'] << "lib/controllers/#{engine}"
108
110
  paths['app/views'] << "lib/views/#{engine}"
@@ -111,9 +113,11 @@ module SolidusSupport
111
113
 
112
114
  if SolidusSupport.send(:"#{engine}_available?")
113
115
  decorators_path = root.join("lib/decorators/#{engine}")
116
+ patches_path = root.join("lib/patches/#{engine}")
114
117
  controllers_path = root.join("lib/controllers/#{engine}")
115
118
  components_path = root.join("lib/components/#{engine}")
116
119
  config.autoload_paths += decorators_path.glob('*')
120
+ config.autoload_paths += patches_path.glob("*")
117
121
  config.autoload_paths << controllers_path if controllers_path.exist?
118
122
  config.autoload_paths << components_path if components_path.exist?
119
123
 
@@ -124,6 +128,36 @@ module SolidusSupport
124
128
  end
125
129
  end
126
130
  end
131
+
132
+ initializer "#{engine_name}_#{engine}_patch_paths" do
133
+ if SolidusSupport.send(:"#{engine}_available?")
134
+ patch_paths = root.join("lib/patches/#{engine}").glob("*")
135
+ Flickwerk.patch_paths += patch_paths
136
+ end
137
+ end
138
+
139
+ initializer "#{engine_name}_#{engine}_user_patches" do |app|
140
+ app.reloader.to_prepare do
141
+ Flickwerk.aliases["Spree.user_class"] = if Spree.respond_to?(:user_class_name)
142
+ Spree.user_class_name
143
+ else
144
+ Spree.user_class.name
145
+ end
146
+ end
147
+ end
148
+
149
+ initializer "eager_load_#{engine_name}_#{engine}_patches" do |app|
150
+ # Solidus versions < 4.5 `require` some of their application code.
151
+ # This leads to hard-to-debug problems with Flickwerk patches.
152
+ # What this does is eager-load all the patches in a `to_prepare`
153
+ # hook by constantizing them.
154
+ # You can override this behavior by setting the environment variable `SOLIDUS_LAZY_LOAD_PATCHES`.
155
+ if Spree.solidus_gem_version < Gem::Version.new("4.5.0.a") && !ENV["SOLIDUS_LAZY_LOAD_PATCHES"]
156
+ app.reloader.to_prepare do
157
+ Flickwerk.patches.each_value { _1.each(&:constantize) }
158
+ end
159
+ end
160
+ end
127
161
  end
128
162
  end
129
163
  end
@@ -23,6 +23,10 @@ module SolidusSupport
23
23
  # @param event_name [Symbol]
24
24
  # @param payload [Hash<Symbol, Any>]
25
25
  def self.publish(event_name, **payload)
26
+ SolidusSupport.deprecator.warn(
27
+ "SolidusSupport::LegacyEventCompat::Bus is deprecated and will be removed in solidus_support 1.0." \
28
+ " Please use Spree::Bus.publish instead."
29
+ )
26
30
  if SolidusSupport::LegacyEventCompat.using_legacy?
27
31
  Spree::Event.fire(event_name, payload)
28
32
  else
@@ -41,6 +41,10 @@ module SolidusSupport
41
41
  end
42
42
 
43
43
  def self.included(legacy_subscriber)
44
+ SolidusSupport.deprecator.warn(
45
+ "SolidusSupport::LegacyEventCompat::Subscriber is deprecated and will be removed in solidus_support 1.0." \
46
+ " Please `include Omnes::Subscriber` in `#{legacy_subscriber.name}` instead."
47
+ )
44
48
  legacy_subscriber.define_singleton_method(:omnes_subscriber) do
45
49
  @omnes_subscriber ||= Class.new.include(::Omnes::Subscriber).tap do |subscriber|
46
50
  legacy_subscriber.event_actions.each do |(legacy_subscriber_method, event_name)|
@@ -3,15 +3,10 @@
3
3
  module SolidusSupport
4
4
  module Migration
5
5
  def self.[](version)
6
- if Rails.gem_version >= Gem::Version.new('5.x')
7
- ActiveRecord::Migration[version]
8
- else
9
- # Rails < 5 doesn't support specifying rails version of migrations, but
10
- # it _is_ rails 4.2, so we can use that when requested.
11
- return ActiveRecord::Migration if version.to_s == '4.2'
12
-
13
- raise ArgumentError, "Unknown migration version '#{version}'; expected one of '4.2'"
14
- end
6
+ SolidusSupport.deprecator.warn(
7
+ "SolidusSupport::Migration[#{version}] is deprecated. Please use ActiveRecord::Migration[#{version}] instead."
8
+ )
9
+ ActiveRecord::Migration[version]
15
10
  end
16
11
  end
17
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusSupport
4
- VERSION = '0.13.0'
4
+ VERSION = '0.14.1'
5
5
  end
@@ -28,6 +28,9 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
+ spec.add_dependency 'flickwerk', '~> 0.3.4'
32
+ spec.add_dependency 'solidus_core', '~> 4.1'
33
+
31
34
  spec.add_development_dependency 'rails'
32
35
  spec.add_development_dependency 'bundler'
33
36
  spec.add_development_dependency 'rake'
@@ -14,9 +14,6 @@ module DummyApp
14
14
  class Application < ::Rails::Application
15
15
  config.eager_load = false
16
16
  config.paths['config/database'] = File.expand_path('dummy_app/database.yml', __dir__)
17
- if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR < 1
18
- config.active_record.legacy_connection_handling = false
19
- end
20
17
  end
21
18
  end
22
19
 
metadata CHANGED
@@ -1,16 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
8
  - Solidus Team
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2025-01-13 00:00:00.000000000 Z
11
+ date: 2025-02-11 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: flickwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: solidus_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.1'
14
41
  - !ruby/object:Gem::Dependency
15
42
  name: rails
16
43
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +150,6 @@ dependencies:
123
150
  - - "~>"
124
151
  - !ruby/object:Gem::Version
125
152
  version: 0.2.2
126
- description:
127
153
  email: contact@solidus.io
128
154
  executables: []
129
155
  extensions: []
@@ -165,7 +191,6 @@ metadata:
165
191
  homepage_uri: https://github.com/solidusio/solidus_support
166
192
  source_code_uri: https://github.com/solidusio/solidus_support
167
193
  changelog_uri: https://github.com/solidusio/solidus_support/releases
168
- post_install_message:
169
194
  rdoc_options: []
170
195
  require_paths:
171
196
  - lib
@@ -180,8 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
205
  - !ruby/object:Gem::Version
181
206
  version: '0'
182
207
  requirements: []
183
- rubygems_version: 3.5.3
184
- signing_key:
208
+ rubygems_version: 3.6.3
185
209
  specification_version: 4
186
210
  summary: Common runtime helpers for Solidus extensions.
187
211
  test_files: