conventional_extensions 0.2.1 → 0.3.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 +9 -0
- data/Gemfile.lock +1 -1
- data/lib/conventional_extensions/loader.rb +1 -7
- data/lib/conventional_extensions/version.rb +1 -1
- data/lib/conventional_extensions.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a9c04f9382953e08d30d29f802edd622ef28f91da4314d77c21d7f0eb09f2fe
|
4
|
+
data.tar.gz: b51b6c673302e93aec88613b42e1e7c44a7c0d4055165057ffac546614fd357f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed770c9838eb07f7c752bf2f1973edf9a5ad77511ec6d939600114d203a3e6db9270d5ec8ef3b354c6914728ca0afe259c128d569aef0c9639928c6c4ed36895
|
7
|
+
data.tar.gz: d5035eff9ad821562a828dc671927a89fffe2ad1f1fe49d91b3c3147131837ecc9c82caa8adaaf26ab48149bc92a9520a3bce514efdd11380a53ff36fa657b18
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.0] - 2022-09-27
|
4
|
+
|
5
|
+
- Fixes defining a nested extension, e.g. `Organization::User` with `app/models/organization/user/extensions/`.
|
6
|
+
- Removes support for defining a nested extension within the namespace file. I couldn't unify it with the fix above, so it went.
|
7
|
+
|
8
|
+
## [0.2.2] - 2022-09-08
|
9
|
+
|
10
|
+
- Fixes Zeitwerk 2.6.0 compatibility issue where extensions wouldn't load and throw an exception. See https://github.com/kaspth/conventional_extensions/commit/7fc25f1e860637e8df9fd0e81e7ca038c8c34aa0
|
11
|
+
|
3
12
|
## [0.2.1] - 2022-09-07
|
4
13
|
|
5
14
|
- Fixes `extend ConventionalExtensions.load_on_inherited` not finding the right directory to load extensions from. See https://github.com/kaspth/conventional_extensions/commit/1f6fe9cbf2fe44ed9d699a5dd485eaa366d875a4
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ require "set"
|
|
5
5
|
class ConventionalExtensions::Loader
|
6
6
|
def initialize(klass, path)
|
7
7
|
@loaded, @klass, @matcher = Set.new, klass, /\s*class #{klass.name}/
|
8
|
-
@path_format = File.join
|
8
|
+
@path_format = File.join path.sub(/\.rb$/, "/extensions/%s.rb")
|
9
9
|
end
|
10
10
|
|
11
11
|
def load(*extensions)
|
@@ -14,12 +14,6 @@ class ConventionalExtensions::Loader
|
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
|
-
# Logic borrowed from Active Support:
|
18
|
-
# https://github.com/rails/rails/blob/a2fc96a80cf26c11df3e86e86c1b2b61736af80c/activesupport/lib/active_support/inflector/methods.rb#L99
|
19
|
-
def underscore(name)
|
20
|
-
name.gsub("::", "/").tap { _1.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" } }.tap(&:downcase!)
|
21
|
-
end
|
22
|
-
|
23
17
|
def extension_paths
|
24
18
|
Dir.glob extension_path_for("*")
|
25
19
|
end
|
@@ -5,8 +5,8 @@ require_relative "conventional_extensions/version"
|
|
5
5
|
module ConventionalExtensions
|
6
6
|
Object.extend self # We're enriching object itself, so any object can call `load_extensions`.
|
7
7
|
|
8
|
-
def load_extensions(*extensions)
|
9
|
-
@loader = Loader.new(self,
|
8
|
+
def load_extensions(*extensions, from: Frame.previous.path)
|
9
|
+
@loader = Loader.new(self, from) unless loader_defined_before_entrance = defined?(@loader)
|
10
10
|
@loader.load(*extensions)
|
11
11
|
ensure
|
12
12
|
@loader = nil unless loader_defined_before_entrance
|
@@ -19,7 +19,13 @@ module ConventionalExtensions
|
|
19
19
|
module LoadOnInherited
|
20
20
|
def inherited(klass)
|
21
21
|
super
|
22
|
-
klass.load_extensions
|
22
|
+
klass.load_extensions from: Frame.previous.path
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module Frame
|
27
|
+
def self.previous
|
28
|
+
caller_locations(2, 1).first # Use 2 instead of 1 so we get the frame of who called us.
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conventional_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Timm Hansen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|