solidus_identifiers 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: 2ac7db7c74c7e0fb5462f156743944dcc69ebd4db170bd72aeb4ad62c58498a9
4
- data.tar.gz: 5d3f64e0cb83e982ada48677d1bed8a6dc7c6895ecf5bbefcaa683a25de49c6d
3
+ metadata.gz: f666c9e8f903673bd6358596729c88956539f416a04aae2aab7bd66472fd50c8
4
+ data.tar.gz: 0e98fb474a73c7eaf886e3815339a039d9c301c48a4a87a5e56e4917e79214e3
5
5
  SHA512:
6
- metadata.gz: 0f8aefcb106aaf7bf87c31c09f1bcc24ca571ac88a4ee9a7d33590c5d598047b6a1bad1f622ab4f2a30aa9fd2ed12db69a4000f3720018103c9485339084c8d9
7
- data.tar.gz: c3815fba3f4e6df9b98b9befa584fe3049a72c201cb43c14070d67a59b5bf7bc97d3dec72f7f6b742022a6c681b7edcf11b7fbe42605ba0c2ca15ef421615308
6
+ metadata.gz: e1b7923cc95ce8a64921321ef29dfb8730bdb36e1c7b0b9860cc845afc0d45b5c4d271284c99edd63ce2cce1f9ceb8c0485fb78977c3c4cbab44a76a5255d8b8
7
+ data.tar.gz: 3fd1106cd29fb293e57948ef6fdc8da9e5f1600fd79082d02c88e0b3afeb344f8299a26eeaabe8d36dd03ad36c0dbb9337174b7224e53250c6e9a74fc47107c9
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'spree/core'
4
4
  require 'solidus_identifiers'
5
+ require 'byebug'
5
6
 
6
7
  module SolidusIdentifiers
7
8
  class Engine < Rails::Engine
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusIdentifiers
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -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
@@ -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', '> 0.4'
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.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: '0.4'
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: '0.4'
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