solidus_support 0.4.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +68 -0
- data/Gemfile +12 -0
- data/README.md +21 -1
- data/bin/console +1 -0
- data/lib/solidus_support.rb +18 -11
- data/lib/solidus_support/engine_extensions.rb +99 -1
- data/lib/solidus_support/version.rb +1 -1
- data/solidus_support.gemspec +1 -1
- data/spec/solidus_support_spec.rb +34 -1
- data/spec/support/dummy_app.rb +0 -1
- metadata +15 -14
- data/lib/solidus_support/engine_extensions/decorators.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d0b61a92f9ea8174330391a7bad3543dc0725f68e9fd380011391e580abab75
|
4
|
+
data.tar.gz: 269a38d161f392811ed2ec1c2a523b67a92557b7a9828c2c2639a2d504df06a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ab8b557078b085cd966e3e45652ba7f20e4b26588f74a66f94da5f0dc7cd1824f68672d354656d346baa97bc1f8d3e37b469ab0871d5a247af1a7368b23bb2
|
7
|
+
data.tar.gz: 4401a91bdecea435d21f175ea4c1dd77b3f68006ed6221338435e6e1f8a27de6b0533dfdb88ec3ab6401554125d0de187fd38ff7a77a99fc59350292734eab4f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,73 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v0.7.0](https://github.com/solidusio/solidus_support/tree/v0.7.0) (2020-10-28)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/solidusio/solidus_support/compare/v0.6.0...v0.7.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- Could we get a new release? [\#49](https://github.com/solidusio/solidus_support/issues/49)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Use `Spree::Event. activate\_all\_subscribers` when available [\#53](https://github.com/solidusio/solidus_support/pull/53) ([spaghetticode](https://github.com/spaghetticode))
|
14
|
+
- Support Rails 5.1.x [\#51](https://github.com/solidusio/solidus_support/pull/51) ([brchristian](https://github.com/brchristian))
|
15
|
+
- Remove redundant `solidus\_core` dev dependency [\#50](https://github.com/solidusio/solidus_support/pull/50) ([brchristian](https://github.com/brchristian))
|
16
|
+
|
17
|
+
## [v0.6.0](https://github.com/solidusio/solidus_support/tree/v0.6.0) (2020-07-24)
|
18
|
+
|
19
|
+
[Full Changelog](https://github.com/solidusio/solidus_support/compare/v0.5.1...v0.6.0)
|
20
|
+
|
21
|
+
**Implemented enhancements:**
|
22
|
+
|
23
|
+
- Autoload Solidus Event subscribers from extensions [\#45](https://github.com/solidusio/solidus_support/pull/45) ([spaghetticode](https://github.com/spaghetticode))
|
24
|
+
|
25
|
+
**Fixed bugs:**
|
26
|
+
|
27
|
+
- Load event subscribers only when Spree::Event is available [\#47](https://github.com/solidusio/solidus_support/pull/47) ([spaghetticode](https://github.com/spaghetticode))
|
28
|
+
|
29
|
+
**Closed issues:**
|
30
|
+
|
31
|
+
- Namespace Conflicts [\#48](https://github.com/solidusio/solidus_support/issues/48)
|
32
|
+
|
33
|
+
**Merged pull requests:**
|
34
|
+
|
35
|
+
- Stop using SolidusSupport.solidus\_gem\_version [\#46](https://github.com/solidusio/solidus_support/pull/46) ([elia](https://github.com/elia))
|
36
|
+
- Add frontend/backend/api decorators to autoload path [\#44](https://github.com/solidusio/solidus_support/pull/44) ([kennyadsl](https://github.com/kennyadsl))
|
37
|
+
|
38
|
+
## [v0.5.1](https://github.com/solidusio/solidus_support/tree/v0.5.1) (2020-04-15)
|
39
|
+
|
40
|
+
[Full Changelog](https://github.com/solidusio/solidus_support/compare/v0.5.0...v0.5.1)
|
41
|
+
|
42
|
+
**Merged pull requests:**
|
43
|
+
|
44
|
+
- Push decorators to autoload path using config.autoload\_paths [\#43](https://github.com/solidusio/solidus_support/pull/43) ([kennyadsl](https://github.com/kennyadsl))
|
45
|
+
|
46
|
+
## [v0.5.0](https://github.com/solidusio/solidus_support/tree/v0.5.0) (2020-02-18)
|
47
|
+
|
48
|
+
[Full Changelog](https://github.com/solidusio/solidus_support/compare/v0.4.1...v0.5.0)
|
49
|
+
|
50
|
+
**Merged pull requests:**
|
51
|
+
|
52
|
+
- Load Solidus engine extension files automatically [\#42](https://github.com/solidusio/solidus_support/pull/42) ([aldesantis](https://github.com/aldesantis))
|
53
|
+
- Deprecate SolidusSupport.solidus\_gem\_version [\#37](https://github.com/solidusio/solidus_support/pull/37) ([kennyadsl](https://github.com/kennyadsl))
|
54
|
+
|
55
|
+
## [v0.4.1](https://github.com/solidusio/solidus_support/tree/v0.4.1) (2020-01-16)
|
56
|
+
|
57
|
+
[Full Changelog](https://github.com/solidusio/solidus_support/compare/v0.4.0...v0.4.1)
|
58
|
+
|
59
|
+
**Closed issues:**
|
60
|
+
|
61
|
+
- Should use require\_dependency instead of require/load [\#34](https://github.com/solidusio/solidus_support/issues/34)
|
62
|
+
- Add a LICENSE [\#20](https://github.com/solidusio/solidus_support/issues/20)
|
63
|
+
|
64
|
+
**Merged pull requests:**
|
65
|
+
|
66
|
+
- Update solidus\_dev\_support [\#41](https://github.com/solidusio/solidus_support/pull/41) ([aldesantis](https://github.com/aldesantis))
|
67
|
+
- Replace manual cache checks w/ require\_dependency [\#39](https://github.com/solidusio/solidus_support/pull/39) ([elia](https://github.com/elia))
|
68
|
+
- Fixes isse when zeitwerk is not enabled [\#38](https://github.com/solidusio/solidus_support/pull/38) ([softr8](https://github.com/softr8))
|
69
|
+
- Spring cleaning [\#33](https://github.com/solidusio/solidus_support/pull/33) ([aldesantis](https://github.com/aldesantis))
|
70
|
+
|
3
71
|
## [v0.4.0](https://github.com/solidusio/solidus_support/tree/v0.4.0) (2019-12-16)
|
4
72
|
|
5
73
|
[Full Changelog](https://github.com/solidusio/solidus_support/compare/v0.3.2...v0.4.0)
|
data/Gemfile
CHANGED
@@ -16,3 +16,15 @@ else
|
|
16
16
|
end
|
17
17
|
|
18
18
|
gemspec
|
19
|
+
|
20
|
+
# There is an issue with Sprockets 4 not accepting a custom path for
|
21
|
+
# the assets manifest, which doesn't play well with in-memory dummy
|
22
|
+
# apps such as the one we use in this gem.
|
23
|
+
|
24
|
+
# A fix was provided for sprockets-rails[1] but it was not accepted
|
25
|
+
# yet.
|
26
|
+
|
27
|
+
# [1]: rails/sprockets-rails#446
|
28
|
+
#
|
29
|
+
# Please do not remove this line until we have a solution.
|
30
|
+
gem 'sprockets', '~> 3'
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ module SolidusExtensionName
|
|
38
38
|
class Engine < Rails::Engine
|
39
39
|
engine_name 'solidus_extension_name'
|
40
40
|
|
41
|
-
include SolidusSupport::EngineExtensions
|
41
|
+
include SolidusSupport::EngineExtensions
|
42
42
|
|
43
43
|
# ...
|
44
44
|
end
|
@@ -57,6 +57,26 @@ end
|
|
57
57
|
config.to_prepare(&method(:activate).to_proc)
|
58
58
|
```
|
59
59
|
|
60
|
+
#### Loading files conditionally
|
61
|
+
|
62
|
+
If you include `EngineExtensions` in your extension and structure your files according to the
|
63
|
+
expected paths, they will be loaded automagically only when the relevant Solidus engines are
|
64
|
+
available.
|
65
|
+
|
66
|
+
Here's what an example structure may look like:
|
67
|
+
|
68
|
+
- `lib/views/backend`: will only be added to the view paths when `solidus_backend` is available.
|
69
|
+
- `lib/controllers/backend`: will only be added to the controller paths when `solidus_backend` is
|
70
|
+
available.
|
71
|
+
- `lib/decorators/backend`: will only be added to the decorator paths when `solidus_backend` is
|
72
|
+
available.
|
73
|
+
|
74
|
+
The same goes for `frontend` and `api`.
|
75
|
+
|
76
|
+
We strongly recommend following this structure and making your extensions so that they're not
|
77
|
+
dependent on anything other than `solidus_core`, only augmenting the functionality of the other
|
78
|
+
engines when they are available.
|
79
|
+
|
60
80
|
## Development
|
61
81
|
|
62
82
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new
|
data/bin/console
CHANGED
data/lib/solidus_support.rb
CHANGED
@@ -8,25 +8,32 @@ require 'solidus_core'
|
|
8
8
|
module SolidusSupport
|
9
9
|
class << self
|
10
10
|
def solidus_gem_version
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# 1.0 doesn't have gem_version
|
18
|
-
Gem::Specification.detect { |x| x.name == 'solidus_core' }.version
|
19
|
-
end
|
11
|
+
ActiveSupport::Deprecation.warn <<-WARN.squish, caller
|
12
|
+
SolidusSupport.solidus_gem_version is deprecated and will be removed
|
13
|
+
in solidus_support 1.0. Please use Spree.solidus_gem_version instead.
|
14
|
+
WARN
|
15
|
+
|
16
|
+
Spree.solidus_gem_version
|
20
17
|
end
|
21
18
|
|
22
19
|
def reset_spree_preferences_deprecated?
|
23
20
|
first_version_without_reset = Gem::Requirement.new('>= 2.9')
|
24
|
-
first_version_without_reset.satisfied_by?(solidus_gem_version)
|
21
|
+
first_version_without_reset.satisfied_by?(Spree.solidus_gem_version)
|
22
|
+
end
|
23
|
+
|
24
|
+
def combined_first_and_last_name_in_address?
|
25
|
+
versions_before_preference = Gem::Requirement.new('< 2.10')
|
26
|
+
versions_after_preference = Gem::Requirement.new('>= 3.0.0.alpha')
|
27
|
+
|
28
|
+
return false if versions_before_preference.satisfied_by?(Spree.solidus_gem_version)
|
29
|
+
return true if versions_after_preference.satisfied_by?(Spree.solidus_gem_version)
|
30
|
+
|
31
|
+
Spree::Config.use_combined_first_and_last_name_in_address
|
25
32
|
end
|
26
33
|
|
27
34
|
def new_gateway_code?
|
28
35
|
first_version_with_new_gateway_code = Gem::Requirement.new('>= 2.3')
|
29
|
-
first_version_with_new_gateway_code.satisfied_by?(solidus_gem_version)
|
36
|
+
first_version_with_new_gateway_code.satisfied_by?(Spree.solidus_gem_version)
|
30
37
|
end
|
31
38
|
|
32
39
|
def payment_source_parent_class
|
@@ -1,3 +1,101 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
module SolidusSupport
|
4
|
+
module EngineExtensions
|
5
|
+
include ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
6
|
+
deprecate_constant 'Decorators', 'SolidusSupport::EngineExtensions'
|
7
|
+
|
8
|
+
def self.included(engine)
|
9
|
+
engine.extend ClassMethods
|
10
|
+
|
11
|
+
engine.class_eval do
|
12
|
+
solidus_decorators_root.glob('*') do |decorators_folder|
|
13
|
+
config.autoload_paths += [decorators_folder]
|
14
|
+
end
|
15
|
+
|
16
|
+
config.to_prepare(&method(:activate))
|
17
|
+
|
18
|
+
enable_solidus_engine_support('backend') if SolidusSupport.backend_available?
|
19
|
+
enable_solidus_engine_support('frontend') if SolidusSupport.frontend_available?
|
20
|
+
enable_solidus_engine_support('api') if SolidusSupport.api_available?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
def activate
|
26
|
+
load_solidus_decorators_from(solidus_decorators_root)
|
27
|
+
load_solidus_subscribers_from(solidus_subscribers_root)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Loads Solidus event subscriber files.
|
31
|
+
#
|
32
|
+
# This allows to add event subscribers to extensions without explicitly subscribing them,
|
33
|
+
# similarly to what happens in Solidus core.
|
34
|
+
def load_solidus_subscribers_from(path)
|
35
|
+
if defined? Spree::Event
|
36
|
+
path.glob("**/*_subscriber.rb") do |subscriber_path|
|
37
|
+
require_dependency(subscriber_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
if Spree::Event.respond_to?(:activate_all_subscribers)
|
41
|
+
Spree::Event.activate_all_subscribers
|
42
|
+
else
|
43
|
+
Spree::Event.subscribers.each(&:subscribe!)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Loads decorator files.
|
49
|
+
#
|
50
|
+
# This is needed since they are never explicitly referenced in the application code and
|
51
|
+
# won't be loaded by default. We need them to be executed regardless in order to decorate
|
52
|
+
# existing classes.
|
53
|
+
def load_solidus_decorators_from(path)
|
54
|
+
path.glob('**/*.rb') do |decorator_path|
|
55
|
+
require_dependency(decorator_path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
# Returns the root for this engine's decorators.
|
62
|
+
#
|
63
|
+
# @return [Path]
|
64
|
+
def solidus_decorators_root
|
65
|
+
root.join('app/decorators')
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns the root for this engine's Solidus event subscribers.
|
69
|
+
#
|
70
|
+
# @return [Path]
|
71
|
+
def solidus_subscribers_root
|
72
|
+
root.join("app/subscribers")
|
73
|
+
end
|
74
|
+
|
75
|
+
# Enables support for a Solidus engine.
|
76
|
+
#
|
77
|
+
# This will tell Rails to:
|
78
|
+
#
|
79
|
+
# * add +lib/controllers/[engine]+ to the controller paths;
|
80
|
+
# * add +lib/views/[engine]+ to the view paths;
|
81
|
+
# * load the decorators in +lib/decorators/[engine]+.
|
82
|
+
#
|
83
|
+
# @see #load_solidus_decorators_from
|
84
|
+
def enable_solidus_engine_support(engine)
|
85
|
+
paths['app/controllers'] << "lib/controllers/#{engine}"
|
86
|
+
paths['app/views'] << "lib/views/#{engine}"
|
87
|
+
|
88
|
+
path = root.join("lib/decorators/#{engine}")
|
89
|
+
|
90
|
+
config.autoload_paths += path.glob('*')
|
91
|
+
|
92
|
+
engine_context = self
|
93
|
+
config.to_prepare do
|
94
|
+
engine_context.instance_eval do
|
95
|
+
load_solidus_decorators_from(path)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/solidus_support.gemspec
CHANGED
@@ -21,11 +21,11 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
+
s.add_development_dependency 'rails'
|
24
25
|
s.add_development_dependency 'bundler'
|
25
26
|
s.add_development_dependency 'rake'
|
26
27
|
s.add_development_dependency 'rspec-rails'
|
27
28
|
s.add_development_dependency 'rubocop'
|
28
29
|
s.add_development_dependency 'rubocop-rspec'
|
29
|
-
s.add_development_dependency 'solidus_core'
|
30
30
|
s.add_development_dependency 'solidus_dev_support'
|
31
31
|
end
|
@@ -7,7 +7,7 @@ RSpec.describe SolidusSupport do
|
|
7
7
|
let(:credit_card) { nil }
|
8
8
|
|
9
9
|
before do
|
10
|
-
allow(
|
10
|
+
allow(Spree).to receive(:solidus_gem_version) do
|
11
11
|
Gem::Version.new(solidus_version)
|
12
12
|
end
|
13
13
|
end
|
@@ -42,4 +42,37 @@ RSpec.describe SolidusSupport do
|
|
42
42
|
end
|
43
43
|
# rubocop:enable RSpec/NestedGroups
|
44
44
|
end
|
45
|
+
|
46
|
+
describe '.combined_first_and_last_name_in_address?' do
|
47
|
+
subject { described_class.combined_first_and_last_name_in_address? }
|
48
|
+
|
49
|
+
before do
|
50
|
+
allow(Spree).to receive(:solidus_gem_version) do
|
51
|
+
Gem::Version.new(solidus_version)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when Solidus did not have the code to combine addresses fields' do
|
56
|
+
let(:solidus_version) { '2.9.3' }
|
57
|
+
|
58
|
+
it { is_expected.to be_falsey }
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'when Solidus has preference to choose if combine addresses fields' do
|
62
|
+
let(:solidus_version) { '2.10.3' }
|
63
|
+
before do
|
64
|
+
allow(Spree::Config)
|
65
|
+
.to receive(:use_combined_first_and_last_name_in_address)
|
66
|
+
.and_return(true)
|
67
|
+
end
|
68
|
+
|
69
|
+
it { is_expected.to be_truthy }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when Solidus only has code to combine addresses fields' do
|
73
|
+
let(:solidus_version) { '3.0.0' }
|
74
|
+
|
75
|
+
it { is_expected.to be_truthy }
|
76
|
+
end
|
77
|
+
end
|
45
78
|
end
|
data/spec/support/dummy_app.rb
CHANGED
@@ -14,7 +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
|
-
config.active_record.sqlite3.represent_boolean_as_integer = true
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hawthorn
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubocop
|
70
|
+
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rubocop-rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email: john@stembolt.com
|
113
113
|
executables: []
|
114
114
|
extensions: []
|
@@ -129,10 +129,10 @@ files:
|
|
129
129
|
- bin/setup
|
130
130
|
- lib/solidus_support.rb
|
131
131
|
- lib/solidus_support/engine_extensions.rb
|
132
|
-
- lib/solidus_support/engine_extensions/decorators.rb
|
133
132
|
- lib/solidus_support/migration.rb
|
134
133
|
- lib/solidus_support/version.rb
|
135
134
|
- solidus_support.gemspec
|
135
|
+
- spec/examples.txt
|
136
136
|
- spec/solidus_support_spec.rb
|
137
137
|
- spec/spec_helper.rb
|
138
138
|
- spec/support/dummy_app.rb
|
@@ -141,7 +141,7 @@ homepage: https://github.com/solidusio/solidus_support
|
|
141
141
|
licenses:
|
142
142
|
- BSD-3-Clause
|
143
143
|
metadata: {}
|
144
|
-
post_install_message:
|
144
|
+
post_install_message:
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|
147
147
|
- lib
|
@@ -156,12 +156,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
159
|
+
rubygems_version: 3.1.4
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Common runtime helpers for Solidus extensions.
|
163
163
|
test_files:
|
164
164
|
- spec/spec_helper.rb
|
165
|
+
- spec/examples.txt
|
165
166
|
- spec/solidus_support_spec.rb
|
166
167
|
- spec/support/dummy_app.rb
|
167
168
|
- spec/support/dummy_app/database.yml
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SolidusSupport
|
4
|
-
module EngineExtensions
|
5
|
-
module Decorators
|
6
|
-
def self.included(engine)
|
7
|
-
engine.class_eval do
|
8
|
-
extend ClassMethods
|
9
|
-
config.to_prepare(&method(:activate).to_proc)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module ClassMethods
|
14
|
-
def activate
|
15
|
-
base_path = root.join('app/decorators')
|
16
|
-
|
17
|
-
if Rails.respond_to?(:autoloaders) && Rails.autoloaders.main
|
18
|
-
# Add decorators folder to the Rails autoloader. This
|
19
|
-
# allows Zeitwerk to resolve decorators paths correctly,
|
20
|
-
# when used.
|
21
|
-
Dir.glob(base_path.join('*')) do |decorators_folder|
|
22
|
-
Rails.autoloaders.main.push_dir(decorators_folder)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Load decorator files. This is needed since they are
|
27
|
-
# never explicitely referenced in the application code
|
28
|
-
# and won't be loaded by default. We need them to be
|
29
|
-
# executed anyway to extend exisiting classes.
|
30
|
-
Dir.glob(base_path.join('**/*.rb')) do |decorator_path|
|
31
|
-
require_dependency(decorator_path)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|