solidus_identifiers 0.1.1 → 0.1.2
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/{lib/controllers/api → app/controllers}/spree/api/identifier_keys_controller.rb +0 -0
- data/{lib/controllers/api → app/controllers}/spree/api/identifiers_controller.rb +0 -0
- data/lib/solidus_identifiers/engine.rb +1 -0
- data/lib/solidus_identifiers/version.rb +1 -1
- data/lib/solidus_support/engine_extensions.rb +97 -0
- data/solidus_identifiers.gemspec +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f666c9e8f903673bd6358596729c88956539f416a04aae2aab7bd66472fd50c8
|
4
|
+
data.tar.gz: 0e98fb474a73c7eaf886e3815339a039d9c301c48a4a87a5e56e4917e79214e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b7923cc95ce8a64921321ef29dfb8730bdb36e1c7b0b9860cc845afc0d45b5c4d271284c99edd63ce2cce1f9ceb8c0485fb78977c3c4cbab44a76a5255d8b8
|
7
|
+
data.tar.gz: 3fd1106cd29fb293e57948ef6fdc8da9e5f1600fd79082d02c88e0b3afeb344f8299a26eeaabe8d36dd03ad36c0dbb9337174b7224e53250c6e9a74fc47107c9
|
File without changes
|
File without changes
|
@@ -0,0 +1,97 @@
|
|
1
|
+
##
|
2
|
+
# Support for apps on solidus support 0.4.0
|
3
|
+
#
|
4
|
+
module SolidusSupport
|
5
|
+
module EngineExtensions
|
6
|
+
include ActiveSupport::Deprecation::DeprecatedConstantAccessor
|
7
|
+
deprecate_constant 'Decorators', 'SolidusSupport::EngineExtensions'
|
8
|
+
|
9
|
+
def self.included(engine)
|
10
|
+
engine.extend ClassMethods
|
11
|
+
|
12
|
+
engine.class_eval do
|
13
|
+
solidus_decorators_root.glob('*') do |decorators_folder|
|
14
|
+
config.autoload_paths += [decorators_folder]
|
15
|
+
end
|
16
|
+
|
17
|
+
config.to_prepare(&method(:activate))
|
18
|
+
|
19
|
+
enable_solidus_engine_support('backend') if SolidusSupport.backend_available?
|
20
|
+
enable_solidus_engine_support('frontend') if SolidusSupport.frontend_available?
|
21
|
+
enable_solidus_engine_support('api') if SolidusSupport.api_available?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module ClassMethods
|
26
|
+
def activate
|
27
|
+
load_solidus_decorators_from(solidus_decorators_root)
|
28
|
+
load_solidus_subscribers_from(solidus_subscribers_root)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Loads Solidus event subscriber files.
|
32
|
+
#
|
33
|
+
# This allows to add event subscribers to extensions without explicitly subscribing them,
|
34
|
+
# similarly to what happens in Solidus core.
|
35
|
+
def load_solidus_subscribers_from(path)
|
36
|
+
if defined? Spree::Event
|
37
|
+
path.glob("**/*_subscriber.rb") do |subscriber_path|
|
38
|
+
require_dependency(subscriber_path)
|
39
|
+
end
|
40
|
+
Spree::Event.subscribers.each(&:subscribe!)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Loads decorator files.
|
45
|
+
#
|
46
|
+
# This is needed since they are never explicitly referenced in the application code and
|
47
|
+
# won't be loaded by default. We need them to be executed regardless in order to decorate
|
48
|
+
# existing classes.
|
49
|
+
def load_solidus_decorators_from(path)
|
50
|
+
path.glob('**/*.rb') do |decorator_path|
|
51
|
+
require_dependency(decorator_path)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
# Returns the root for this engine's decorators.
|
58
|
+
#
|
59
|
+
# @return [Path]
|
60
|
+
def solidus_decorators_root
|
61
|
+
root.join('app/decorators')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the root for this engine's Solidus event subscribers.
|
65
|
+
#
|
66
|
+
# @return [Path]
|
67
|
+
def solidus_subscribers_root
|
68
|
+
root.join("app/subscribers")
|
69
|
+
end
|
70
|
+
|
71
|
+
# Enables support for a Solidus engine.
|
72
|
+
#
|
73
|
+
# This will tell Rails to:
|
74
|
+
#
|
75
|
+
# * add +lib/controllers/[engine]+ to the controller paths;
|
76
|
+
# * add +lib/views/[engine]+ to the view paths;
|
77
|
+
# * load the decorators in +lib/decorators/[engine]+.
|
78
|
+
#
|
79
|
+
# @see #load_solidus_decorators_from
|
80
|
+
def enable_solidus_engine_support(engine)
|
81
|
+
paths['app/controllers'] << "lib/controllers/#{engine}"
|
82
|
+
paths['app/views'] << "lib/views/#{engine}"
|
83
|
+
|
84
|
+
path = root.join("lib/decorators/#{engine}")
|
85
|
+
|
86
|
+
config.autoload_paths += path.glob('*')
|
87
|
+
|
88
|
+
engine_context = self
|
89
|
+
config.to_prepare do
|
90
|
+
engine_context.instance_eval do
|
91
|
+
load_solidus_decorators_from(path)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
data/solidus_identifiers.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
32
|
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
|
33
|
-
spec.add_dependency 'solidus_support', '
|
33
|
+
spec.add_dependency 'solidus_support', '>= 0.4.0'
|
34
34
|
|
35
35
|
spec.add_development_dependency 'byebug'
|
36
36
|
spec.add_development_dependency 'rails-controller-testing'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_identifiers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Scott
|
@@ -34,16 +34,16 @@ dependencies:
|
|
34
34
|
name: solidus_support
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 0.4.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 0.4.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: byebug
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +104,8 @@ files:
|
|
104
104
|
- LICENSE
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
|
+
- app/controllers/spree/api/identifier_keys_controller.rb
|
108
|
+
- app/controllers/spree/api/identifiers_controller.rb
|
107
109
|
- app/decorators/helpers/spree/api/api_helpers_decorator.rb
|
108
110
|
- app/decorators/lib/spree/permission_sets/user_management_decorator.rb
|
109
111
|
- app/decorators/lib/spree/permitted_attributes_decorator.rb
|
@@ -128,13 +130,12 @@ files:
|
|
128
130
|
- db/migrate/20200603191551_create_spree_identifier_keys.rb
|
129
131
|
- db/migrate/20200603191555_create_spree_identifiers.rb
|
130
132
|
- db/migrate/20200603203105_add_unique_index_to_spree_identifier_keys.rb
|
131
|
-
- lib/controllers/api/spree/api/identifier_keys_controller.rb
|
132
|
-
- lib/controllers/api/spree/api/identifiers_controller.rb
|
133
133
|
- lib/generators/solidus_identifiers/install/install_generator.rb
|
134
134
|
- lib/solidus_identifiers.rb
|
135
135
|
- lib/solidus_identifiers/engine.rb
|
136
136
|
- lib/solidus_identifiers/factories.rb
|
137
137
|
- lib/solidus_identifiers/version.rb
|
138
|
+
- lib/solidus_support/engine_extensions.rb
|
138
139
|
- solidus_identifiers.gemspec
|
139
140
|
- spec/controllers/spree/api/identifier_keys_controller_spec.rb
|
140
141
|
- spec/controllers/spree/api/identifiers_controller_spec.rb
|